pub enum ResponseFormat {
JsonSchema {
schema: Value,
strict: bool,
},
Grammar {
gbnf: String,
},
}Expand description
Constrains the output format of a LlmCompletionPort::chat_stream call.
Pass Some(&format) when the caller requires structured output (e.g. for
plan generation in the orchestrator). Adapters that target llama-server
translate these variants as follows:
| Variant | Wire field |
|---|---|
JsonSchema | response_format: { type: "json_schema", json_schema: { schema, strict } } |
Grammar | grammar: "<gbnf string>" (llama.cpp extension) |
Normal agent-loop calls pass None, which leaves the model free-form.
Variants§
JsonSchema
Constrain the output to a JSON object matching the given JSON Schema.
strict: true instructs the model to refuse outputs that do not
conform to the schema. Use strict: false for best-effort guidance
when strict validation would be overly rigid.
Fields
Grammar
Constrain output using a GBNF grammar string (llama.cpp extension).
GBNF grammars are more expressive than JSON Schema for some use cases (e.g. constraining enum-only outputs without a schema round-trip).
Trait Implementations§
Source§impl Clone for ResponseFormat
impl Clone for ResponseFormat
Source§fn clone(&self) -> ResponseFormat
fn clone(&self) -> ResponseFormat
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more