pub struct ConversationalRetrieverChainBuilder { /* private fields */ }
Expand description
Conversation Retriever Chain Builder
§Usage
§Convensional way
ⓘ
let chain = ConversationalRetrieverChainBuilder::new()
.llm(llm)
.rephrase_question(true)
.retriever(RetrieverMock {})
.memory(SimpleMemory::new().into())
.build()
.expect("Error building ConversationalChain");
§Custom way
ⓘ
let llm = Box::new(OpenAI::default().with_model(OpenAIModel::Gpt35.to_string()));
let combine_documents_chain = StuffDocument::load_stuff_qa(llm.clone_box());
let chain = ConversationalRetrieverChainBuilder::new()
.rephrase_question(true)
.combine_documents_chain(Box::new(combine_documents_chain))
.condense_question_chain(Box::new(condense_question_chain))
.retriever(RetrieverMock {})
.memory(SimpleMemory::new().into())
.build()
.expect("Error building ConversationalChain");
Implementations§
Source§impl ConversationalRetrieverChainBuilder
impl ConversationalRetrieverChainBuilder
pub fn new() -> Self
pub fn retriever<R: Into<Box<dyn Retriever>>>(self, retriever: R) -> Self
Sourcepub fn prompt<P: Into<Box<dyn FormatPrompter>>>(self, prompt: P) -> Self
pub fn prompt<P: Into<Box<dyn FormatPrompter>>>(self, prompt: P) -> Self
If you want to add a custom prompt,keep in mind which variables are obligatory.
pub fn input_key<S: Into<String>>(self, input_key: S) -> Self
pub fn memory(self, memory: Arc<Mutex<dyn BaseMemory>>) -> Self
pub fn llm<L: Into<Box<dyn LLM>>>(self, llm: L) -> Self
Sourcepub fn combine_documents_chain<C: Into<Box<dyn Chain>>>(
self,
combine_documents_chain: C,
) -> Self
pub fn combine_documents_chain<C: Into<Box<dyn Chain>>>( self, combine_documents_chain: C, ) -> Self
Chain designed to take the documents and the question and generate an output
Sourcepub fn condense_question_chain<C: Into<Box<dyn Chain>>>(
self,
condense_question_chain: C,
) -> Self
pub fn condense_question_chain<C: Into<Box<dyn Chain>>>( self, condense_question_chain: C, ) -> Self
Chain designed to reformulate the question based on the cat history
pub fn rephrase_question(self, rephrase_question: bool) -> Self
pub fn return_source_documents(self, return_source_documents: bool) -> Self
pub fn build(self) -> Result<ConversationalRetrieverChain, ChainError>
Auto Trait Implementations§
impl Freeze for ConversationalRetrieverChainBuilder
impl !RefUnwindSafe for ConversationalRetrieverChainBuilder
impl Send for ConversationalRetrieverChainBuilder
impl Sync for ConversationalRetrieverChainBuilder
impl Unpin for ConversationalRetrieverChainBuilder
impl !UnwindSafe for ConversationalRetrieverChainBuilder
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