Add BaseCombineDocumentsChain to CombineDocsChainComponent

This commit is contained in:
anovazzi1 2024-01-16 18:33:41 -03:00
commit 921e34e378

View file

@ -2,6 +2,7 @@
from langflow import CustomComponent
from langflow.field_typing import BaseLanguageModel, Chain
from typing import Union, Callable
from langchain.chains.combine_documents.base import BaseCombineDocumentsChain
class CombineDocsChainComponent(CustomComponent):
display_name = "CombineDocsChain"
@ -24,14 +25,4 @@ class CombineDocsChainComponent(CustomComponent):
if chain_type not in ['stuff', 'map_reduce', 'map_rerank', 'refine']:
raise ValueError(f"Invalid chain_type: {chain_type}")
# Implement the logic to create and return the appropriate chain based on the chain_type
# This could be a placeholder for now, as the specific chain loading function is not defined.
# Replace with actual implementation when available.
return load_qa_chain(llm=llm, chain_type=chain_type)
# Assuming there is a function or class `load_qa_chain` that creates the chain
# based on the `chain_type` and `llm`. This is a placeholder for the actual
# implementation which should be replaced with the correct function/class call.
def load_qa_chain(llm: BaseLanguageModel, chain_type: str) -> Union[Chain, Callable]:
# Implement the logic to create and return the appropriate chain based on the chain_type
pass
return BaseCombineDocumentsChain()