pub struct TaskBuilder {
pub id: u128,
pub model: Option<String>,
pub max_tokens: Option<u64>,
pub payload: Option<Value>,
pub system: Option<String>,
pub history: Option<Vec<Interaction>>,
pub schema: Option<Value>,
pub prompt: Option<String>,
}Expand description
Builds a chat task; only the prompt is required at build time.
Prefer Self::new for a generated ID: derived Default uses ID zero.
Fields§
§id: u128Correlation ID; must be unique among outstanding memory-queue tasks.
model: Option<String>Explicit model, overriding the producer/executor default when present.
max_tokens: Option<u64>Requested output limit; the API executor casts this to u32 unchecked.
payload: Option<Value>Caller metadata carried through the response, not sent to the model.
system: Option<String>System instruction, separate from conversation history.
history: Option<Vec<Interaction>>Earlier turns; the API executor ignores system entries here.
schema: Option<Value>JSON schema requested as strict structured output; not locally validated.
prompt: Option<String>Current prompt; None fails to build, but an empty string is accepted.
Implementations§
Source§impl TaskBuilder
impl TaskBuilder
Sourcepub fn with_model<M: ToString>(self, model: M) -> Self
pub fn with_model<M: ToString>(self, model: M) -> Self
Overrides the default model; NATS uses this model to select a subject.
Sourcepub fn with_max_tokens(self, max_tokens: u64) -> Self
pub fn with_max_tokens(self, max_tokens: u64) -> Self
Sets the requested output limit; keep it within u32 for the API executor.
Sourcepub fn with_payload<P: Serialize>(self, payload: P) -> Self
pub fn with_payload<P: Serialize>(self, payload: P) -> Self
Attaches caller metadata without including it in the model request.
§Panics
Panics if the payload cannot be serialized as JSON.
Sourcepub fn with_system<S: ToString>(self, system: S) -> Self
pub fn with_system<S: ToString>(self, system: S) -> Self
Sets the system instruction prepended to the model’s messages.
Sourcepub fn with_history<H: IntoIterator<Item = Interaction>>(
self,
history: H,
) -> Self
pub fn with_history<H: IntoIterator<Item = Interaction>>( self, history: H, ) -> Self
Replaces earlier turns; the API executor discards system entries.
Sourcepub fn with_schema<S: Serialize>(self, schema: S) -> Self
pub fn with_schema<S: Serialize>(self, schema: S) -> Self
Sets a strict output schema without validating schema correctness.
§Panics
Panics if the schema cannot be serialized as JSON.
Sourcepub fn with_prompt<P: ToString>(self, prompt: P) -> Self
pub fn with_prompt<P: ToString>(self, prompt: P) -> Self
Sets the current prompt, sent as a user message by the API executor.
Sourcepub fn build_chat(self) -> Result<Task>
pub fn build_chat(self) -> Result<Task>
Builds a chat task, returning an error if no prompt was supplied.
Model availability, token limits, and schema correctness are not checked.
Trait Implementations§
Source§impl Clone for TaskBuilder
impl Clone for TaskBuilder
Source§fn clone(&self) -> TaskBuilder
fn clone(&self) -> TaskBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more