Skip to content

Commit 5c44949

Browse files
committed
refactor: ignore FunctionCallingOptions
Signed-off-by: jiangsier-xyz <[email protected]>
1 parent 7aec508 commit 5c44949

File tree

3 files changed

+14
-44
lines changed

3 files changed

+14
-44
lines changed

models/spring-ai-qwen/src/main/java/org/springframework/ai/qwen/QwenChatModel.java

-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.springframework.ai.chat.prompt.ChatOptions;
1414
import org.springframework.ai.chat.prompt.Prompt;
1515
import org.springframework.ai.model.ModelOptionsUtils;
16-
import org.springframework.ai.model.function.FunctionCallingOptions;
1716
import org.springframework.ai.model.tool.DefaultToolExecutionEligibilityPredicate;
1817
import org.springframework.ai.model.tool.ToolCallingChatOptions;
1918
import org.springframework.ai.model.tool.ToolCallingManager;
@@ -185,10 +184,6 @@ private Prompt buildRequestPrompt(Prompt prompt) {
185184
runtimeOptions = ModelOptionsUtils.copyToTarget(toolCallingChatOptions, ToolCallingChatOptions.class,
186185
QwenChatOptions.class);
187186
}
188-
else if (prompt.getOptions() instanceof FunctionCallingOptions functionCallingOptions) {
189-
runtimeOptions = ModelOptionsUtils.copyToTarget(functionCallingOptions, FunctionCallingOptions.class,
190-
QwenChatOptions.class);
191-
}
192187
else {
193188
runtimeOptions = ModelOptionsUtils.copyToTarget(prompt.getOptions(), ChatOptions.class,
194189
QwenChatOptions.class);

models/spring-ai-qwen/src/main/java/org/springframework/ai/qwen/QwenChatOptions.java

+13-38
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.springframework.ai.qwen;
22

33
import com.alibaba.dashscope.common.ResponseFormat;
4-
import org.springframework.ai.model.function.FunctionCallback;
54
import org.springframework.ai.model.tool.ToolCallingChatOptions;
65
import org.springframework.ai.tool.ToolCallback;
76
import org.springframework.lang.Nullable;
@@ -101,7 +100,7 @@ public class QwenChatOptions implements ToolCallingChatOptions {
101100
* Collection of {@link ToolCallback}s to be used for tool calling in the chat
102101
* completion requests.
103102
*/
104-
private List<FunctionCallback> toolCallbacks;
103+
private List<ToolCallback> toolCallbacks;
105104

106105
/**
107106
* Collection of tool names to be resolved at runtime and used for tool calling in the
@@ -155,7 +154,7 @@ public class QwenChatOptions implements ToolCallingChatOptions {
155154
* not specified, it will be judged based on the model name when called, but these
156155
* judgments may not keep up with the latest situation.
157156
*/
158-
private Boolean multimodalModel;
157+
private Boolean isMultimodalModel;
159158

160159
/**
161160
* Whether the model supports incremental output in the streaming output mode. This
@@ -190,7 +189,7 @@ private QwenChatOptions(Builder builder) {
190189
this.searchOptions = builder.searchOptions;
191190
this.translationOptions = builder.translationOptions;
192191
this.vlHighResolutionImages = builder.vlHighResolutionImages;
193-
this.multimodalModel = builder.multimodalModel;
192+
this.isMultimodalModel = builder.multimodalModel;
194193
this.custom = builder.custom;
195194
}
196195

@@ -269,29 +268,17 @@ public Double getTopP() {
269268
}
270269

271270
@Override
272-
public List<FunctionCallback> getToolCallbacks() {
271+
public List<ToolCallback> getToolCallbacks() {
273272
return this.toolCallbacks;
274273
}
275274

276275
@Override
277-
public void setToolCallbacks(List<FunctionCallback> toolCallbacks) {
276+
public void setToolCallbacks(List<ToolCallback> toolCallbacks) {
278277
Assert.notNull(toolCallbacks, "toolCallbacks cannot be null");
279278
Assert.noNullElements(toolCallbacks, "toolCallbacks cannot contain null elements");
280279
this.toolCallbacks = toolCallbacks;
281280
}
282281

283-
@Override
284-
@Deprecated
285-
public List<FunctionCallback> getFunctionCallbacks() {
286-
return this.getToolCallbacks();
287-
}
288-
289-
@Override
290-
@Deprecated
291-
public void setFunctionCallbacks(List<FunctionCallback> functionCallbacks) {
292-
this.setToolCallbacks(functionCallbacks);
293-
}
294-
295282
@Override
296283
public Set<String> getToolNames() {
297284
return this.toolNames;
@@ -305,21 +292,9 @@ public void setToolNames(Set<String> toolNames) {
305292
this.toolNames = toolNames;
306293
}
307294

308-
@Override
309-
@Deprecated
310-
public Set<String> getFunctions() {
311-
return this.getToolNames();
312-
}
313-
314-
@Override
315-
@Deprecated
316-
public void setFunctions(Set<String> functionNames) {
317-
this.setToolNames(functionNames);
318-
}
319-
320295
@Override
321296
@Nullable
322-
public Boolean isInternalToolExecutionEnabled() {
297+
public Boolean getInternalToolExecutionEnabled() {
323298
return internalToolExecutionEnabled;
324299
}
325300

@@ -391,12 +366,12 @@ public void setVlHighResolutionImages(Boolean vlHighResolutionImages) {
391366
this.vlHighResolutionImages = vlHighResolutionImages;
392367
}
393368

394-
public Boolean isMultimodalModel() {
395-
return multimodalModel;
369+
public Boolean getIsMultimodalModel() {
370+
return isMultimodalModel;
396371
}
397372

398-
public void setMultimodalModel(Boolean multimodalModel) {
399-
this.multimodalModel = multimodalModel;
373+
public void setIsMultimodalModel(Boolean isMultimodalModel) {
374+
this.isMultimodalModel = isMultimodalModel;
400375
}
401376

402377
public Boolean getSupportIncrementalOutput() {
@@ -454,7 +429,7 @@ public static class Builder {
454429

455430
private Integer topK;
456431

457-
private List<FunctionCallback> toolCallbacks = new ArrayList<>();
432+
private List<ToolCallback> toolCallbacks = new ArrayList<>();
458433

459434
private Set<String> toolNames = new HashSet<>();
460435

@@ -528,7 +503,7 @@ public Builder topK(Integer topK) {
528503
return this;
529504
}
530505

531-
public Builder toolCallbacks(List<FunctionCallback> toolCallbacks) {
506+
public Builder toolCallbacks(List<ToolCallback> toolCallbacks) {
532507
this.toolCallbacks = toolCallbacks;
533508
return this;
534509
}
@@ -614,7 +589,7 @@ public Builder overrideWith(QwenChatOptions fromOptions) {
614589
this.translationOptions(getOrDefault(fromOptions.getTranslationOptions(), this.translationOptions));
615590
this.vlHighResolutionImages(
616591
getOrDefault(fromOptions.getVlHighResolutionImages(), this.vlHighResolutionImages));
617-
this.isMultimodalModel(getOrDefault(fromOptions.isMultimodalModel(), this.multimodalModel));
592+
this.isMultimodalModel(getOrDefault(fromOptions.getIsMultimodalModel(), this.multimodalModel));
618593
this.supportIncrementalOutput(
619594
getOrDefault(fromOptions.getSupportIncrementalOutput(), this.supportIncrementalOutput));
620595
this.custom(copyIfNotNull(getOrDefault(fromOptions.getCustom(), this.custom)));

models/spring-ai-qwen/src/main/java/org/springframework/ai/qwen/api/QwenApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ boolean isMultimodalModel(Prompt prompt) {
266266
}
267267

268268
String modelName = options.getModel();
269-
Boolean isMultimodalModel = ((QwenChatOptions) options).isMultimodalModel();
269+
Boolean isMultimodalModel = ((QwenChatOptions) options).getIsMultimodalModel();
270270
isMultimodalModel = getOrDefault(isMultimodalModel, isMultimodalModelName(modelName));
271271

272272
return Boolean.TRUE.equals(isMultimodalModel);

0 commit comments

Comments
 (0)