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 langflow import CustomComponent
|
||||||
from langchain.chains import RetrievalQAWithSourcesChain
|
from langchain.chains import RetrievalQAWithSourcesChain
|
||||||
|
from langchain.chains.combine_documents.base import BaseCombineDocumentsChain
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from langflow.field_typing import (
|
from langflow.field_typing import (
|
||||||
BaseMemory,
|
BaseMemory,
|
||||||
BaseRetriever,
|
BaseRetriever,
|
||||||
Chain,
|
BaseLanguageModel
|
||||||
)
|
)
|
||||||
|
|
||||||
class RetrievalQAWithSourcesChainComponent(CustomComponent):
|
class RetrievalQAWithSourcesChainComponent(CustomComponent):
|
||||||
|
|
@ -14,22 +15,24 @@ class RetrievalQAWithSourcesChainComponent(CustomComponent):
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
return {
|
return {
|
||||||
"combine_documents_chain": {"display_name": "Combine Documents Chain"},
|
"llm": {"display_name": "LLM"},
|
||||||
"retriever": {"display_name": "Retriever"},
|
"chain_type": {
|
||||||
"memory": {"display_name": "Memory", "optional": True},
|
"display_name": "Chain Type",
|
||||||
"return_source_documents": {"display_name": "Return Source Documents", "default": True, "advanced": True},
|
"options": ['stuff', 'map_reduce', 'map_rerank', 'refine'],
|
||||||
|
},
|
||||||
|
"memory": {"display_name": "Memory"},
|
||||||
|
"return_source_documents": {"display_name": "Return Source Documents"},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
combine_documents_chain: Chain,
|
|
||||||
retriever: BaseRetriever,
|
retriever: BaseRetriever,
|
||||||
|
llm: BaseLanguageModel,
|
||||||
|
combine_documents_chain: BaseCombineDocumentsChain,
|
||||||
|
chain_type: str,
|
||||||
memory: Optional[BaseMemory] = None,
|
memory: Optional[BaseMemory] = None,
|
||||||
return_source_documents: Optional[bool] = True,
|
return_source_documents: Optional[bool] = True,
|
||||||
) -> RetrievalQAWithSourcesChain:
|
) -> RetrievalQAWithSourcesChain:
|
||||||
return RetrievalQAWithSourcesChain(
|
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)
|
||||||
combine_documents_chain=combine_documents_chain,
|
|
||||||
retriever=retriever,
|
|
||||||
memory=memory,
|
|
||||||
return_source_documents=return_source_documents
|
|
||||||
)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue