PerplexityModels

Enum PerplexityModels 

Source
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

Source§

fn clone(&self) -> PerplexityModels

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PerplexityModels

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PerplexityModels

Source§

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

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,

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

This function sanitizes the text response from Perplexity models to clean up common formatting issues. Currently the function checks:

  • json{} wrapper around response
  • wrapper (for SonarReasoning model only)
Source§

fn as_str(&self) -> &str

Converts each item in the model enum into its string representation
Source§

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

Returns max supported number of tokens for each of the variants of the enum
Source§

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

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>

Based on the model type extracts the data portion of the API response
Source§

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

Returns the normalized temperature for the model
Source§

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

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

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

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>

An API-version-specific implementation of the data extractor
Source§

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

Returns the default temperature to be used by the model
Source§

impl PartialEq for PerplexityModels

Source§

fn eq(&self, other: &PerplexityModels) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PerplexityModels

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for PerplexityModels

Source§

impl StructuralPartialEq for PerplexityModels

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,