Skip to content

Commit

Permalink
Update ChatOptions configurer
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcheng1982 committed May 9, 2024
1 parent fbeda6f commit 0e093a7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ public boolean supports(@NotNull ChatOptions chatOptions) {
public ChatOptions configure(@NotNull ChatOptions chatOptions,
@NotNull ChatOptionsConfig config) {
var options = (DashscopeChatOptions) chatOptions;
var builder = DashscopeChatOptions.builder(options);
var updatedOptions = options.createCopy();
if (config.getStopSequence() != null) {
builder.withStops(config.getStopSequence());
updatedOptions.setStops(config.getStopSequence());
}
if (config.getFunctions() != null) {
var toolNames = new HashSet<>(config.getFunctions());
if (options.getFunctions() != null) {
toolNames.addAll(options.getFunctions());
}
builder.withFunctions(toolNames);
updatedOptions.setFunctions(toolNames);
}
return builder.build();
return updatedOptions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public ChatOptions configure(@NotNull ChatOptions chatOptions,
@NotNull ChatOptionsConfig config) {
var options = (MistralAiChatOptions) chatOptions;
var updatedOptions = new MistralAiChatOptions();
ModelOptionsUtils.merge(options, updatedOptions,
updatedOptions = ModelOptionsUtils.merge(options, updatedOptions,
MistralAiChatOptions.class);
if (config.getFunctions() != null) {
var toolNames = new HashSet<>(config.getFunctions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public ChatOptions configure(@NotNull ChatOptions chatOptions,
@NotNull ChatOptionsConfig config) {
var options = (OpenAiChatOptions) chatOptions;
var updatedOptions = new OpenAiChatOptions();
ModelOptionsUtils.merge(options, updatedOptions, OpenAiChatOptions.class);
updatedOptions = ModelOptionsUtils.merge(options, updatedOptions,
OpenAiChatOptions.class);
if (config.getStopSequence() != null) {
updatedOptions.setStop(config.getStopSequence());
}
Expand Down
2 changes: 1 addition & 1 deletion llm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<packaging>pom</packaging>

<properties>
<dashscope-client.version>1.1.1</dashscope-client.version>
<dashscope-client.version>1.1.4</dashscope-client.version>
</properties>

<dependencyManagement>
Expand Down

0 comments on commit 0e093a7

Please sign in to comment.