Struct spider::features::openai_common::GPTConfigs

source ·
pub struct GPTConfigs {
    pub prompt: Prompt,
    pub model: String,
    pub max_tokens: u16,
    pub temperature: Option<f32>,
    pub user: Option<String>,
    pub top_p: Option<f32>,
    pub prompt_url_map: Option<HashMap<CaseInsensitiveString, Self>>,
    pub extra_ai_data: bool,
    pub paths_map: bool,
    pub screenshot: bool,
    pub api_key: Option<String>,
    pub cache: Option<AICache>,
}
Expand description

The GPT configs to use for dynamic Javascript execution and other functionality.

Fields§

§prompt: Prompt

The prompt to use for the Chat. Example: Search for movies. This will attempt to get the code required to perform the action on the page.

§model: String

The model to use. Example: gpt-4-1106-preview or gpt-3.5-turbo-16k

§max_tokens: u16

The max tokens to use for the request.

§temperature: Option<f32>

The temperature between 0 - 2.

§user: Option<String>

The user for the request.

§top_p: Option<f32>

The top priority for the request.

§prompt_url_map: Option<HashMap<CaseInsensitiveString, Self>>

Prompts to use for certain urls. If this is set only the urls that match exactly are ran.

§extra_ai_data: bool

Extra data, this will merge the prompts and try to get the content for you. Example: extracting data from the page.

§paths_map: bool

Map to paths. If the prompt_url_map has a key called /blog and all blog pages are found like /blog/something the same prompt is perform unless an exact match is found.

§screenshot: bool

Take a screenshot of the page after each JS script execution. The screenshot is stored as a base64.

§api_key: Option<String>

The API key to use for the request.

§cache: Option<AICache>

Use caching to cache the prompt. This does nothing without the ‘cache_openai’ flag enabled.

Implementations§

source§

impl GPTConfigs

source

pub fn new(model: &str, prompt: &str, max_tokens: u16) -> GPTConfigs

GPTConfigs for OpenAI chrome dynamic scripting.

source

pub fn new_cache( model: &str, prompt: &str, max_tokens: u16, cache: Option<AICache> ) -> GPTConfigs

GPTConfigs for OpenAI chrome dynamic scripting and caching.

source

pub fn new_multi<I, S>(model: &str, prompt: I, max_tokens: u16) -> GPTConfigs
where I: IntoIterator<Item = S>, S: AsRef<str>,

GPTConfigs for OpenAI chrome dynamic scripting multi chain prompts.

source

pub fn new_multi_cache<I, S>( model: &str, prompt: I, max_tokens: u16, cache: Option<AICache> ) -> GPTConfigs
where I: IntoIterator<Item = S>, S: AsRef<str>,

GPTConfigs for OpenAI chrome dynamic scripting multi chain prompts with prompt caching. The feature flag ‘cache_openai’ is required.

source

pub fn set_extra(&mut self, extra_ai_data: bool) -> &mut Self

Set extra AI data to return results.

Trait Implementations§

source§

impl Clone for GPTConfigs

source§

fn clone(&self) -> GPTConfigs

Returns a copy 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 GPTConfigs

source§

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

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

impl Default for GPTConfigs

source§

fn default() -> GPTConfigs

Returns the “default value” for a type. Read more

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

§

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>,

§

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>,

§

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<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