Skip to main content

Crate dynamo_renderer

Crate dynamo_renderer 

Source
Expand description

Prompt Formatting

Standalone, runtime-free chat-template / prompt formatting for OpenAI-compatible inference frontends. Renders HuggingFace chat_template jinja2 (via minijinja + minijinja-contrib pycompat), handles tool usage formatting and generation-prompt handling.

Consumers implement OAIChatLikeRequest for their request type (or use the ready-made impl for dynamo-protocols’ OpenAI chat request) and render with a PromptFormatter built from a HuggingFace tokenizer_config.json (ChatTemplate).

This crate is a bridge between OpenAI request types (dynamo_protocols) and the HF chat-template engine (minijinja); it does not depend on tokenizer internals. dynamo-tokenizers is re-exported for convenience.

Re-exports§

pub use dynamo_tokenizers;

Modules§

deepseek
Native (non-jinja) prompt formatters for DeepSeek model families.
inkling
Native Inkling chat renderer.

Structs§

ChatTemplate
Template for chat models including bos/eos/unk as well as the chat template.
ChatTemplateValue
Support older tool use patterns where the tool use template was separate from the default/chat template. Modern patterns use a single template with a tool_use key, e.g.
ContextMixins
NoOpFormatter

Enums§

PromptContextMixin
Selects which context-mixin behaviors a template renders with.
PromptFormatter
PromptInput
TextInput
TokenInput

Traits§

OAIChatLikeRequest
Trait that defines a request that can map to an OpenAI-like request.
OAIPromptFormatter

Functions§

deepseek_formatter_for
If the model is a DeepSeek family whose HF repo doesn’t ship a Jinja chat_template, return the native Rust formatter for it. Returns None for everything else (the caller then loads the HF tokenizer_config.json template via PromptFormatter::from_parts).
may_be_fix_tool_schema
Fix a tool schema that is missing type/properties. pub so consumers can normalize their own tools value when implementing crate::OAIChatLikeRequest::tools.
native_formatter_for
Select a native formatter for model families that do not ship a usable HF chat_template.
thinking_bool_from_args
Shared helper: extract a boolean thinking toggle from chat_template_args.