pub struct LlmRequest {
pub model: String,
pub messages: Messages,
pub system: Option<String>,
pub max_tokens: Option<u32>,
pub tools: Vec<ToolSpec>,
pub effort: Option<String>,
pub schema: Option<Value>,
}Expand description
A model call.
Fields§
§model: StringWhich model to ask, in the provider’s naming.
messages: MessagesThe conversation so far, oldest turn first.
system: Option<String>System prompt, kept apart from messages because providers disagree
about where it goes — a system turn, a top-level field, or folded
into the first user turn. The client places it at its edge.
max_tokens: Option<u32>Cap on generated tokens. A reply that hits it stops with
StopReason::MaxTokens, which steps treat as an error, not an answer.
tools: Vec<ToolSpec>Tools the model may call, as JSON Schema definitions.
effort: Option<String>Reasoning depth, in the provider’s terms (low … max).
schema: Option<Value>JSON Schema the reply must satisfy.
A request, not a guarantee: endpoints that support constrained
decoding enforce it, and the rest are asked in the prompt and may
still answer with prose. Whoever consumes the reply validates it —
see crate::schema::Schema for the graph-level contract, which is
a different thing: this constrains one model call, that one
constrains an edge.
Implementations§
Source§impl LlmRequest
impl LlmRequest
Sourcepub fn new(model: impl Into<String>, messages: Messages) -> Self
pub fn new(model: impl Into<String>, messages: Messages) -> Self
A request with only the essentials: a model and a conversation.
Everything else is opt-in through the with_* builders — and because
unset options are skipped when the request is serialized, they are
also absent from the journal key (Effect::cache_key). Growing this
struct therefore never moves the keys of requests that predate the
new knob.
Sourcepub fn with_system(self, system: impl Into<String>) -> Self
pub fn with_system(self, system: impl Into<String>) -> Self
Set the system prompt.
Stated here once, placed by the provider client wherever this endpoint wants it — as its own turn, or prepended to the first user turn when the endpoint refuses a system role.
Sourcepub fn with_max_tokens(self, n: u32) -> Self
pub fn with_max_tokens(self, n: u32) -> Self
Cap the reply at n generated tokens.
A budget, not a target: a reply that runs into it is a cut-off
thought, and LlmResponse::reject_non_answers turns it into an
error rather than letting the fragment flow downstream as an answer.
Sourcepub fn with_tools(self, tools: Vec<ToolSpec>) -> Self
pub fn with_tools(self, tools: Vec<ToolSpec>) -> Self
Offer the model these tools, replacing any previous set.
Offering is all this does. When the model wants one, the reply stops
with StopReason::ToolUse and it is the step’s job to perform the
calls — typically as Effect::Tool — and ask the model to continue
with the results appended to the conversation.
Sourcepub fn with_effort(self, effort: impl Into<String>) -> Self
pub fn with_effort(self, effort: impl Into<String>) -> Self
Ask for this much reasoning, in the provider’s vocabulary
(low … max).
Passed through verbatim (reasoning_effort on OpenAI-shaped
endpoints); endpoints without the concept ignore the unknown field.
Like every other knob it is part of the journal key — the same
question at a different effort is a different request, so a replay
never serves the cheaper answer.
Sourcepub fn with_schema(self, schema: Value) -> Self
pub fn with_schema(self, schema: Value) -> Self
Ask for a reply shaped like schema.
Sourcepub fn into_effect(self) -> Effect
pub fn into_effect(self) -> Effect
Wrap as the effect a step awaits.
Trait Implementations§
Source§impl Clone for LlmRequest
impl Clone for LlmRequest
Source§fn clone(&self) -> LlmRequest
fn clone(&self) -> LlmRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more