#[non_exhaustive]pub struct Prompt {
pub tier: ModelTier,
pub system: Option<String>,
pub messages: Vec<Turn>,
pub json_schema: Option<Value>,
pub max_tokens: u32,
}Expand description
One completion request: the tier asked for, the conversation so far, and what the caller will accept back.
#[non_exhaustive]: build one with Prompt::new and the builder
methods rather than a struct literal. What a v2 port has to carry —
tools, temperature, a stop sequence — should not be a breaking change
for every caller, the same way Message is built.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tier: ModelTier§system: Option<String>§messages: Vec<Turn>§json_schema: Option<Value>A JSON Schema (draft 2020-12) the answer must conform to. When set,
the adapter asks its provider for structured output and a
successful Completion carries the parsed value in
Completion::json.
max_tokens: u32Implementations§
Source§impl Prompt
impl Prompt
Sourcepub fn new(tier: ModelTier) -> Self
pub fn new(tier: ModelTier) -> Self
An empty prompt for tier: no system prompt, no messages, no
schema, and DEFAULT_MAX_TOKENS as the ceiling. Everything else
is a builder method.
Sourcepub fn system(self, system: impl Into<String>) -> Self
pub fn system(self, system: impl Into<String>) -> Self
The standing instruction the model answers under.
Sourcepub fn user(self, content: impl Into<String>) -> Self
pub fn user(self, content: impl Into<String>) -> Self
Appends a Turn::user — the common case, a one-message prompt.
Sourcepub fn assistant(self, content: impl Into<String>) -> Self
pub fn assistant(self, content: impl Into<String>) -> Self
Appends a Turn::assistant.
Sourcepub fn turn(self, turn: Turn) -> Self
pub fn turn(self, turn: Turn) -> Self
Appends a whole turn, for a conversation built elsewhere.
Sourcepub fn json_schema(self, schema: Value) -> Self
pub fn json_schema(self, schema: Value) -> Self
Asks for structured output conforming to schema; a successful
completion then carries the parsed value in Completion::json.
Sourcepub fn max_tokens(self, max_tokens: u32) -> Self
pub fn max_tokens(self, max_tokens: u32) -> Self
The token ceiling for the answer.