pub struct AnswerGenerator { /* private fields */ }Expand description
Main answer generator that orchestrates the response generation process
Implementations§
Source§impl AnswerGenerator
impl AnswerGenerator
Sourcepub fn new(llm: Box<dyn LLMInterface>, config: GenerationConfig) -> Result<Self>
pub fn new(llm: Box<dyn LLMInterface>, config: GenerationConfig) -> Result<Self>
Create a new answer generator with the provided LLM and configuration
Sourcepub fn with_custom_templates(
llm: Box<dyn LLMInterface>,
config: GenerationConfig,
templates: HashMap<String, PromptTemplate>,
) -> Result<Self>
pub fn with_custom_templates( llm: Box<dyn LLMInterface>, config: GenerationConfig, templates: HashMap<String, PromptTemplate>, ) -> Result<Self>
Create a new answer generator with custom prompt templates
Sourcepub fn generate_answer(
&self,
query: &str,
search_results: Vec<SearchResult>,
hierarchical_results: Vec<QueryResult>,
) -> Result<GeneratedAnswer>
pub fn generate_answer( &self, query: &str, search_results: Vec<SearchResult>, hierarchical_results: Vec<QueryResult>, ) -> Result<GeneratedAnswer>
Generate an answer from search results
Sourcepub fn add_template(&mut self, name: String, template: PromptTemplate)
pub fn add_template(&mut self, name: String, template: PromptTemplate)
Add a custom prompt template
Sourcepub fn update_config(&mut self, new_config: GenerationConfig)
pub fn update_config(&mut self, new_config: GenerationConfig)
Update generation configuration
Sourcepub fn get_statistics(&self) -> GeneratorStatistics
pub fn get_statistics(&self) -> GeneratorStatistics
Get statistics about the generator
Auto Trait Implementations§
impl Freeze for AnswerGenerator
impl !RefUnwindSafe for AnswerGenerator
impl Send for AnswerGenerator
impl Sync for AnswerGenerator
impl Unpin for AnswerGenerator
impl UnsafeUnpin for AnswerGenerator
impl !UnwindSafe for AnswerGenerator
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> 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 more