Skip to content

Commit

Permalink
type fix from chian to chain
Browse files Browse the repository at this point in the history
  • Loading branch information
StavoS committed Oct 6, 2024
1 parent 891c56f commit 951be98
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions src/chain/conversational_retrieval_qa/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ const CONVERSATIONAL_RETRIEVAL_QA_DEFAULT_INPUT_KEY: &str = "question";
///
/// let llm = Box::new(OpenAI::default().with_model(OpenAIModel::Gpt35.to_string()));
/// let combine_documents_chain = StuffDocument::load_stuff_qa(llm.clone_box());
// let condense_question_chian = CondenseQuestionGeneratorChain::new(llm.clone_box());
// let condense_question_chain = CondenseQuestionGeneratorChain::new(llm.clone_box());
/// let chain = ConversationalRetrieverChainBuilder::new()
/// .rephrase_question(true)
/// .combine_documents_chain(Box::new(combine_documents_chain))
/// .condense_question_chian(Box::new(condense_question_chian))
/// .condense_question_chain(Box::new(condense_question_chain))
/// .retriever(RetrieverMock {})
/// .memory(SimpleMemory::new().into())
/// .build()
Expand All @@ -49,7 +49,7 @@ pub struct ConversationalRetrieverChainBuilder {
retriever: Option<Box<dyn Retriever>>,
memory: Option<Arc<Mutex<dyn BaseMemory>>>,
combine_documents_chain: Option<Box<dyn Chain>>,
condense_question_chian: Option<Box<dyn Chain>>,
condense_question_chain: Option<Box<dyn Chain>>,
prompt: Option<Box<dyn FormatPrompter>>,
rephrase_question: bool,
return_source_documents: bool,
Expand All @@ -63,7 +63,7 @@ impl ConversationalRetrieverChainBuilder {
retriever: None,
memory: None,
combine_documents_chain: None,
condense_question_chian: None,
condense_question_chain: None,
prompt: None,
rephrase_question: true,
return_source_documents: true,
Expand Down Expand Up @@ -108,11 +108,11 @@ impl ConversationalRetrieverChainBuilder {
}

///Chain designed to reformulate the question based on the cat history
pub fn condense_question_chian<C: Into<Box<dyn Chain>>>(
pub fn condense_question_chain<C: Into<Box<dyn Chain>>>(
mut self,
condense_question_chian: C,
condense_question_chain: C,
) -> Self {
self.condense_question_chian = Some(condense_question_chian.into());
self.condense_question_chain = Some(condense_question_chain.into());
self
}

Expand All @@ -135,9 +135,9 @@ impl ConversationalRetrieverChainBuilder {
}
builder.build()?
};
let condense_question_chian = CondenseQuestionGeneratorChain::new(llm.clone_box());
let condense_question_chain = CondenseQuestionGeneratorChain::new(llm.clone_box());
self.combine_documents_chain = Some(Box::new(combine_documents_chain));
self.condense_question_chian = Some(Box::new(condense_question_chian));
self.condense_question_chain = Some(Box::new(condense_question_chain));
}

let retriever = self
Expand All @@ -153,7 +153,7 @@ impl ConversationalRetrieverChainBuilder {
"Combine documents chain must be set or llm must be set".into(),
)
})?;
let condense_question_chian = self.condense_question_chian.ok_or_else(|| {
let condense_question_chain = self.condense_question_chain.ok_or_else(|| {
ChainError::MissingObject(
"Condense question chain must be set or llm must be set".into(),
)
Expand All @@ -162,7 +162,7 @@ impl ConversationalRetrieverChainBuilder {
retriever,
memory,
combine_documents_chain,
condense_question_chian,
condense_question_chain,
rephrase_question: self.rephrase_question,
return_source_documents: self.return_source_documents,
input_key: self.input_key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct ConversationalRetrieverChain {
pub(crate) retriever: Box<dyn Retriever>,
pub memory: Arc<Mutex<dyn BaseMemory>>,
pub(crate) combine_documents_chain: Box<dyn Chain>,
pub(crate) condense_question_chian: Box<dyn Chain>,
pub(crate) condense_question_chain: Box<dyn Chain>,
pub(crate) rephrase_question: bool,
pub(crate) return_source_documents: bool,
pub(crate) input_key: String, //Default is `question`
Expand All @@ -46,7 +46,7 @@ impl ConversationalRetrieverChain {
let question = match self.rephrase_question {
true => {
let result = self
.condense_question_chian
.condense_question_chain
.call(
CondenseQuestionPromptBuilder::new()
.question(input)
Expand Down

0 comments on commit 951be98

Please sign in to comment.