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
ChatModel and StreamingChatModel implementation for MiniMax backed by MiniMaxApi.
Since:
1.0.0 M1
Author:
Geng Rong
See Also:
  • Field Details

    • retryTemplate

      public final org.springframework.retry.support.RetryTemplate retryTemplate
      The retry template used to retry the MiniMax API calls.
  • Constructor Details

    • MiniMaxChatModel

      public MiniMaxChatModel(MiniMaxApi miniMaxApi)
      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

      public MiniMaxChatModel(MiniMaxApi miniMaxApi, MiniMaxChatOptions options)
      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

      public ChatResponse call(Prompt prompt)
      Description copied from interface: Model
      Executes a method call to the AI model.
      Specified by:
      call in interface ChatModel
      Specified by:
      call in interface Model<Prompt,ChatResponse>
      Parameters:
      prompt - the request object to be sent to the AI model
      Returns:
      the response from the AI model
    • getDefaultOptions

      public ChatOptions getDefaultOptions()
      Specified by:
      getDefaultOptions in interface ChatModel
    • stream

      public reactor.core.publisher.Flux<ChatResponse> stream(Prompt prompt)
      Description copied from interface: StreamingModel
      Executes a method call to the AI model.
      Specified by:
      stream in interface ChatModel
      Specified by:
      stream in interface StreamingChatModel
      Specified by:
      stream in interface StreamingModel<Prompt,ChatResponse>
      Parameters:
      prompt - the request object to be sent to the AI model
      Returns:
      the streaming response from the AI model
    • isToolCall

      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'
      Overrides:
      isToolCall in class AbstractToolCallSupport
      Parameters:
      generation - the generation to check
      toolCallFinishReasons - the tool call finish reasons
      Returns:
      true if the generation is a tool call
    • setObservationConvention

      public void setObservationConvention(ChatModelObservationConvention observationConvention)