Class DeepSeekChatModel
- All Implemented Interfaces:
ChatModel,StreamingChatModel,Model<Prompt,,ChatResponse> StreamingModel<Prompt,ChatResponse>
ChatModel and StreamingChatModel implementation for DeepSeek
backed by DeepSeekApi.
The assistant message of each choice is built from ordered MessageParts: the
reasoning_content becomes a ReasoningPart without a payload, the
content a TextPart, and each tool call a ToolCallPart. That is
also the only order DeepSeek produces them in: an assistant message has one field per
kind of content and no list of content blocks, and reasoning that is interleaved with
tool calls spans several assistant messages, one per tool call round.
An assistant message is replayed as one message: the text parts are joined into the
content, the reasoning parts into reasoning_content, unless another
provider signed some of them, and the tool call parts become the tool_calls.
DeepSeek documents that in thinking mode every assistant message of a request with
tools must carry its reasoning_content, so the reasoning survives between the
rounds. The last message of a prompt is sent as a chat prefix completion when it
carries true under PREFIX_METADATA_KEY.
- Author:
- Geng Rong, Thomas Vitale, Sebastien Deleuze, guan xu, Dimitar Proynov
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringMessage metadata key that marks an assistant message as the prefix the model completes, see the DeepSeek chat prefix completion feature.final org.springframework.core.retry.RetryTemplateThe retry template used to retry the DeepSeek API calls. -
Constructor Summary
ConstructorsConstructorDescriptionDeepSeekChatModel(DeepSeekApi deepSeekApi, DeepSeekChatOptions options, ToolCallingManager toolCallingManager, org.springframework.core.retry.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry) -
Method Summary
Modifier and TypeMethodDescriptionstatic DeepSeekChatModel.Builderbuilder()Executes a method call to the AI model.Gets the chat options for this model.voidsetObservationConvention(ChatModelObservationConvention observationConvention) Use the provided convention for reporting observation datareactor.core.publisher.Flux<ChatResponse>Executes a method call to the AI model.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.ai.chat.model.ChatModel
call, call, getDefaultOptionsMethods inherited from interface org.springframework.ai.chat.model.StreamingChatModel
stream, stream
-
Field Details
-
PREFIX_METADATA_KEY
Message metadata key that marks an assistant message as the prefix the model completes, see the DeepSeek chat prefix completion feature. AnAssistantMessagewhose metadata holdstrueunder this key is sent withprefix: truewhen it is the last message of the prompt, and as a plain turn otherwise.- Since:
- 2.1.0
- See Also:
-
retryTemplate
public final org.springframework.core.retry.RetryTemplate retryTemplateThe retry template used to retry the DeepSeek API calls.
-
-
Constructor Details
-
DeepSeekChatModel
public DeepSeekChatModel(DeepSeekApi deepSeekApi, DeepSeekChatOptions options, ToolCallingManager toolCallingManager, org.springframework.core.retry.RetryTemplate retryTemplate, io.micrometer.observation.ObservationRegistry observationRegistry)
-
-
Method Details
-
call
Description copied from interface:ModelExecutes a method call to the AI model. -
stream
Description copied from interface:StreamingModelExecutes a method call to the AI model.- Specified by:
streamin interfaceChatModel- Specified by:
streamin interfaceStreamingChatModel- Specified by:
streamin interfaceStreamingModel<Prompt,ChatResponse> - Parameters:
prompt- the request object to be sent to the AI model- Returns:
- the streaming response from the AI model
-
getOptions
Description copied from interface:ChatModelGets the chat options for this model.- Specified by:
getOptionsin interfaceChatModel- Returns:
- the chat options
- Since:
- 2.0.0
-
toString
-
setObservationConvention
Use the provided convention for reporting observation data- Parameters:
observationConvention- The provided convention
-
builder
-