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>,
}
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
impl SearchConfig
Sourcepub fn parse_into_results(
&self,
raw_results: &Value,
) -> Result<SearchOutput, Box<dyn Error>>
pub fn parse_into_results( &self, raw_results: &Value, ) -> Result<SearchOutput, Box<dyn Error>>
Wrapper for the parser() function.
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
Sourcepub async fn perform_search<T: Serialize>(
&self,
search_input: &T,
) -> Result<SearchOutput, LlamaCoreError>
pub async fn perform_search<T: Serialize>( &self, search_input: &T, ) -> Result<SearchOutput, LlamaCoreError>
Perform a web search with a Serialize
-able input. The search_input
is used as is to query the search endpoint.
Sourcepub async fn summarize_search<T: Serialize>(
&self,
search_input: &T,
) -> Result<String, LlamaCoreError>
pub async fn summarize_search<T: Serialize>( &self, search_input: &T, ) -> Result<String, LlamaCoreError>
Perform a search and summarize the corresponding search results
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SearchConfig
impl RefUnwindSafe for SearchConfig
impl Send for SearchConfig
impl Sync for SearchConfig
impl Unpin for SearchConfig
impl UnwindSafe for SearchConfig
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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