File tree Expand file tree Collapse file tree 4 files changed +65
-1
lines changed
java/com/baeldung/springai/docker/modelrunner Expand file tree Collapse file tree 4 files changed +65
-1
lines changed Original file line number Diff line number Diff line change 73
73
<artifactId >spring-ai-spring-boot-testcontainers</artifactId >
74
74
<scope >test</scope >
75
75
</dependency >
76
+ <dependency >
77
+ <groupId >org.testcontainers</groupId >
78
+ <artifactId >junit-jupiter</artifactId >
79
+ <scope >test</scope >
80
+ </dependency >
76
81
<dependency >
77
82
<groupId >org.testcontainers</groupId >
78
83
<artifactId >chromadb</artifactId >
143
148
<spring-ai-mongodb-atlas .version>1.0.0-M7</spring-ai-mongodb-atlas .version>
144
149
<junit-jupiter .version>5.9.0</junit-jupiter .version>
145
150
<spring-boot-docker-compose .version>3.1.1</spring-boot-docker-compose .version>
146
- <spring-boot .version>3.4.5 </spring-boot .version>
151
+ <spring-boot .version>3.5.0 </spring-boot .version>
147
152
<spring-ai .version>1.0.0-M6</spring-ai .version>
148
153
<spring-ai-start-model-openai .version>1.0.0-M7</spring-ai-start-model-openai .version>
149
154
</properties >
Original file line number Diff line number Diff line change
1
+ package com .baeldung .springai .docker .modelrunner ;
2
+
3
+ import org .springframework .ai .autoconfigure .chat .client .ChatClientAutoConfiguration ;
4
+ import org .springframework .ai .autoconfigure .mistralai .MistralAiAutoConfiguration ;
5
+ import org .springframework .ai .model .openai .autoconfigure .OpenAiAudioSpeechAutoConfiguration ;
6
+ import org .springframework .boot .SpringApplication ;
7
+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
8
+ import org .springframework .boot .autoconfigure .data .mongo .MongoDataAutoConfiguration ;
9
+ import org .springframework .boot .autoconfigure .mongo .MongoAutoConfiguration ;
10
+
11
+
12
+ @ SpringBootApplication (exclude = {
13
+ ChatClientAutoConfiguration .class ,
14
+ MongoAutoConfiguration .class ,
15
+ MongoDataAutoConfiguration .class ,
16
+ org .springframework .ai .autoconfigure .vectorstore .mongo .MongoDBAtlasVectorStoreAutoConfiguration .class ,
17
+ org .springframework .ai .vectorstore .mongodb .autoconfigure .MongoDBAtlasVectorStoreAutoConfiguration .class ,
18
+ OpenAiAudioSpeechAutoConfiguration .class ,
19
+ MistralAiAutoConfiguration .class
20
+ })
21
+ class ModelRunnerApplication {
22
+
23
+ public static void main (String [] args ) {
24
+ SpringApplication app = new SpringApplication (ModelRunnerApplication .class );
25
+ app .setAdditionalProfiles ("dockermodelrunner" );
26
+ app .run (args );
27
+ }
28
+
29
+ }
Original file line number Diff line number Diff line change
1
+ package com .baeldung .springai .docker .modelrunner ;
2
+
3
+ import org .springframework .ai .chat .client .ChatClient ;
4
+ import org .springframework .web .bind .annotation .GetMapping ;
5
+ import org .springframework .web .bind .annotation .RequestParam ;
6
+ import org .springframework .web .bind .annotation .RestController ;
7
+
8
+ @ RestController
9
+ class ModelRunnerController {
10
+
11
+ private final ChatClient chatClient ;
12
+
13
+ public ModelRunnerController (ChatClient .Builder chatClientBuilder ) {
14
+ this .chatClient = chatClientBuilder .build ();
15
+ }
16
+
17
+ @ GetMapping ("/chat" )
18
+ public String chat (@ RequestParam ("message" ) String message ) {
19
+ return this .chatClient .prompt ()
20
+ .user (message )
21
+ .call ()
22
+ .content ();
23
+ }
24
+
25
+ }
Original file line number Diff line number Diff line change
1
+ spring.ai.openai.api-key =${OPENAI_API_KEY}
2
+ spring.ai.openai.base-url =http://localhost:12434/engines
3
+ spring.ai.openai.chat.options.model =ai/gemma3
4
+
5
+ spring.docker.compose.enabled =false
You can’t perform that action at this time.
0 commit comments