Skip to content

Commit 0ec9490

Browse files
committed
fix: api compatability
Signed-off-by: lambochen <[email protected]>
1 parent 8dd816d commit 0ec9490

File tree

7 files changed

+71
-14
lines changed

7 files changed

+71
-14
lines changed

models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/AnthropicChatModel.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,11 @@ public ChatResponse call(Prompt prompt) {
171171
// Before moving any further, build the final request Prompt,
172172
// merging runtime and default options.
173173
Prompt requestPrompt = buildRequestPrompt(prompt);
174-
return this.internalCall(requestPrompt, null, 1);
174+
return this.internalCall(requestPrompt, null);
175+
}
176+
177+
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse) {
178+
return this.internalCall(prompt, previousChatResponse, 1);
175179
}
176180

177181
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse, int attempts) {
@@ -233,7 +237,11 @@ public Flux<ChatResponse> stream(Prompt prompt) {
233237
// Before moving any further, build the final request Prompt,
234238
// merging runtime and default options.
235239
Prompt requestPrompt = buildRequestPrompt(prompt);
236-
return this.internalStream(requestPrompt, null, 1);
240+
return this.internalStream(requestPrompt, null);
241+
}
242+
243+
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse) {
244+
return this.internalStream(prompt, previousChatResponse, 1);
237245
}
238246

239247
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse, int attempts) {

models/spring-ai-azure-openai/src/main/java/org/springframework/ai/azure/openai/AzureOpenAiChatModel.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
* @author lambochen
126126
* @see ChatModel
127127
* @see com.azure.ai.openai.OpenAIClient
128+
* @see ToolCallingChatOptions
128129
* @since 1.0.0
129130
*/
130131
public class AzureOpenAiChatModel implements ChatModel {
@@ -248,7 +249,11 @@ public ChatResponse call(Prompt prompt) {
248249
// Before moving any further, build the final request Prompt,
249250
// merging runtime and default options.
250251
Prompt requestPrompt = buildRequestPrompt(prompt);
251-
return this.internalCall(requestPrompt, null, 1);
252+
return this.internalCall(requestPrompt, null);
253+
}
254+
255+
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse) {
256+
return internalCall(prompt, previousChatResponse, 1);
252257
}
253258

254259
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse, int attempts) {
@@ -295,7 +300,11 @@ public Flux<ChatResponse> stream(Prompt prompt) {
295300
// Before moving any further, build the final request Prompt,
296301
// merging runtime and default options.
297302
Prompt requestPrompt = buildRequestPrompt(prompt);
298-
return this.internalStream(requestPrompt, null, 1);
303+
return this.internalStream(requestPrompt, null);
304+
}
305+
306+
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse) {
307+
return this.internalStream(prompt, previousChatResponse, 1);
299308
}
300309

