1010import org .slf4j .LoggerFactory ;
1111import org .springframework .ai .chat .client .ChatClient ;
1212import org .springframework .ai .chat .prompt .PromptTemplate ;
13- import org .springframework .beans .factory .ObjectProvider ;
1413import org .springframework .beans .factory .annotation .Value ;
1514import org .springframework .core .io .Resource ;
1615import org .springframework .stereotype .Service ;
@@ -37,15 +36,14 @@ public class LLMService {
3736 private final ChatClient chatClient ;
3837 private final ObjectMapper objectMapper = new ObjectMapper ();
3938
40- public LLMService (ObjectProvider <ChatClient .Builder > chatClientBuilderProvider ) {
41- ChatClient .Builder builder = chatClientBuilderProvider .getIfAvailable ();
42- this .chatClient = builder != null ? builder .build () : null ;
43- }
44-
45- public Map <String , Object > extractActivityData (String pdfText ) {
39+ public LLMService (ChatClient chatClient ) {
4640 if (chatClient == null ) {
4741 throw new IllegalStateException ("ChatClient is not available. Please configure a ChatModel." );
4842 }
43+ this .chatClient = chatClient ;
44+ }
45+
46+ public Map <String , Object > extractActivityData (String pdfText ) {
4947
5048 String promptText = new PromptTemplate (extractionPromptResource ).render (Map .of ("pdfText" , pdfText ));
5149
@@ -77,10 +75,6 @@ public Map<String, Object> extractActivityData(String pdfText) {
7775 * user-adjusted activity metadata to inform the schema
7876 */
7977 public String generateArtikulationsschema (String pdfText , Map <String , Object > metadata ) {
80- if (chatClient == null ) {
81- throw new IllegalStateException ("ChatClient is not available. Please configure a ChatModel." );
82- }
83-
8478 String metadataSection = buildMetadataSection (metadata );
8579 String promptText = new PromptTemplate (artikulationsschemaPromptResource )
8680 .render (Map .of ("metadataSection" , metadataSection , "pdfText" , pdfText ));
@@ -105,10 +99,6 @@ public String generateArtikulationsschema(String pdfText, Map<String, Object> me
10599 * user-adjusted activity metadata to inform the generation
106100 */
107101 public String generateDeckblatt (String pdfText , Map <String , Object > metadata ) {
108- if (chatClient == null ) {
109- throw new IllegalStateException ("ChatClient is not available. Please configure a ChatModel." );
110- }
111-
112102 String metadataSection = buildMetadataSection (metadata );
113103 String promptText = new PromptTemplate (deckblattPromptResource )
114104 .render (Map .of ("metadataSection" , metadataSection , "pdfText" , pdfText ));
@@ -134,10 +124,6 @@ public String generateDeckblatt(String pdfText, Map<String, Object> metadata) {
134124 * user-adjusted activity metadata to inform the generation
135125 */
136126 public String generateHintergrundwissen (String pdfText , Map <String , Object > metadata ) {
137- if (chatClient == null ) {
138- throw new IllegalStateException ("ChatClient is not available. Please configure a ChatModel." );
139- }
140-
141127 String metadataSection = buildMetadataSection (metadata );
142128 String promptText = new PromptTemplate (hintergrundwissenPromptResource )
143129 .render (Map .of ("metadataSection" , metadataSection , "pdfText" , pdfText ));
0 commit comments