MessageBuilder

Struct MessageBuilder 

Source
pub struct MessageBuilder { /* private fields */ }
Expand description

Builder for creating sampling messages and requests at runtime

Implementations§

Source§

impl MessageBuilder

Source

pub fn new() -> Self

Create a new message builder with default max_tokens

Source

pub fn max_tokens(self, max_tokens: u32) -> Self

Set maximum tokens for response generation

Source

pub fn message(self, message: SamplingMessage) -> Self

Add a message to the conversation

Source

pub fn system(self, content: impl Into<String>) -> Self

Add a system message with text content

Source

pub fn user_text(self, content: impl Into<String>) -> Self

Add a user message with text content

Source

pub fn user_image( self, data: impl Into<String>, mime_type: impl Into<String>, ) -> Self

Add a user message with image content

Source

pub fn assistant_text(self, content: impl Into<String>) -> Self

Add an assistant message with text content

Source

pub fn model_preferences(self, preferences: ModelPreferences) -> Self

Set model preferences

Source

pub fn with_model_preferences<F>(self, f: F) -> Self

Create and set model preferences with builder pattern

Source

pub fn system_prompt(self, prompt: impl Into<String>) -> Self

Set system prompt

Source

pub fn include_context(self, context: impl Into<String>) -> Self

Set include context

Source

pub fn temperature(self, temperature: f64) -> Self

Set temperature for sampling (0.0-1.0)

Source

pub fn stop_sequences(self, sequences: Vec<String>) -> Self

Set stop sequences

Source

pub fn stop_sequence(self, sequence: impl Into<String>) -> Self

Add a stop sequence

Source

pub fn metadata(self, metadata: Value) -> Self

Set metadata

Source

pub fn meta(self, meta: HashMap<String, Value>) -> Self

Set meta information

Source

pub fn build_params(self) -> CreateMessageParams

Build a CreateMessageParams

Source

pub fn build_request(self) -> CreateMessageRequest

Build a complete CreateMessageRequest

Trait Implementations§

Source§

impl Default for MessageBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.