Package org.springframework.ai.minimax
Class MiniMaxChatModel
java.lang.Object
org.springframework.ai.chat.model.AbstractToolCallSupport
org.springframework.ai.minimax.MiniMaxChatModel
- All Implemented Interfaces:
ChatModel
,StreamingChatModel
,Model<Prompt,
,ChatResponse> StreamingModel<Prompt,
ChatResponse>
public class MiniMaxChatModel
extends AbstractToolCallSupport
implements ChatModel, StreamingChatModel
- Since:
- 1.0.0 M1
- Author:
- Geng Rong
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal org.springframework.retry.support.RetryTemplate
The retry template used to retry the MiniMax API calls.Fields inherited from class org.springframework.ai.chat.model.AbstractToolCallSupport
functionCallbackContext, functionCallbackRegister, IS_RUNTIME_CALL
-
Constructor Summary
ConstructorDescriptionMiniMaxChatModel
(MiniMaxApi miniMaxApi) Creates an instance of the MiniMaxChatModel.MiniMaxChatModel
(MiniMaxApi miniMaxApi, MiniMaxChatOptions options) Initializes an instance of the MiniMaxChatModel.MiniMaxChatModel
(MiniMaxApi miniMaxApi, MiniMaxChatOptions options, FunctionCallbackContext functionCallbackContext, List<FunctionCallback> toolFunctionCallbacks, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) Initializes a new instance of the MiniMaxChatModel.MiniMaxChatModel
(MiniMaxApi miniMaxApi, MiniMaxChatOptions options, FunctionCallbackContext functionCallbackContext, org.springframework.retry.support.RetryTemplate retryTemplate) Initializes a new instance of the MiniMaxChatModel. -
Method Summary
Modifier and TypeMethodDescriptionExecutes a method call to the AI model.protected boolean
isToolCall
(Generation generation, Set<String> toolCallFinishReasons) The MimiMax web search function tool type is 'web_search', so we need to filter out the tool calls whose type is not 'function'void
setObservationConvention
(ChatModelObservationConvention observationConvention) reactor.core.publisher.Flux<ChatResponse>
Executes a method call to the AI model.Methods inherited from class org.springframework.ai.chat.model.AbstractToolCallSupport
buildToolCallConversation, executeFunctions, getFunctionCallbackRegister, handleToolCalls, isProxyToolCalls, isToolCall, resolveFunctionCallbacks, runtimeFunctionCallbackConfigurations
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.chat.model.StreamingChatModel
stream, stream
-
Field Details
-
retryTemplate
public final org.springframework.retry.support.RetryTemplate retryTemplateThe retry template used to retry the MiniMax API calls.
-
-
Constructor Details
-
MiniMaxChatModel
Creates an instance of the MiniMaxChatModel.- Parameters:
miniMaxApi
- The MiniMaxApi instance to be used for interacting with the MiniMax Chat API.- Throws:
IllegalArgumentException
- if MiniMaxApi is null
-
MiniMaxChatModel
Initializes an instance of the MiniMaxChatModel.- Parameters:
miniMaxApi
- The MiniMaxApi instance to be used for interacting with the MiniMax Chat API.options
- The MiniMaxChatOptions to configure the chat model.
-
MiniMaxChatModel
public MiniMaxChatModel(MiniMaxApi miniMaxApi, MiniMaxChatOptions options, FunctionCallbackContext functionCallbackContext, org.springframework.retry.support.RetryTemplate retryTemplate) Initializes a new instance of the MiniMaxChatModel.- Parameters:
miniMaxApi
- The MiniMaxApi instance to be used for interacting with the MiniMax Chat API.options
- The MiniMaxChatOptions to configure the chat model.functionCallbackContext
- The function callback context.retryTemplate
- The retry template.
-
MiniMaxChatModel
public MiniMaxChatModel(MiniMaxApi miniMaxApi, MiniMaxChatOptions options, FunctionCallbackContext functionCallbackContext, List<FunctionCallback> toolFunctionCallbacks, org.springframework.retry.support.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) Initializes a new instance of the MiniMaxChatModel.- Parameters:
miniMaxApi
- The MiniMaxApi instance to be used for interacting with the MiniMax Chat API.options
- The MiniMaxChatOptions to configure the chat model.functionCallbackContext
- The function callback context.toolFunctionCallbacks
- The tool function callbacks.retryTemplate
- The retry template.observationRegistry
- The ObservationRegistry used for instrumentation.
-
-
Method Details
-
call
Description copied from interface:Model
Executes a method call to the AI model. -
getDefaultOptions
- Specified by:
getDefaultOptions
in interfaceChatModel
-
stream
Description copied from interface:StreamingModel
Executes a method call to the AI model.- Specified by:
stream
in interfaceChatModel
- Specified by:
stream
in interfaceStreamingChatModel
- Specified by:
stream
in interfaceStreamingModel<Prompt,
ChatResponse> - Parameters:
prompt
- the request object to be sent to the AI model- Returns:
- the streaming response from the AI model
-
isToolCall
The MimiMax web search function tool type is 'web_search', so we need to filter out the tool calls whose type is not 'function'- Overrides:
isToolCall
in classAbstractToolCallSupport
- Parameters:
generation
- the generation to checktoolCallFinishReasons
- the tool call finish reasons- Returns:
- true if the generation is a tool call
-
setObservationConvention
-