Skip to content

Commit ab63e1a

Browse files
committed
#BAEL-9291: add main class, controller and dependency
1 parent 1583397 commit ab63e1a

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

spring-ai-3/pom.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
<artifactId>spring-ai-spring-boot-testcontainers</artifactId>
7474
<scope>test</scope>
7575
</dependency>
76+
<dependency>
77+
<groupId>org.testcontainers</groupId>
78+
<artifactId>junit-jupiter</artifactId>
79+
<scope>test</scope>
80+
</dependency>
7681
<dependency>
7782
<groupId>org.testcontainers</groupId>
7883
<artifactId>chromadb</artifactId>
@@ -143,7 +148,7 @@
143148
<spring-ai-mongodb-atlas.version>1.0.0-M7</spring-ai-mongodb-atlas.version>
144149
<junit-jupiter.version>5.9.0</junit-jupiter.version>
145150
<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>
147152
<spring-ai.version>1.0.0-M6</spring-ai.version>
148153
<spring-ai-start-model-openai.version>1.0.0-M7</spring-ai-start-model-openai.version>
149154
</properties>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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

0 commit comments

Comments
 (0)