🐛 fix(process.py): add support for processing Document objects in process_graph_cached function

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-09-09 08:28:29 -03:00
commit f379d54686

View file

@ -11,6 +11,7 @@ from langflow.graph import Graph
from langchain.chains.base import Chain from langchain.chains.base import Chain
from langchain.vectorstores.base import VectorStore from langchain.vectorstores.base import VectorStore
from typing import Any, Dict, List, Optional, Tuple, Union from typing import Any, Dict, List, Optional, Tuple, Union
from langchain.schema import Document
def fix_memory_inputs(langchain_object): def fix_memory_inputs(langchain_object):
@ -126,6 +127,8 @@ def process_graph_cached(
logger.debug("Generated result and thought") logger.debug("Generated result and thought")
elif isinstance(langchain_object, VectorStore): elif isinstance(langchain_object, VectorStore):
result = langchain_object.search(**inputs) result = langchain_object.search(**inputs)
elif isinstance(langchain_object, Document):
result = langchain_object.dict()
else: else:
raise ValueError( raise ValueError(
f"Unknown langchain_object type: {type(langchain_object).__name__}" f"Unknown langchain_object type: {type(langchain_object).__name__}"