pub struct RequestBuilder<'a> { /* private fields */ }Expand description
Represents a builder for constructing a request to the Anthropic API.
The RequestBuilder allows setting various parameters for the request, such as the model,
messages, max tokens, temperature, and system prompt. The send method sends the request
to the API and returns the response.
Implementations§
Source§impl<'a> RequestBuilder<'a>
impl<'a> RequestBuilder<'a>
pub fn new(client: &'a (dyn LlmClientTrait + Send + Sync)) -> Self
pub fn add_tool(self, tool: Tool) -> Self
Sourcepub fn user_message(self, message: &str) -> Self
pub fn user_message(self, message: &str) -> Self
Adds a user message to the conversation.
Sourcepub fn max_tokens(self, max_tokens: u32) -> Self
pub fn max_tokens(self, max_tokens: u32) -> Self
Sets the maximum number of tokens to generate in the response.
Sourcepub fn temperature(self, temperature: f64) -> Self
pub fn temperature(self, temperature: f64) -> Self
Sets the temperature value to control the randomness of the generated response.
Sourcepub fn system_prompt(self, system_prompt: &str) -> Self
pub fn system_prompt(self, system_prompt: &str) -> Self
Sets the system prompt to provide context and instructions to the model.
pub fn render_request(&self) -> Result<Value, ApiError>
pub async fn send(self) -> Result<ResponseMessage, ApiError>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for RequestBuilder<'a>
impl<'a> !UnwindSafe for RequestBuilder<'a>
impl<'a> Freeze for RequestBuilder<'a>
impl<'a> Send for RequestBuilder<'a>
impl<'a> Sync for RequestBuilder<'a>
impl<'a> Unpin for RequestBuilder<'a>
impl<'a> UnsafeUnpin for RequestBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more