mirror of
https://github.com/deepseek-ai/deepseek-recipe.git
synced 2026-10-26 16:55:05 +00:00
Co-authored-by: xinchengxx <xinchengxx@deepseek.com> Co-authored-by: zhu-he <hezhu@deepseek.com>
16 KiB
16 KiB
Changelog
This file lists the changes to the Rust crates and to the deepseek-recipe
Python distribution. All crates and the distribution share one version. The
format follows Keep a Changelog, and
versions follow Semantic Versioning: before 1.0, a new
minor version can contain incompatible changes.
Unreleased
0.2.0 - 2026-10-20
This release changes the public API of every crate and of the Python package. Migrating from 0.1 lists the renamed and removed items.
Added
- Model versions. Conversion resolves a
ModelVersion(V4 or V4.1) from the request'smodelname throughConversionOptions::model_versions_by_name. The defaults areDeepSeek-V4-ProandDeepSeek-V4.1-Flash;with_model_aliasandwith_model_versions_by_nameregister other names.ConversationRequest::model_versionreports the result. V4 does not accept images (ModelVersion::supports_image): conversion replaces each image of a V4 request with the text[Unsupported Image]. Python:ConversionOptions.model_versions_by_name,with_model_alias, andwith_model_versions_by_name. - Sampling values by model version. Conversion resolves
temperatureandtop_pinstead of passing them through.temperatureis 1.0 in thinking mode and otherwise the requested value or 1.0.top_pfollowsModelVersion::resolve_top_p: in thinking mode, V4.1 raises it to at least 0.95, and V4 uses 0.95 with tools and 1.0 without; outside thinking mode, V4.1 uses 1.0 and V4 uses the requested value. - Log probabilities. Conversion maps Chat Completions
logprobsandtop_logprobs, and Responsestop_logprobs, intoInferenceOptions. The caller supplies backend values inInferenceChunk::Tokens, and the Chat Completions and Responses adapters report them.OutputChunk::ContentandOutputChunk::Reasoningcarry them aslogprobs. - Reasoning token counts.
CompletionUsage::reasoning_tokens: in thinking mode, a stream processor with an attached tokenizer counts the tokens of the reasoning content, and Chat Completions and Responses report them. - Structured output.
ResponseFormat::JsonSchemaandResponseFormat::Regex. Conversion validates a Chat Completionsresponse_formator Responsestext.formatof typejson_schema, which 0.1 accepted and ignored, and rendering writes the schema into the prompt. A Chat Completionsregexresponse format passes through asResponseFormat::Regex. - Explicit special tokens. The new
deepseek-recipe-macroscrate provides theprompt!macro, anddeepseek-recipe-coreprovidesPrompt.RenderedPrompt::special_rangesrecords the byte ranges of the explicit special tokens, andPromptTokenizerencodes only those ranges as special tokens. Apart from the grounding tokens in assistant content and reasoning content, a special-token spelling in message text encodes as plain text. - Prefix continuation. A final Chat Completions assistant message with
prefix: truecontinues that message instead of starting a new assistant turn.InputMessage::Assistantgainsprefix. Python: theprefixargument ofAssistantMessage. - Deferred tool loading and tool search. V4.1 supports deferred tool
loading in Messages and client-executed
tool_searchin Responses.ToolDefinitiongainsdefer_loading, andInputMessage::Systemgainstools. Python:ToolDefinition.defer_loadingandSystemMessage.tools. - System images. V4.1 accepts images in system messages.
InputMessage::Systemgainsimage_sources. Python: theimage_sourcesandimage_tokenarguments ofSystemMessage. - Image destination filtering.
DestinationFilterandReqwestImageFetcher::with_destination_filtercheck the URL host, every resolved address, and every redirect target. A rejected destination fails withImageError::DestinationRejected. Python:ReqwestImageFetcher.with_destination_filter. - Request settings in responses. Conversion preserves usage inclusion,
tool output types, namespace mappings, and echoed request settings in
ConversationRequest::response_options.ProtocolRequest::chunk_generatorapplies them when constructing a generator. Python: the request types'chunk_generatormethods. - Max tokens upper bounds.
ConversionOptions::thinking_max_tokens_upper_boundandConversionOptions::non_thinking_max_tokens_upper_bound, set by the matchingwith_*methods: the largest acceptedmax_tokensin thinking mode and outside it, both defaulting toDEFAULT_MAX_TOKENS_UPPER_BOUND(393216).resolve_max_tokens_upper_boundselects the bound of a request's thinking mode; Messages lowers a larger value to it, Chat Completions and Responses reject it. Python: the matching keywords, properties, andwith_*methods ofConversionOptions. - Output constraints.
InferenceOptions::output_constraintholds theOutputConstraintthat constrained decoding would enforce. A request with tools and a tool choice other thannonegetsToolCalls, which lists the tools and whether a call is required. Otherwise a JSON object or JSON Schema response format getsJson, and a regex response format getsRegex.OutputConstraint::kindreturnsjson,regex,tool_call, ortool_call_required, andOutputConstraint::schemareturns the constraint text. Whether the backend applies the constraint is the caller's decision. Python:OutputConstraintandInferenceOptions.output_constraint. ConversationRequest::resolve_max_tokens: after the caller encodes the prompt, it resolves themax_tokensto send from the prompt's token count and a caller-supplied context limit. A request withoutmax_tokensgets 8192 outside thinking mode, 65536 in thinking mode, and 131072 in thinking mode withmaxeffort (DEFAULT_NON_THINKING_MAX_TOKENS,DEFAULT_THINKING_MAX_TOKENS,DEFAULT_MAX_EFFORT_MAX_TOKENS), lowered to the context left after the prompt. When the prompt and the requestedmax_tokenstogether exceed the context limit, it returns a400 Bad Requesterror whose message matches the DeepSeek API:This model's maximum context length is {context_limit} tokens. .... Python:ConversationRequest.resolve_max_tokens.SpecialTokennames the grounding tokens (Ref,RefEnd,Box,BoxEnd,Point,PointEnd,Polygon,PolygonEnd), so aSpecialTokensmapping can respell them;SpecialTokensMaphas a field for each. The encoding crate lists them as the assistant special tokens that rendering inserts from assistant content and reasoning content. Python: the matchingSpecialTokenmembers andSpecialTokenskeywords.deepseek_recipe_core::multimodal::UNSUPPORTED_IMAGE_ERROR_MESSAGE: the text of the unsupported-image error.- Shared request types
RequestReasoningEffortandThinkingType. - Request schema types:
MessagesMetadatavalidatesmetadata,MessagesTooldistinguishes client tools from server tools (MessagesServerTool), andResponsesWebSearchTooldeserializes and validates thesearch_context_sizeanduser_locationof aweb_searchorweb_search_2025_08_26tool. - Python: the
ModelVersionenum, aResponsesEchoconstructor with read-only getters, theresponse_schemaandresponse_regexarguments ofConversation, theimage_tokenargument ofUserMessageandToolMessage, an optionaltool_call_idofToolMessage, and themodelproperty of the protocol requests, readable beforeconvert.
Changed
- Conversion rejects a request whose
modelis not a key ofConversionOptions::model_versions_by_name. Register any additional name, such asdeepseek-flash, withwith_model_alias. - Validation error messages and the order of the checks match the DeepSeek API.
- A Responses reasoning item without text adds nothing to the conversation;
encrypted_contentis accepted and ignored. - V4.1 preserves Messages
systemand Responsesdevelopermessages as system messages. - Messages document blocks require a
sourceobject. Their unsupported-content text includes the media type. - A complete Chat Completions response numbers its
tool_callswithindex(ChatCompletionIndexedToolCall), as the streamed deltas do. StreamProcessor::with_tokenizertakes aStreamTokenizer. Besidesdecode_ids, the trait has the optional methodsid_to_token, for log probabilities,count_tokens, for reasoning token counts, andis_special_token, for marker matching.PromptTokenizerencodes the plain text regions of a prompt as one batch throughTokenizer::encode_batch_fastinstead of one region at a time. Thetokenizerscrate encodes the batch in parallel unless itsTOKENIZERS_PARALLELISMenvironment variable disables parallelism.- Conversion rejects a request that mixes strict and non-strict tools, and a
request that sets a response format together with strict tools, unless the
tool choice is
none. - With token input, the stream processor decodes each special token as its own
piece. Output parsing matches the thinking end token (
</think>by default) and the DSML token within DSML tags only against decoded special tokens; the same text spelled with plain tokens is content. The log probabilities of these special tokens are reported with the marker rather than with the surrounding content. Text chunks still match markers by spelling. - The Python distribution takes its version from the Cargo package, so
deepseek_recipe.__version__matches the installed distribution.
Removed
InferenceChunk::Token. Send oneInferenceChunk::Tokenschunk instead.- The
argumentsfield ofOutputChunk::ToolCall, nowToolCallNamed. Arguments arrive inToolCallArgumentsDeltachunks. - The
utilmodules ofdeepseek-recipeanddeepseek-recipe-core, and the publicstate_machinemodule andStreamDecodertype ofdeepseek-recipe. Output parsing and token decoding are internal toStreamProcessor;ParsingOptionsandThinkingInitialStageremain public instream. - The per-protocol reasoning effort and thinking type enums, replaced by
RequestReasoningEffortandThinkingType. MessagesContentBlock::ToolReference. A Messages request can contain a tool reference only intool_result.contentortool_addition.tool.- Public constructors of
ChatCompletionChunkGeneratorandResponsesChunkGenerator. UseProtocolRequest::chunk_generatorwith a converted request. Python: use the request type'schunk_generatormethod. ChatCompletionRequest::include_usage,ChatCompletionChunkGenerator::with_include_usage,ResponsesRequest::custom_tool_names, andResponsesChunkGenerator::with_custom_tool_names, including their Python equivalents.InferenceOptions::thinking_budget_tokensandInferenceOptions::disable_parallel_tool_use. Conversion accepts and ignores Messagesthinking.budget_tokensanddisable_parallel_tool_useand Chat Completionsparallel_tool_calls, as the DeepSeek API does. Python: thethinking_budget_tokensanddisable_parallel_tool_useproperties ofInferenceOptions.- Python:
InferenceChunk.token()andInferenceChunk.token_id.
Migrating from 0.1
Rust
| 0.1 | 0.2 |
|---|---|
ConversationRequest::new(conversation) |
ConversationRequest::new(conversation, model_version) |
ConversationRequest::model |
ConversationRequest::model_version; the model name stays on the protocol request |
ChatCompletionChunkGenerator::new(...), ResponsesChunkGenerator::new(...) |
ChatCompletionRequest::chunk_generator(&converted, id, model), ResponsesRequest::chunk_generator(&converted, id, model) |
ConversionError::into_response |
ConversionError::into_error_response |
StreamProcessor::process |
StreamProcessor::into_protocol_stream |
TokenizerDecoder |
StreamTokenizer |
InferenceChunk::Text { content, content_tokens } |
InferenceChunk::Text { content, token_count } |
InferenceChunk::Token { token_id } |
InferenceChunk::Tokens { token_ids: vec![token_id], logprobs: None } |
OutputChunk::Start { usage } |
OutputChunk::Start { prompt_usage } |
OutputChunk::Raw { content } |
OutputChunk::Content { content, logprobs } |
OutputChunk::Reasoning { content } |
OutputChunk::Reasoning { content, logprobs } |
OutputChunk::ToolCall { tool_name, arguments } |
OutputChunk::ToolCallNamed { tool_name } |
OutputChunk::ToolArgumentsDelta { content } |
OutputChunk::ToolCallArgumentsDelta { arguments } |
OutputChunk::Finish { reason, usage, .. } |
OutputChunk::Finish { finish_reason, completion_usage, .. } |
ParsingOptions::reasoning_initial_stage: Option<ReasoningStage> |
ParsingOptions::thinking_initial_stage: Option<ThinkingInitialStage> |
ParsingOptions::tool_call_initial_stage |
ParsingOptions::starts_in_tool_calls |
ReasoningStage::start_from_reasoning |
ThinkingInitialStage::starts_in_reasoning |
ReasoningContentBehavior::Ignore |
ReasoningContentBehavior::FillEmpty |
WebSearchBehavior::Ignore |
WebSearchBehavior::Drop |
util::append_delta::AppendDelta |
response::Accumulate |
util::json_formatter |
deepseek_recipe_core::json |
ImageTokenSpec::calc_token_len |
ImageTokenSpec::calc_token_count |
ImageTokenSpec::max_n_token |
ImageTokenSpec::max_token_count |
MessagesReasoningEffort, ChatCompletionReasoningEffort, ResponsesReasoningEffort |
RequestReasoningEffort |
MessagesThinkingType, ChatCompletionThinkingType |
ThinkingType |
MessagesTextOrTextBlocks, MessagesTextBlock |
MessagesSystemContent, MessagesSystemBlock |
MessagesTool { name, description, input_schema, kind } |
MessagesTool::Client { name, description, input_schema, defer_loading }, MessagesTool::Server(MessagesServerTool) |
MessagesResponseContent, MessagesDelta, MessagesStopInfo |
MessagesResponseContentBlock, MessagesContentBlockDelta, MessagesMessageDelta |
ChatCompletionToolChoiceMode, ChatCompletionNamedToolChoice |
variants of ChatCompletionToolChoiceOption |
ResponsesToolChoiceMode |
variants of ResponsesToolChoice |
Python
| 0.1 | 0.2 |
|---|---|
ConversationRequest(conversation) |
ConversationRequest(conversation, model_version) |
ConversationRequest.model |
ConversationRequest.model_version; read the name from the protocol request's model before convert |
ChatCompletionChunkGenerator(...), ResponsesChunkGenerator(...) |
ChatCompletionRequest.chunk_generator(converted, id, model), ResponsesRequest.chunk_generator(converted, id, model) |
*Response.append(chunk) |
*Response.accumulate(chunk) |
*Response.chunk_event_type(chunk) |
*Response.sse_event_name(chunk) |
*Response.done_message() |
*Response.sse_done_data() |
InferenceChunk.text(text, content_tokens) |
InferenceChunk.text(content, token_count) |
InferenceChunk.content_tokens |
InferenceChunk.token_count |
InferenceChunk.token(token_id) |
InferenceChunk.tokens([token_id]) |
ReasoningStage |
ThinkingInitialStage |
ReasoningStage.start_from_reasoning |
ThinkingInitialStage.starts_in_reasoning |
model version strings such as "DeepSeek-V4-Pro" |
ModelVersion.DeepseekV4Pro, ModelVersion.DeepseekV41Flash |
0.1.0 - 2026-09-10
Initial release: conversion of Messages, Chat Completions, and Responses
requests into a shared conversation, DeepSeek V4 and V4.1 prompt rendering,
image fetching and preprocessing, streaming output parsing into protocol
responses, and the deepseek-recipe Python distribution.