Skip to content

Commit db1f3ea

Browse files
committed
doc fixes
1 parent 2b2cacc commit db1f3ea

File tree

3 files changed

+140
-136
lines changed

3 files changed

+140
-136
lines changed

README.md

Lines changed: 2 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -10,147 +10,14 @@ For further information go to our [Spring AI reference documentation](https://do
1010

1111
## Breaking changes
1212

13-
On our march to release 1.0.0 M1 we have made several breaking changes. Apologies, it is for the best!
14-
15-
**(22.05.2024)**
16-
17-
A major change was made that took the 'old' `ChatClient` and moved the functionality into `ChatModel`. The 'new' `ChatClient` now takes an instance of `ChatModel`. This was done do support a fluent API for creating and executing prompts in a style similar to other client classes in the Spring ecosystem, such as `RestClient`, `WebClient`, and `JdbcClient`. Refer to the [JavaDoc](https://docs.spring.io/spring-ai/docs/1.0.0-SNAPSHOT/api/) for more information on the Fluent API, proper reference documentation is coming shortly.
18-
19-
We renamed the 'old' `ModelClient` to `Model` and renamed implementing classes, for example `ImageClient` was renamed to `ImageModel`. The `Model` implementation represent the portability layer that converts between the Spring AI API and the underlying AI Model API.
20-
21-
### Adapting to the changes
22-
23-
NOTE: The `ChatClient` class is now in the package `org.springframework.ai.chat.client`
24-
25-
#### Approach 1
26-
27-
Now, instead of getting an Autoconfigured `ChatClient` instance, you will get a `ChatModel` instance. The `call` method signatures after renaming remain the same.
28-
To adapt your code should refactor you code to change use of the type `ChatClient` to `ChatModel`
29-
Here is an example of existing code before the change
30-
31-
```java
32-
@RestController
33-
public class OldSimpleAiController {
34-
35-
private final ChatClient chatClient;
36-
37-
public OldSimpleAiController(ChatClient chatClient) {
38-
this.chatClient = chatClient;
39-
}
40-
41-
@GetMapping("/ai/simple")
42-
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
43-
return Map.of("generation", chatClient.call(message));
44-
}
45-
}
46-
```
47-
48-
Now after the changes this will be
49-
50-
```java
51-
@RestController
52-
public class SimpleAiController {
53-
54-
private final ChatModel chatModel;
55-
56-
public SimpleAiController(ChatModel chatModel) {
57-
this.chatModel = chatModel;
58-
}
59-
60-
@GetMapping("/ai/simple")
61-
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
62-
return Map.of("generation", chatModel.call(message));
63-
}
64-
}
65-
```
66-
67-
NOTE: The renaming also applies to the classes
68-
* `StreamingChatClient` -> `StreamingChatModel`
69-
* `EmbeddingClient` -> `EmbeddingModel`
70-
* `ImageClient` -> `ImageModel`
71-
* `SpeechClient` -> `SpeechModel`
72-
* and similar for other `<XYZ>Client` classes
73-
74-
#### Approach 2
75-
76-
In this approach you will use the new fluent API available on the 'new' `ChatClient`
77-
78-
Here is an example of existing code before the change
79-
80-
```java
81-
@RestController
82-
class OldSimpleAiController {
83-
84-
ChatClient chatClient;
85-
86-
OldSimpleAiController(ChatClient chatClient) {
87-
this.chatClient = chatClient;
88-
}
89-
90-
@GetMapping("/ai/simple")
91-
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
92-
return Map.of(
93-
"generation",
94-
chatClient.call(message)
95-
);
96-
}
97-
}
98-
```
99-
100-
Now after the changes this will be
101-
102-
```java
103-
@RestController
104-
class SimpleAiController {
105-
106-
private final ChatClient chatClient;
107-
108-
SimpleAiController(ChatClient.Builder builder) {
109-
this.builder = builder.build();
110-
}
111-
112-
@GetMapping("/ai/simple")
113-
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
114-
return Map.of(
115-
"generation",
116-
chatClient.prompt().user(message).call().content()
117-
);
118-
}
119-
}
120-
```
121-
122-
123-
NOTE: The `ChatModel` instance is made available to you through autoconfiguration.
124-
125-
#### Approach 3
126-
127-
There is a tag in the GitHub repository called [v1.0.0-SNAPSHOT-before-chatclient-changes](https://github.com/spring-projects/spring-ai/tree/v1.0.0-SNAPSHOT-before-chatclient-changes) that you can checkout and do a local build to avoid updating any of your code until you are ready to migrate your code base.
128-
129-
```bash
130-
git checkout tags/v1.0.0-SNAPSHOT-before-chatclient-changes
131-
132-
./mvnw clean install -DskipTests
133-
```
134-
135-
136-
**(15.05.2024)**
137-
138-
Renamed POM artifact names:
139-
- spring-ai-qdrant -> spring-ai-qdrant-store
140-
- spring-ai-cassandra -> spring-ai-cassandra-store
141-
- spring-ai-pinecone -> spring-ai-pinecone-store
142-
- spring-ai-redis -> spring-ai-redis-store
143-
- spring-ai-qdrant -> spring-ai-qdrant-store
144-
- spring-ai-gemfire -> spring-ai-gemfire-store
145-
- spring-ai-azure-vector-store-spring-boot-starter -> spring-ai-azure-store-spring-boot-starter
146-
- spring-ai-redis-spring-boot-starter -> spring-ai-redis-store-spring-boot-starter
13+
* Refer to the [upgrade notes](https://docs.spring.io/spring-ai/reference/upgrade-notes.html) to see how to upgrade to 1.0.0.M1 or higher.
14714

14815
## Project Links
14916

15017
* [Documentation](https://docs.spring.io/spring-ai/reference/)
15118
* [Issues](https://github.com/spring-projects/spring-ai/issues)
15219
* [Discussions](https://github.com/spring-projects/spring-ai/discussions) - Go here if you have a question, suggestion, or feedback!
153-
* [Upgrade from 0.7.1-SNAPSHOT](https://docs.spring.io/spring-ai/reference/upgrade-notes.html)
20+
15421

15522
## Educational Resources
15623

spring-ai-docs/src/main/antora/modules/ROOT/pages/api/chatclient.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ After specifying the `stream` method on `ChatClient`, there are a few options fo
181181
== Using Defaults
182182

183183
Creating a ChatClient with default system text in an `@Configuration` class simplifies runtime code.
184-
By setting defaults, you only need to specify user text when calling `ChatClient, eliminating the need to set system text for each request in your runtime codeala path.
184+
By setting defaults, you only need to specify user text when calling `ChatClient`, eliminating the need to set system text for each request in your runtime code path.
185185

186186

187187

spring-ai-docs/src/main/antora/modules/ROOT/pages/upgrade-notes.adoc

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,143 @@
11
[[upgrade-notes]]
22
= Upgrading Notes
33

4+
== Upgrading to 1.0.0.M1
5+
6+
On our march to release 1.0.0 M1 we have made several breaking changes. Apologies, it is for the best!
7+
8+
=== ChatClient changes
9+
10+
A major change was made that took the 'old' `ChatClient` and moved the functionality into `ChatModel`. The 'new' `ChatClient` now takes an instance of `ChatModel`. This was done do support a fluent API for creating and executing prompts in a style similar to other client classes in the Spring ecosystem, such as `RestClient`, `WebClient`, and `JdbcClient`. Refer to the [JavaDoc](https://docs.spring.io/spring-ai/docs/1.0.0-SNAPSHOT/api/) for more information on the Fluent API, proper reference documentation is coming shortly.
11+
12+
We renamed the 'old' `ModelClient` to `Model` and renamed implementing classes, for example `ImageClient` was renamed to `ImageModel`. The `Model` implementation represent the portability layer that converts between the Spring AI API and the underlying AI Model API.
13+
14+
### Adapting to the changes
15+
16+
NOTE: The `ChatClient` class is now in the package `org.springframework.ai.chat.client`
17+
18+
#### Approach 1
19+
20+
Now, instead of getting an Autoconfigured `ChatClient` instance, you will get a `ChatModel` instance. The `call` method signatures after renaming remain the same.
21+
To adapt your code should refactor you code to change use of the type `ChatClient` to `ChatModel`
22+
Here is an example of existing code before the change
23+
24+
```java
25+
@RestController
26+
public class OldSimpleAiController {
27+
28+
private final ChatClient chatClient;
29+
30+
public OldSimpleAiController(ChatClient chatClient) {
31+
this.chatClient = chatClient;
32+
}
33+
34+
@GetMapping("/ai/simple")
35+
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
36+
return Map.of("generation", chatClient.call(message));
37+
}
38+
}
39+
```
40+
41+
Now after the changes this will be
42+
43+
```java
44+
@RestController
45+
public class SimpleAiController {
46+
47+
private final ChatModel chatModel;
48+
49+
public SimpleAiController(ChatModel chatModel) {
50+
this.chatModel = chatModel;
51+
}
52+
53+
@GetMapping("/ai/simple")
54+
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
55+
return Map.of("generation", chatModel.call(message));
56+
}
57+
}
58+
```
59+
60+
NOTE: The renaming also applies to the classes
61+
* `StreamingChatClient` -> `StreamingChatModel`
62+
* `EmbeddingClient` -> `EmbeddingModel`
63+
* `ImageClient` -> `ImageModel`
64+
* `SpeechClient` -> `SpeechModel`
65+
* and similar for other `<XYZ>Client` classes
66+
67+
#### Approach 2
68+
69+
In this approach you will use the new fluent API available on the 'new' `ChatClient`
70+
71+
Here is an example of existing code before the change
72+
73+
```java
74+
@RestController
75+
class OldSimpleAiController {
76+
77+
ChatClient chatClient;
78+
79+
OldSimpleAiController(ChatClient chatClient) {
80+
this.chatClient = chatClient;
81+
}
82+
83+
@GetMapping("/ai/simple")
84+
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
85+
return Map.of(
86+
"generation",
87+
chatClient.call(message)
88+
);
89+
}
90+
}
91+
```
92+
93+
Now after the changes this will be
94+
95+
```java
96+
@RestController
97+
class SimpleAiController {
98+
99+
private final ChatClient chatClient;
100+
101+
SimpleAiController(ChatClient.Builder builder) {
102+
this.builder = builder.build();
103+
}
104+
105+
@GetMapping("/ai/simple")
106+
Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
107+
return Map.of(
108+
"generation",
109+
chatClient.prompt().user(message).call().content()
110+
);
111+
}
112+
}
113+
```
114+
115+
116+
NOTE: The `ChatModel` instance is made available to you through autoconfiguration.
117+
118+
#### Approach 3
119+
120+
There is a tag in the GitHub repository called [v1.0.0-SNAPSHOT-before-chatclient-changes](https://github.com/spring-projects/spring-ai/tree/v1.0.0-SNAPSHOT-before-chatclient-changes) that you can checkout and do a local build to avoid updating any of your code until you are ready to migrate your code base.
121+
122+
```bash
123+
git checkout tags/v1.0.0-SNAPSHOT-before-chatclient-changes
124+
125+
./mvnw clean install -DskipTests
126+
```
127+
128+
129+
=== Artifact name changes
130+
131+
Renamed POM artifact names:
132+
- spring-ai-qdrant -> spring-ai-qdrant-store
133+
- spring-ai-cassandra -> spring-ai-cassandra-store
134+
- spring-ai-pinecone -> spring-ai-pinecone-store
135+
- spring-ai-redis -> spring-ai-redis-store
136+
- spring-ai-qdrant -> spring-ai-qdrant-store
137+
- spring-ai-gemfire -> spring-ai-gemfire-store
138+
- spring-ai-azure-vector-store-spring-boot-starter -> spring-ai-azure-store-spring-boot-starter
139+
- spring-ai-redis-spring-boot-starter -> spring-ai-redis-store-spring-boot-starter
140+
4141
== Upgrading to 0.8.1
5142

6143
Former `spring-ai-vertex-ai` has been renamed to `spring-ai-vertex-ai-palm2` and `spring-ai-vertex-ai-spring-boot-starter` has been renamed to `spring-ai-vertex-ai-palm2-spring-boot-starter`.

0 commit comments

Comments
 (0)