java.lang.Object
io.agentscope.core.formatter.AbstractBaseFormatter<OpenAIMessage,OpenAIResponse,OpenAIRequest>
All Implemented Interfaces:
io.agentscope.core.formatter.Formatter<OpenAIMessage,OpenAIResponse,OpenAIRequest>

public class DeepSeekFormatter extends OpenAIChatFormatter
Formatter for DeepSeek Chat models (deepseek-v4-flash, deepseek-v4-pro).

DeepSeek API has the following specific requirements:

  • System/user/assistant name fields are allowed
  • Omits strict parameter in tool definitions
  • In thinking mode, reasoning_content is preserved for segments with tool calls

Usage:


 OpenAIChatModel.builder()
     .formatter(new DeepSeekFormatter())
     .modelName("deepseek-v4-flash")
     .baseUrl("https://api.deepseek.com")
     .apiKey(apiKey)
     .build();
 
See Also:
  • Constructor Details

    • DeepSeekFormatter

      public DeepSeekFormatter()
    • DeepSeekFormatter

      public DeepSeekFormatter(boolean appendEmptyUserIfEndsWithAssistant)
      Create a DeepSeek formatter with optional empty user message appending.
      Parameters:
      appendEmptyUserIfEndsWithAssistant - if true, append an empty user message when the conversation ends with an assistant message to avoid API errors
  • Method Details

    • doFormat

      protected List<OpenAIMessage> doFormat(List<io.agentscope.core.message.Msg> msgs)
      Overrides:
      doFormat in class OpenAIChatFormatter
    • supportsStrict

      protected boolean supportsStrict()
      Description copied from class: OpenAIChatFormatter
      Returns whether this formatter's target API supports the strict parameter in tool definitions.

      Subclasses can override this method to disable strict parameter for providers that don't support it (e.g., DeepSeek).

      Overrides:
      supportsStrict in class OpenAIChatFormatter
      Returns:
      true if strict parameter is supported, false otherwise