ContentBuilder

Struct ContentBuilder 

Source
pub struct ContentBuilder {
    pub contents: Vec<Content>,
    /* private fields */
}
Expand description

Builder for content generation requests

Fields§

§contents: Vec<Content>

Implementations§

Source§

impl ContentBuilder

Source

pub fn with_system_prompt(self, text: impl Into<String>) -> Self

Add a system prompt to the request

Source

pub fn with_system_instruction(self, text: impl Into<String>) -> Self

Set the system instruction directly (matching the API format in the curl example)

Source

pub fn with_user_message(self, text: impl Into<String>) -> Self

Add a user message to the request

Source

pub fn with_model_message(self, text: impl Into<String>) -> Self

Add a model message to the request

Source

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

Add a inline data (blob data) to the request

Source

pub fn with_function_response( self, name: impl Into<String>, response: Value, ) -> Self

Add a function response to the request using a JSON value

Source

pub fn with_function_response_str( self, name: impl Into<String>, response: impl Into<String>, ) -> Result<Self, Error>

Add a function response to the request using a JSON string

Source

pub fn with_message(self, message: Message) -> Self

Add a message to the request

Source

pub fn with_messages(self, messages: impl IntoIterator<Item = Message>) -> Self

Add multiple messages to the request

Source

pub fn with_generation_config(self, config: GenerationConfig) -> Self

Set the generation config for the request

Source

pub fn with_temperature(self, temperature: f32) -> Self

Set the temperature for the request

Source

pub fn with_top_p(self, top_p: f32) -> Self

Set the top-p value for the request

Source

pub fn with_top_k(self, top_k: i32) -> Self

Set the top-k value for the request

Source

pub fn with_max_output_tokens(self, max_output_tokens: i32) -> Self

Set the maximum output tokens for the request

Source

pub fn with_candidate_count(self, candidate_count: i32) -> Self

Set the candidate count for the request

Source

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

Set the stop sequences for the request

Source

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

Set the response mime type for the request

Source

pub fn with_response_schema(self, schema: Value) -> Self

Set the response schema for structured output

Source

pub fn with_tool(self, tool: Tool) -> Self

Add a tool to the request

Source

pub fn with_function(self, function: FunctionDeclaration) -> Self

Add a function declaration as a tool

Source

pub fn with_function_calling_mode(self, mode: FunctionCallingMode) -> Self

Set the function calling mode for the request

Source

pub fn with_thinking_config(self, thinking_config: ThinkingConfig) -> Self

Set the thinking configuration for the request (Gemini 2.5 series only)

Source

pub fn with_thinking_budget(self, budget: i32) -> Self

Set the thinking budget for the request (Gemini 2.5 series only)

Source

pub fn with_dynamic_thinking(self) -> Self

Enable dynamic thinking (model decides the budget) (Gemini 2.5 series only)

Source

pub fn with_thoughts_included(self, include: bool) -> Self

Include thought summaries in the response (Gemini 2.5 series only)

Source

pub fn build(self) -> GenerateContentRequest

Source

pub async fn execute(self) -> Result<GenerationResponse>

Execute the request

Source

pub async fn execute_stream( self, ) -> Result<Pin<Box<dyn Stream<Item = Result<GenerationResponse>> + Send>>>

Execute the request with streaming

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,