Merge branch 'update_lc' of github.com:logspace-ai/langflow into update_lc
This commit is contained in:
commit
6fb0800d52
1 changed files with 15 additions and 12 deletions
|
|
@ -1,11 +1,12 @@
|
|||
|
||||
from langflow import CustomComponent
|
||||
from langchain.chains import RetrievalQAWithSourcesChain
|
||||
from langchain.chains.combine_documents.base import BaseCombineDocumentsChain
|
||||
from typing import Optional
|
||||
from langflow.field_typing import (
|
||||
BaseMemory,
|
||||
BaseRetriever,
|
||||
Chain,
|
||||
BaseLanguageModel
|
||||
)
|
||||
|
||||
class RetrievalQAWithSourcesChainComponent(CustomComponent):
|
||||
|
|
@ -14,22 +15,24 @@ class RetrievalQAWithSourcesChainComponent(CustomComponent):
|
|||
|
||||
def build_config(self):
|
||||
return {
|
||||
"combine_documents_chain": {"display_name": "Combine Documents Chain"},
|
||||
"retriever": {"display_name": "Retriever"},
|
||||
"memory": {"display_name": "Memory", "optional": True},
|
||||
"return_source_documents": {"display_name": "Return Source Documents", "default": True, "advanced": True},
|
||||
"llm": {"display_name": "LLM"},
|
||||
"chain_type": {
|
||||
"display_name": "Chain Type",
|
||||
"options": ['stuff', 'map_reduce', 'map_rerank', 'refine'],
|
||||
},
|
||||
"memory": {"display_name": "Memory"},
|
||||
"return_source_documents": {"display_name": "Return Source Documents"},
|
||||
|
||||
}
|
||||
|
||||
|
||||
def build(
|
||||
self,
|
||||
combine_documents_chain: Chain,
|
||||
retriever: BaseRetriever,
|
||||
llm: BaseLanguageModel,
|
||||
combine_documents_chain: BaseCombineDocumentsChain,
|
||||
chain_type: str,
|
||||
memory: Optional[BaseMemory] = None,
|
||||
return_source_documents: Optional[bool] = True,
|
||||
) -> RetrievalQAWithSourcesChain:
|
||||
return RetrievalQAWithSourcesChain(
|
||||
combine_documents_chain=combine_documents_chain,
|
||||
retriever=retriever,
|
||||
memory=memory,
|
||||
return_source_documents=return_source_documents
|
||||
)
|
||||
return RetrievalQAWithSourcesChain(combine_documents_chain=combine_documents_chain,memory=memory,return_source_documents=return_source_documents,retriever=retriever).from_chain_type(llm=llm, chain_type=chain_type)
|
||||
Loading…
Add table
Add a link
Reference in a new issue