-
Notifications
You must be signed in to change notification settings - Fork 843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: MiniMax model function call #1116
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
361 changes: 194 additions & 167 deletions
361
models/spring-ai-minimax/src/main/java/org/springframework/ai/minimax/MiniMaxChatModel.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,10 @@ | |
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration; | ||
import org.springframework.ai.chat.model.ChatResponse; | ||
import org.springframework.ai.chat.model.Generation; | ||
import org.springframework.ai.chat.messages.AssistantMessage; | ||
import org.springframework.ai.chat.messages.UserMessage; | ||
import org.springframework.ai.chat.model.ChatResponse; | ||
import org.springframework.ai.chat.model.Generation; | ||
import org.springframework.ai.chat.prompt.Prompt; | ||
import org.springframework.ai.minimax.MiniMaxChatModel; | ||
import org.springframework.ai.minimax.MiniMaxChatOptions; | ||
|
@@ -53,11 +53,12 @@ public class FunctionCallbackInPromptIT { | |
|
||
@Test | ||
void functionCallTest() { | ||
contextRunner.withPropertyValues("spring.ai.minimax.chat.options.model=abab6-chat").run(context -> { | ||
contextRunner.withPropertyValues("spring.ai.minimax.chat.options.model=abab6.5s-chat").run(context -> { | ||
|
||
MiniMaxChatModel chatModel = context.getBean(MiniMaxChatModel.class); | ||
|
||
UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); | ||
UserMessage userMessage = new UserMessage( | ||
"What's the weather like in San Francisco, Tokyo, and Paris? Return the temperature in Celsius."); | ||
|
||
var promptOptions = MiniMaxChatOptions.builder() | ||
.withFunctionCallbacks(List.of(FunctionCallbackWrapper.builder(new MockWeatherService()) | ||
|
@@ -78,11 +79,12 @@ void functionCallTest() { | |
@Test | ||
void streamingFunctionCallTest() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test fails with
|
||
|
||
contextRunner.withPropertyValues("spring.ai.minimax.chat.options.model=abab6-chat").run(context -> { | ||
contextRunner.withPropertyValues("spring.ai.minimax.chat.options.model=abab6.5s-chat").run(context -> { | ||
|
||
MiniMaxChatModel chatModel = context.getBean(MiniMaxChatModel.class); | ||
|
||
UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); | ||
UserMessage userMessage = new UserMessage( | ||
"What's the weather like in San Francisco, Tokyo, and Paris? Return the temperature in Celsius."); | ||
|
||
var promptOptions = MiniMaxChatOptions.builder() | ||
.withFunctionCallbacks(List.of(FunctionCallbackWrapper.builder(new MockWeatherService()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,10 @@ | |
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.ai.autoconfigure.retry.SpringAiRetryAutoConfiguration; | ||
import org.springframework.ai.chat.model.ChatResponse; | ||
import org.springframework.ai.chat.model.Generation; | ||
import org.springframework.ai.chat.messages.AssistantMessage; | ||
import org.springframework.ai.chat.messages.UserMessage; | ||
import org.springframework.ai.chat.model.ChatResponse; | ||
import org.springframework.ai.chat.model.Generation; | ||
import org.springframework.ai.chat.prompt.Prompt; | ||
import org.springframework.ai.minimax.MiniMaxChatModel; | ||
import org.springframework.ai.minimax.MiniMaxChatOptions; | ||
|
@@ -57,14 +57,16 @@ class FunctionCallbackWithPlainFunctionBeanIT { | |
RestClientAutoConfiguration.class, MiniMaxAutoConfiguration.class)) | ||
.withUserConfiguration(Config.class); | ||
|
||
// FIXME: multiple function calls may stop prematurely due to model performance | ||
@Test | ||
void functionCallTest() { | ||
contextRunner.withPropertyValues("spring.ai.minimax.chat.options.model=abab6-chat").run(context -> { | ||
contextRunner.withPropertyValues("spring.ai.minimax.chat.options.model=abab6.5s-chat").run(context -> { | ||
|
||
MiniMaxChatModel chatModel = context.getBean(MiniMaxChatModel.class); | ||
|
||
// Test weatherFunction | ||
UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); | ||
UserMessage userMessage = new UserMessage( | ||
"What's the weather like in San Francisco, Tokyo, and Paris? Return the temperature in Celsius."); | ||
|
||
ChatResponse response = chatModel.call(new Prompt(List.of(userMessage), | ||
MiniMaxChatOptions.builder().withFunction("weatherFunction").build())); | ||
|
@@ -86,12 +88,13 @@ void functionCallTest() { | |
|
||
@Test | ||
void functionCallWithPortableFunctionCallingOptions() { | ||
contextRunner.withPropertyValues("spring.ai.minimax.chat.options.model=abab6-chat").run(context -> { | ||
contextRunner.withPropertyValues("spring.ai.minimax.chat.options.model=abab6.5s-chat").run(context -> { | ||
|
||
MiniMaxChatModel chatModel = context.getBean(MiniMaxChatModel.class); | ||
|
||
// Test weatherFunction | ||
UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); | ||
UserMessage userMessage = new UserMessage( | ||
"What's the weather like in San Francisco, Tokyo, and Paris? Return the temperature in Celsius."); | ||
|
||
PortableFunctionCallingOptions functionOptions = FunctionCallingOptions.builder() | ||
.withFunction("weatherFunction") | ||
|
@@ -103,14 +106,16 @@ void functionCallWithPortableFunctionCallingOptions() { | |
}); | ||
} | ||
|
||
// FIXME: multiple function calls may stop prematurely due to model performance | ||
@Test | ||
void streamFunctionCallTest() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test fails with
|
||
contextRunner.withPropertyValues("spring.ai.minimax.chat.options.model=abab6-chat").run(context -> { | ||
contextRunner.withPropertyValues("spring.ai.minimax.chat.options.model=abab6.5s-chat").run(context -> { | ||
|
||
MiniMaxChatModel chatModel = context.getBean(MiniMaxChatModel.class); | ||
|
||
// Test weatherFunction | ||
UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?"); | ||
UserMessage userMessage = new UserMessage( | ||
"What's the weather like in San Francisco, Tokyo, and Paris? Return the temperature in Celsius."); | ||
|
||
Flux<ChatResponse> response = chatModel.stream(new Prompt(List.of(userMessage), | ||
MiniMaxChatOptions.builder().withFunction("weatherFunction").build())); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to update to use
as the answer said "30 Celcius"
also, it seems sometimes i get an answer back in chinese. Is there a way for it to be force to reply in english?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as far as i know, there's can't to set the talk language through options, but we can add an explicit request in the message, like
please answer in english