pub struct ChatApplyParams { /* private fields */ }Expand description
A request to render: messages, optional tools, and how to constrain output.
messages_json and tools_json are OpenAI-shaped JSON. They are passed as
text rather than typed structs so this crate need not take a JSON dependency
or track upstream’s message schema, which grows most releases.
Implementations§
Source§impl ChatApplyParams
impl ChatApplyParams
Sourcepub fn new(messages_json: impl Into<String>) -> Self
pub fn new(messages_json: impl Into<String>) -> Self
Start from an OpenAI-shaped messages JSON array.
Sourcepub fn with_tools(self, tools_json: impl Into<String>) -> Self
pub fn with_tools(self, tools_json: impl Into<String>) -> Self
Supply an OpenAI-shaped tools JSON array.
Sourcepub fn with_grammar(self, grammar: impl Into<String>) -> Self
pub fn with_grammar(self, grammar: impl Into<String>) -> Self
Constrain output with a GBNF grammar directly.
Sourcepub fn with_json_schema(self, schema_json: impl Into<String>) -> Self
pub fn with_json_schema(self, schema_json: impl Into<String>) -> Self
Constrain output with a JSON Schema. llama.cpp converts it to GBNF.
Sourcepub fn with_template_kwargs(self, kwargs_json: impl Into<String>) -> Self
pub fn with_template_kwargs(self, kwargs_json: impl Into<String>) -> Self
Extra Jinja variables, as a JSON object.
Sourcepub fn with_tool_choice(self, choice: ToolChoice) -> Self
pub fn with_tool_choice(self, choice: ToolChoice) -> Self
Set what the model may do with the tools. Defaults to
ToolChoice::Auto.
Sourcepub fn with_reasoning_format(self, format: ReasoningFormat) -> Self
pub fn with_reasoning_format(self, format: ReasoningFormat) -> Self
Set how reasoning is handled. Defaults to ReasoningFormat::Auto.
Sourcepub fn with_add_generation_prompt(self, add: bool) -> Self
pub fn with_add_generation_prompt(self, add: bool) -> Self
Append the assistant generation prompt. Defaults to true; set false
to render a transcript rather than a request.
Sourcepub fn with_enable_thinking(self, enable: bool) -> Self
pub fn with_enable_thinking(self, enable: bool) -> Self
Let the model think before answering, on templates that support it.
Defaults to true.
Sourcepub fn with_parallel_tool_calls(self, parallel: bool) -> Self
pub fn with_parallel_tool_calls(self, parallel: bool) -> Self
Allow several tool calls in one turn. Defaults to false.
Sourcepub fn with_use_jinja(self, use_jinja: bool) -> Self
pub fn with_use_jinja(self, use_jinja: bool) -> Self
Render with the Jinja engine. Defaults to true; false selects the
legacy llama_chat_apply_template path, which ignores tools.
Sourcepub fn with_add_bos_eos(self, add_bos: bool, add_eos: bool) -> Self
pub fn with_add_bos_eos(self, add_bos: bool, add_eos: bool) -> Self
Prepend BOS / append EOS to the rendered prompt. Both default to
false, since tokenization usually adds BOS itself.
Trait Implementations§
Source§impl Clone for ChatApplyParams
impl Clone for ChatApplyParams
Source§fn clone(&self) -> ChatApplyParams
fn clone(&self) -> ChatApplyParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more