pub enum PerplexityModels {
SonarPro,
Sonar,
SonarReasoning,
Llama3_1SonarSmall,
Llama3_1SonarLarge,
Llama3_1SonarHuge,
}Variants§
SonarPro
Sonar
SonarReasoning
Llama3_1SonarSmall
👎Deprecated since 0.12.0:
Llama3_1SonarSmall is deprecated starting February 22, 2025, please use Sonar or SonarPro instead.Llama3_1SonarLarge
👎Deprecated since 0.12.0:
Llama3_1SonarLarge is deprecated starting February 22, 2025, please use Sonar or SonarPro instead.Llama3_1SonarHuge
👎Deprecated since 0.12.0:
Llama3_1SonarHuge is deprecated starting February 22, 2025, please use Sonar or SonarPro instead.Trait Implementations§
Source§impl Clone for PerplexityModels
impl Clone for PerplexityModels
Source§fn clone(&self) -> PerplexityModels
fn clone(&self) -> PerplexityModels
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PerplexityModels
impl Debug for PerplexityModels
Source§impl<'de> Deserialize<'de> for PerplexityModels
impl<'de> Deserialize<'de> for PerplexityModels
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
Source§impl LLMModel for PerplexityModels
impl LLMModel for PerplexityModels
Source§fn call_api<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
api_key: &'life1 str,
_version: Option<String>,
body: &'life2 Value,
debug: bool,
_tools: Option<&'life3 [LLMTools]>,
) -> Pin<Box<dyn Future<Output = Result<String>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn call_api<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
api_key: &'life1 str,
_version: Option<String>,
body: &'life2 Value,
debug: bool,
_tools: Option<&'life3 [LLMTools]>,
) -> Pin<Box<dyn Future<Output = Result<String>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
This function leverages Perplexity API to perform any query as per the provided body.
It returns a String the Response object that needs to be parsed based on the self.model.
Source§fn sanitize_json_response(&self, json_response: &str) -> String
fn sanitize_json_response(&self, json_response: &str) -> String
This function sanitizes the text response from Perplexity models to clean up common formatting issues. Currently the function checks:
json{}wrapper around responsewrapper (for SonarReasoning model only)
Source§fn try_from_str(name: &str) -> Option<Self>
fn try_from_str(name: &str) -> Option<Self>
Returns an instance of the enum based on the provided string representation of name
Source§fn default_max_tokens(&self) -> usize
fn default_max_tokens(&self) -> usize
Returns max supported number of tokens for each of the variants of the enum
Source§fn get_endpoint(&self) -> String
fn get_endpoint(&self) -> String
Returns the url of the endpoint that should be called for each variant of the LLM Model enum
Source§fn get_body(
&self,
instructions: &str,
json_schema: &Value,
function_call: bool,
_max_tokens: &usize,
temperature: &f32,
_tools: Option<&[LLMTools]>,
_thinking_level: Option<&ThinkingLevel>,
) -> Value
fn get_body( &self, instructions: &str, json_schema: &Value, function_call: bool, _max_tokens: &usize, temperature: &f32, _tools: Option<&[LLMTools]>, _thinking_level: Option<&ThinkingLevel>, ) -> Value
Constructs the body that should be attached to the API call for each of the LLM Models
Source§fn get_data(&self, response_text: &str, _function_call: bool) -> Result<String>
fn get_data(&self, response_text: &str, _function_call: bool) -> Result<String>
Based on the model type extracts the data portion of the API response
Source§fn get_rate_limit(&self) -> RateLimit
fn get_rate_limit(&self) -> RateLimit
Returns the rate limit accepted by the API depending on the used model
If not explicitly defined it will assume 1B tokens or 100k transactions a minute
Source§fn get_normalized_temperature(&self, relative_temp: u32) -> f32
fn get_normalized_temperature(&self, relative_temp: u32) -> f32
Returns the normalized temperature for the model
Source§fn get_version_endpoint(&self, _version: Option<String>) -> String
fn get_version_endpoint(&self, _version: Option<String>) -> String
Returns the url of the endpoint that should be called for each variant of the LLM Model enum
It allows to specify which version of the endpoint to use
Source§fn get_base_instructions(&self, _function_call: Option<bool>) -> String
fn get_base_instructions(&self, _function_call: Option<bool>) -> String
Provides a list of base instructions that should be added to each prompt when using each of the models
Source§fn function_call_default(&self) -> bool
fn function_call_default(&self) -> bool
Returns recommendation if function calling should be used for the specified model
Source§fn get_version_body(
&self,
instructions: &str,
json_schema: &Value,
function_call: bool,
max_tokens: &usize,
temperature: &f32,
_version: Option<String>,
tools: Option<&[LLMTools]>,
thinking_level: Option<&ThinkingLevel>,
) -> Value
fn get_version_body( &self, instructions: &str, json_schema: &Value, function_call: bool, max_tokens: &usize, temperature: &f32, _version: Option<String>, tools: Option<&[LLMTools]>, thinking_level: Option<&ThinkingLevel>, ) -> Value
An API-version-specific implementation of the body constructor
Source§fn get_version_data(
&self,
response_text: &str,
function_call: bool,
_version: Option<String>,
) -> Result<String>
fn get_version_data( &self, response_text: &str, function_call: bool, _version: Option<String>, ) -> Result<String>
An API-version-specific implementation of the data extractor
Source§fn get_max_requests(&self) -> usize
fn get_max_requests(&self) -> usize
Based on the RateLimit for the model calculates how many requests can be send to the API
Source§fn get_default_temperature(&self) -> f32
fn get_default_temperature(&self) -> f32
Returns the default temperature to be used by the model
Source§impl PartialEq for PerplexityModels
impl PartialEq for PerplexityModels
Source§impl Serialize for PerplexityModels
impl Serialize for PerplexityModels
impl Eq for PerplexityModels
impl StructuralPartialEq for PerplexityModels
Auto Trait Implementations§
impl Freeze for PerplexityModels
impl RefUnwindSafe for PerplexityModels
impl Send for PerplexityModels
impl Sync for PerplexityModels
impl Unpin for PerplexityModels
impl UnwindSafe for PerplexityModels
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.