301310
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse, int attempts) {

models/spring-ai-bedrock-converse/src/main/java/org/springframework/ai/bedrock/converse/BedrockProxyChatModel.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ private static ToolCallingChatOptions from(ChatOptions options) {
214214
@Override
215215
public ChatResponse call(Prompt prompt) {
216216
Prompt requestPrompt = buildRequestPrompt(prompt);
217-
return this.internalCall(requestPrompt, null, 1);
217+
return this.internalCall(requestPrompt, null);
218+
}
219+
220+
private ChatResponse internalCall(Prompt prompt, ChatResponse perviousChatResponse) {
221+
return this.internalCall(prompt, perviousChatResponse, 1);
218222
}
219223

220224
private ChatResponse internalCall(Prompt prompt, ChatResponse perviousChatResponse, int attempts) {
@@ -644,7 +648,11 @@ private ChatResponse toChatResponse(ConverseResponse response, ChatResponse perv
644648
@Override
645649
public Flux<ChatResponse> stream(Prompt prompt) {
646650
Prompt requestPrompt = buildRequestPrompt(prompt);
647-
return this.internalStream(requestPrompt, null, 1);
651+
return this.internalStream(requestPrompt, null);
652+
}
653+
654+
private Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse perviousChatResponse) {
655+
return this.internalStream(prompt, perviousChatResponse, 1);
648656
}
649657

650658
private Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse perviousChatResponse, int attempts) {

models/spring-ai-deepseek/src/main/java/org/springframework/ai/deepseek/DeepSeekChatModel.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ public DeepSeekChatModel(DeepSeekApi deepSeekApi, DeepSeekChatOptions defaultOpt
148148
@Override
149149
public ChatResponse call(Prompt prompt) {
150150
Prompt requestPrompt = buildRequestPrompt(prompt);
151-
return this.internalCall(requestPrompt, null, 1);
151+
return this.internalCall(requestPrompt, null);
152+
}
153+
154+
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse) {
155+
return internalCall(prompt, previousChatResponse, 1);
152156
}
153157

154158
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse, int attempts) {
@@ -228,7 +232,11 @@ public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatRespons
228232
@Override
229233
public Flux<ChatResponse> stream(Prompt prompt) {
230234
Prompt requestPrompt = buildRequestPrompt(prompt);
231-
return internalStream(requestPrompt, null, 1);
235+
return internalStream(requestPrompt, null);
236+
}
237+
238+
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse) {
239+
return internalStream(prompt, previousChatResponse, 1);
232240
}
233241

234242
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse, int attempts) {

models/spring-ai-mistral-ai/src/main/java/org/springframework/ai/mistralai/MistralAiChatModel.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,11 @@ public ChatResponse call(Prompt prompt) {
179179
// Before moving any further, build the final request Prompt,
180180
// merging runtime and default options.
181181
Prompt requestPrompt = buildRequestPrompt(prompt);
182-
return this.internalCall(requestPrompt, null, 1);
182+
return this.internalCall(requestPrompt, null);
183+
}
184+
185+
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse) {
186+
return internalCall(prompt, previousChatResponse, 1);
183187
}
184188

185189
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse, int attempts) {
@@ -251,7 +255,11 @@ public Flux<ChatResponse> stream(Prompt prompt) {
251255
// Before moving any further, build the final request Prompt,
252256
// merging runtime and default options.
253257
Prompt requestPrompt = buildRequestPrompt(prompt);
254-
return this.internalStream(requestPrompt, null, 1);
258+
return this.internalStream(requestPrompt, null);
259+
}
260+
261+
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse) {
262+
return internalStream(prompt, previousChatResponse, 1);
255263
}
256264

257265
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse, int attempts) {

models/spring-ai-openai/src/main/java/org/springframework/ai/openai/OpenAiChatModel.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ public ChatResponse call(Prompt prompt) {
180180
// Before moving any further, build the final request Prompt,
181181
// merging runtime and default options.
182182
Prompt requestPrompt = buildRequestPrompt(prompt);
183-
return this.internalCall(requestPrompt, null, 1);
183+
return this.internalCall(requestPrompt, null);
184+
}
185+
186+
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse) {
187+
return internalCall(prompt, previousChatResponse, 1);
184188
}
185189

186190
public ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse, int attempts) {
@@ -266,7 +270,11 @@ public Flux<ChatResponse> stream(Prompt prompt) {
266270
// Before moving any further, build the final request Prompt,
267271
// merging runtime and default options.
268272
Prompt requestPrompt = buildRequestPrompt(prompt);
269-
return internalStream(requestPrompt, null, 1);
273+
return internalStream(requestPrompt, null);
274+
}
275+
276+
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse) {
277+
return internalStream(prompt, previousChatResponse, 1);
270278
}
271279

272280
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse, int attempts) {

models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModel.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,11 @@ private static Schema jsonToSchema(String json) {
391391
@Override
392392
public ChatResponse call(Prompt prompt) {
393393
var requestPrompt = this.buildRequestPrompt(prompt);
394-
return this.internalCall(requestPrompt, null, 1);
394+
return this.internalCall(requestPrompt, null);
395+
}
396+
397+
private ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse) {
398+
return this.internalCall(prompt, previousChatResponse, 1);
395399
}
396400

397401
private ChatResponse internalCall(Prompt prompt, ChatResponse previousChatResponse, int attempts) {
@@ -506,7 +510,11 @@ Prompt buildRequestPrompt(Prompt prompt) {
506510
@Override
507511
public Flux<ChatResponse> stream(Prompt prompt) {
508512
var requestPrompt = this.buildRequestPrompt(prompt);
509-
return this.internalStream(requestPrompt, null, 1);
513+
return this.internalStream(requestPrompt, null);
514+
}
515+
516+
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse) {
517+
return this.internalStream(prompt, previousChatResponse, 1);
510518
}
511519

512520
public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousChatResponse, int attempts) {

0 commit comments

Comments
 (0)