pub struct RequestBuilder { /* private fields */ }
Expand description
Provides fluent api for building the request object for chat completion
The field types, defaults and description could be found from the official doc
Here and Request just a 1:1 mapping from it
Implementations§
Source§impl RequestBuilder
impl RequestBuilder
pub fn with_config(cfg: &BuilderConfig) -> Self
pub fn get_config(&self) -> BuilderConfig
Sourcepub fn from_builder(source: &RequestBuilder) -> Self
pub fn from_builder(source: &RequestBuilder) -> Self
1 to 1 copy of another RequestBuilder
Sourcepub fn new(model: String) -> Self
pub fn new(model: String) -> Self
§Important Note
The builder method of modifying messages filed is hidden because the reposibility is shifted to the client struct. such that the client struct can maintain the message history and can be reused.
§Description
Instantiates a RequestBuilder struct with a set of default values for the request object of groq chat completion API.
ⓘ
Self {
logit_bias: None,
logprobs: false,
frequency_penalty: 0.0,
max_tokens: None,
messages: Vec::new(),
model : "no default model".to_string(),
n: 1,
presence_penalty: 0.0,
response_format: ResponseFormat {
response_type: "text".into(),
},
seed: None,
stop: None,
stream: false,
temperature: 1.0,
tool_choice: None,
tools: None,
top_logprobs: None,
top_p: 1.0,
user: None,
}
pub fn build(self) -> Request
pub fn with_logit_bias(self, logit_bias: Value) -> Self
pub fn with_logprobs(self, logprobs: bool) -> Self
pub fn with_frequency_penalty(self, penalty: f32) -> Self
pub fn with_max_tokens(self, n: u32) -> Self
pub fn with_model(self, model: &str) -> Self
pub fn with_n(self, n: u32) -> Self
pub fn with_presence_penalty(self, penalty: f32) -> Self
pub fn with_response_fmt(self, fmt: ResponseFormat) -> Self
pub fn with_seed(self, seed: i32) -> Self
pub fn with_stop(self, stop: &str) -> Self
pub fn with_stops(self, stops: Vec<String>) -> Self
pub fn with_stream(self, stream: bool) -> Self
pub fn with_temperature(self, temp: f32) -> Self
pub fn with_tool_choice(self, tool: Tool) -> Self
pub fn with_auto_tool_choice(self) -> Self
pub fn with_tools(self, tools: Vec<Tool>) -> Self
pub fn with_top_logprobs(self, prob: u8) -> Self
pub fn with_top_p(self, top_p: f32) -> Self
pub fn with_user(self, user: &str) -> Self
Sourcepub fn is_stream(&self) -> bool
pub fn is_stream(&self) -> bool
Check the request object is set to use stream for the completion response or not
- true if the stream flag is on
- false if the stream flag is off
pub fn with_tool_choice_string(self, tool: String) -> Result<Self>
Trait Implementations§
Source§impl Debug for RequestBuilder
impl Debug for RequestBuilder
Auto Trait Implementations§
impl Freeze for RequestBuilder
impl RefUnwindSafe for RequestBuilder
impl Send for RequestBuilder
impl Sync for RequestBuilder
impl Unpin for RequestBuilder
impl UnwindSafe for RequestBuilder
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