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
add MiniMax model client #628
Conversation
Thanks, it has taken a long time for me to get to this but I am reviewing now. Thanks for such a comprehensive PR! |
@mxsl-gr I have sent you an email as I am not able to get an API key on the minimax web site. I enter my phone number to get a verification code, but the code never comes. |
/** | ||
* Accessible for testing. | ||
*/ | ||
MiniMaxApi.ChatCompletionRequest createRequest(Prompt prompt, boolean stream) { |
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.
In this method, if the model supports media, it needs to be added. I guess the model does support media which is why the fromMediaData
method is implemented. Perhaps it just needs to be called here?
* @see MiniMaxApi | ||
*/ | ||
public class MiniMaxChatClient extends | ||
AbstractFunctionCallSupport<MiniMaxApi.ChatCompletionMessage, MiniMaxApi.ChatCompletionRequest, ResponseEntity<MiniMaxApi.ChatCompletion>> |
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.
The abstract base class AbstractFunctionCallSupport
has the method doChatCompletionStream
that was not implemented. I'm not sure how you got this code to compile, perhaps there is another commit with that method and some other code as well. In the meantime, I've added
@Override
protected Flux<ResponseEntity<MiniMaxApi.ChatCompletion>> doChatCompletionStream(
MiniMaxApi.ChatCompletionRequest request) {
throw new RuntimeException("Streaming Function calling is not supported");
}
* | ||
* <pre>{@code List.of("text1", "text2", "text3") or List.of(List.of(1, 2, 3), List.of(3, 4, 5))} </pre> | ||
*/ | ||
public <T> ResponseEntity<EmbeddingList> embeddings(EmbeddingRequest embeddingRequest) { |
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 believe the <T>
needs to be removed.
/** | ||
* Specifying a particular function forces the model to call that function. | ||
*/ | ||
public static Object FUNCTION(String functionName) { |
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.
why is the method name in all capital letters?
/** | ||
* @author Geng Rong | ||
*/ | ||
public class MiniMaxApiException extends RuntimeException { |
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.
The other ChatClient implementations do not throw dedicated exceptions, but either IllegalArgument or just a general RuntimeException. I think in the place where this exception is being thrown we can replace it with one of those two options.
Follow the https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-minimax/src/main/java/org/springframework/ai/minimax/api/MiniMaxApi.java[MiniMaxApi.java]'s JavaDoc for further information. | ||
|
||
==== MiniMaxApi Samples | ||
* The link:https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-minimax/src/test/java/org/springframework/ai/minimax/api/MiniMaxApiIT.java[MiniMaxApiIT.java] test provides some general examples how to use the lightweight library. |
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.
added a link to MiniMaxApiToolFunctionCallIT
I've merged the PR in 6b67401 Please review the comments above that were not address in the merge. Much thanks again |
@markpollack Regarding the inability to receive verification codes from MiniMax or other model providers, it may be that they are only integrated with SMS providers in mainland China, and phone numbers from other countries or regions cannot receive the messages. In my email reply, I have provided the test API keys for MiniMax, Moonshot, and DeepSeek. |
Hi, this PR is add
MiniMax
model client and has passed unit testing.I can provide my api_key if needed for testing
the PR content:
MiniMax
is a popular LLM in China Mainland recently, the link: MiniMaxFor some reasons, products from OpenAI and others can't be directly used in Chinese Mainland.
However ZhiPuAI, Moonshot, MiniMax, BaiChuanAI are referred to as the
Four Dragons
of China's LLM.If they can supported, it will further aid spring-ai to promotion in Chinese Mainland.
If necessary, I can take care of subsequent maintenance since I'm currently using them.
The
Moonshot
PR is #596The
ZhiPuAI
PR is #623I'll also provide PR for BaiChuan later.