pub struct Request<T> { /* private fields */ }
Expand description
Used to send a request for chat.
Implementations§
Source§impl Request<MessageVision>
impl Request<MessageVision>
Sourcepub fn add_message(
self,
role: Roles,
prompt: String,
image_uri: String,
) -> Request<MessageVision>
pub fn add_message( self, role: Roles, prompt: String, image_uri: String, ) -> Request<MessageVision>
Adds a message to the request when making a chat vision call.
§Arguments
role
- The role of the user sending the message.prompt
- The text prompt to be sent along with the image.image_uri
- data URI for base64 encoded image e.g. data:image/jpeg;base64,data
Source§impl<T> Request<T>
impl<T> Request<T>
Sourcepub fn with_message(self, msg: T) -> Request<T>
pub fn with_message(self, msg: T) -> Request<T>
Sourcepub fn with_messages(self, messages: Vec<T>) -> Request<T>
pub fn with_messages(self, messages: Vec<T>) -> Request<T>
Returns a request with the list of messages.
§Arguments
messages
- The messages to be added to the request.
Sourcepub fn max_tokens(self, max: i64) -> Request<T>
pub fn max_tokens(self, max: i64) -> Request<T>
Sets the max tokens for the request.
§Arguments
max
- The maximum number of tokens to be returned in the response.
Sourcepub fn temperature(self, temp: f64) -> Request<T>
pub fn temperature(self, temp: f64) -> Request<T>
Sets the temperature for the request.
§Arguments
temp
- The temperature setting for the request. Used to control randomness.
Sourcepub fn top_p(self, top: f64) -> Request<T>
pub fn top_p(self, top: f64) -> Request<T>
Sets the Top p for the request.
§Arguments
top
- The Top p setting for the request. Used to control randomness.
Sourcepub fn top_k(self, top_k: i64) -> Request<T>
pub fn top_k(self, top_k: i64) -> Request<T>
Sets the Top k for the request.
§Arguments
top_k
- The Top k setting for the request. Used to control randomness.
Sourcepub fn input(
self,
block_prompt_injection: bool,
pii: Option<(InputMethod, ReplaceMethod)>,
) -> Request<T>
pub fn input( self, block_prompt_injection: bool, pii: Option<(InputMethod, ReplaceMethod)>, ) -> Request<T>
Sets the input parameters for the request, to check for prompt injection and PII.
§Arguments
block_prompt_injection
- Determines whether to check for prompt injection in the request.pii
- Sets thepii::InputMethod
and thepii::ReplacementMethod
.
Sourcepub fn output(self, check_factuality: bool, check_toxicity: bool) -> Request<T>
pub fn output(self, check_factuality: bool, check_toxicity: bool) -> Request<T>
Sets the output parameters for the request, to check for factuality and toxicity.
§Arguments
check_factuality
- Determines whether to check for factuality in the response.check_toxicity
- Determines whether to check for toxicity in the response.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Request<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Request<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> Freeze for Request<T>
impl<T> RefUnwindSafe for Request<T>where
T: RefUnwindSafe,
impl<T> Send for Request<T>where
T: Send,
impl<T> Sync for Request<T>where
T: Sync,
impl<T> Unpin for Request<T>where
T: Unpin,
impl<T> UnwindSafe for Request<T>where
T: UnwindSafe,
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