Skip to content

Commit c8d030c

Browse files
committed
Extend chat-models and prompts samples
1 parent 375f172 commit c8d030c

File tree

87 files changed

+1108
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1108
-287
lines changed

01-chat-models/chat-models-mistral-ai/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,29 @@ You can now call the application that will use Mistral AI to generate text based
7171
This example uses [httpie](https://httpie.io) to send HTTP requests.
7272

7373
```shell
74-
http :8080/chat
74+
http :8080/chat -b
7575
```
7676

7777
Try passing your custom prompt and check the result.
7878

7979
```shell
80-
http :8080/chat question=="What is the capital of Italy?"
80+
http :8080/chat question=="What is the capital of Italy?" -b
8181
```
8282

8383
The next request is configured with a custom temperature value to obtain a more creative, yet less precise answer.
8484

8585
```shell
86-
http :8080/chat/generic-options question=="Why is a raven like a writing desk? Give a short answer."
86+
http :8080/chat/generic-options question=="Why is a raven like a writing desk? Give a short answer." -b
8787
```
8888

8989
The next request is configured with Mistral AI-specific customizations.
9090

9191
```shell
92-
http :8080/chat/provider-options question=="What can you see beyond what you can see? Give a short answer."
92+
http :8080/chat/provider-options question=="What can you see beyond what you can see? Give a short answer." -b
9393
```
9494

9595
The final request returns the model's answer as a stream.
9696

9797
```shell
98-
http --stream :8080/chat/stream question=="Why is a raven like a writing desk? Answer in 3 paragraphs."
98+
http --stream :8080/chat/stream question=="Why is a raven like a writing desk? Answer in 3 paragraphs." -b
9999
```

01-chat-models/chat-models-mistral-ai/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'java'
33
id 'org.springframework.boot'
44
id 'io.spring.dependency-management'
5+
id 'org.graalvm.buildtools.native'
56
}
67

78
group = 'com.thomasvitale'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
* Chat examples using the high-level ChatClient API.
1313
*/
1414
@RestController
15-
class ChatClientController {
15+
class ChatController {
1616

1717
private final ChatClient chatClient;
1818

19-
ChatClientController(ChatClient.Builder chatClientBuilder) {
19+
ChatController(ChatClient.Builder chatClientBuilder) {
2020
this.chatClient = chatClientBuilder.build();
2121
}
2222

01-chat-models/chat-models-mistral-ai/src/main/java/com/thomasvitale/ai/spring/ChatModelController.java renamed to 01-chat-models/chat-models-mistral-ai/src/main/java/com/thomasvitale/ai/spring/model/ChatModelController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.thomasvitale.ai.spring;
1+
package com.thomasvitale.ai.spring.model;
22

33
import org.springframework.ai.chat.model.ChatModel;
44
import org.springframework.ai.chat.prompt.ChatOptionsBuilder;

01-chat-models/chat-models-multiple-providers/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@ This example uses [httpie](https://httpie.io) to send HTTP requests.
4040
Using OpenAI:
4141

4242
```shell
43-
http :8080/chat/openai question=="What is the capital of Italy?"
43+
http :8080/chat/openai question=="What is the capital of Italy?" -b
4444
```
4545

4646
Using Mistral AI:
4747

4848
```shell
49-
http :8080/chat/mistral-ai question=="What is the capital of Italy?"
49+
http :8080/chat/mistral-ai question=="What is the capital of Italy?" -b
5050
```
5151

5252
The next request is configured with OpenAI-specific customizations.
5353

5454
```shell
55-
http :8080/chat/openai-options question=="Why is a raven like a writing desk? Give a short answer."
55+
http :8080/chat/openai-options question=="Why is a raven like a writing desk? Give a short answer." -b
5656
```
5757

5858
The next request is configured with Mistral AI-specific customizations.
5959

6060
```shell
61-
http :8080/chat/mistral-ai-options question=="Why is a raven like a writing desk? Give a short answer."
61+
http :8080/chat/mistral-ai-options question=="Why is a raven like a writing desk? Give a short answer." -b
6262
```

01-chat-models/chat-models-multiple-providers/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'java'
33
id 'org.springframework.boot'
44
id 'io.spring.dependency-management'
5+
id 'org.graalvm.buildtools.native'
56
}
67

78
group = 'com.thomasvitale'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
* Chat examples using the high-level ChatClient API.
1414
*/
1515
@RestController
16-
class ChatClientController {
16+
class ChatController {
1717

1818
private final ChatClient mistralAichatClient;
1919
private final ChatClient openAichatClient;
2020

21-
ChatClientController(MistralAiChatModel mistralAiChatModel, OpenAiChatModel openAiChatModel) {
21+
ChatController(MistralAiChatModel mistralAiChatModel, OpenAiChatModel openAiChatModel) {
2222
this.mistralAichatClient = ChatClient.builder(mistralAiChatModel).build();
2323
this.openAichatClient = ChatClient.builder(openAiChatModel).build();
2424
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.thomasvitale.ai.spring;
1+
package com.thomasvitale.ai.spring.model;
22

33
import org.springframework.ai.chat.prompt.Prompt;
44
import org.springframework.ai.mistralai.MistralAiChatModel;

01-chat-models/chat-models-ollama/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ The application relies on Ollama for providing LLMs. You can either run Ollama l
5353
### Ollama as a native application
5454

5555
First, make sure you have [Ollama](https://ollama.ai) installed on your laptop.
56-
Then, use Ollama to run the _mistral_ large language model. That's what we'll use in this example.
56+
Then, use Ollama to pull the _mistral_ large language model.
5757

5858
```shell
59-
ollama run mistral
59+
ollama pull mistral
6060
```
6161

6262
Finally, run the Spring Boot application.
@@ -79,29 +79,29 @@ You can now call the application that will use Ollama to generate text based on
7979
This example uses [httpie](https://httpie.io) to send HTTP requests.
8080

8181
```shell
82-
http :8080/chat
82+
http :8080/chat -b
8383
```
8484

8585
Try passing your custom prompt and check the result.
8686

8787
```shell
88-
http :8080/chat question=="What is the capital of Italy?"
88+
http :8080/chat question=="What is the capital of Italy?" -b
8989
```
9090

9191
The next request is configured with a custom temperature value to obtain a more creative, yet less precise answer.
9292

9393
```shell
94-
http :8080/chat/generic-options question=="Why is a raven like a writing desk? Give a short answer."
94+
http :8080/chat/generic-options question=="Why is a raven like a writing desk? Give a short answer." -b
9595
```
9696

9797
The next request is configured with Ollama-specific customizations.
9898

9999
```shell
100-
http :8080/chat/provider-options question=="What can you see beyond what you can see? Give a short answer."
100+
http :8080/chat/provider-options question=="What can you see beyond what you can see? Give a short answer." -b
101101
```
102102

103103
The final request returns the model's answer as a stream.
104104

105105
```shell
106-
http --stream :8080/chat/stream question=="Why is a raven like a writing desk? Answer in 3 paragraphs."
106+
http --stream :8080/chat/stream question=="Why is a raven like a writing desk? Answer in 3 paragraphs." -b
107107
```
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
* Chat examples using the high-level ChatClient API.
1313
*/
1414
@RestController
15-
class ChatClientController {
15+
class ChatController {
1616

1717
private final ChatClient chatClient;
1818

19-
ChatClientController(ChatClient.Builder chatClientBuilder) {
19+
ChatController(ChatClient.Builder chatClientBuilder) {
2020
this.chatClient = chatClientBuilder.build();
2121
}
2222

0 commit comments

Comments
 (0)