Struct SearchConfig

Source
pub struct SearchConfig {
    pub search_engine: String,
    pub max_search_results: u8,
    pub size_limit_per_result: u16,
    pub endpoint: String,
    pub content_type: ContentType,
    pub output_content_type: ContentType,
    pub method: String,
    pub additional_headers: Option<HashMap<String, String>>,
    pub parser: fn(&Value) -> Result<SearchOutput, Box<dyn Error>>,
    pub summarization_prompts: Option<(String, String)>,
    pub summarize_ctx_size: Option<usize>,
}
Available on crate feature search only.
Expand description

The base Search Configuration holding all relevant information to access a search api and retrieve results.

Fields§

§search_engine: String

The search engine we’re currently focusing on. Currently only one supported, to ensure stability.

§max_search_results: u8

The total number of results.

§size_limit_per_result: u16

The size limit of every search result.

§endpoint: String

The endpoint for the search API.

§content_type: ContentType

The content type of the input.

§output_content_type: ContentType

The (expected) content type of the output.

§method: String

Method expected by the api endpoint.

§additional_headers: Option<HashMap<String, String>>

Additional headers for any other purpose.

§parser: fn(&Value) -> Result<SearchOutput, Box<dyn Error>>

Callback function to parse the output of the api-service. Implementation left to the user.

§summarization_prompts: Option<(String, String)>

Prompts for use with summarization functionality. If set to None, use hard-coded prompts.

§summarize_ctx_size: Option<usize>

Context size for summary generation. If None, will use the 4 char ~ 1 token metric to generate summary.

Implementations§

Source§

impl SearchConfig

Source

pub fn parse_into_results( &self, raw_results: &Value, ) -> Result<SearchOutput, Box<dyn Error>>

Wrapper for the parser() function.

Source

pub fn new( search_engine: String, max_search_results: u8, size_limit_per_result: u16, endpoint: String, content_type: ContentType, output_content_type: ContentType, method: String, additional_headers: Option<HashMap<String, String>>, parser: fn(&Value) -> Result<SearchOutput, Box<dyn Error>>, summarization_prompts: Option<(String, String)>, summarize_ctx_size: Option<usize>, ) -> SearchConfig

Perform a web search with a Serialize-able input. The search_input is used as is to query the search endpoint.

Perform a search and summarize the corresponding search results

Trait Implementations§

Source§

impl Debug for SearchConfig

Source§

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

Formats the value using the given formatter. 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T