🐛 fix(chat.py): remove unused user dependency in stream_build function

🐛 fix(chat.py): handle KeyError when retrieving user_id from cache_service
 feat(chat.py): use user_id from cache_service instead of user.id in try_running_celery_task and vertex.build functions
🔧 chore(config.yaml): comment out ConversationChain in chains configuration
🔧 chore(base.py): import SQLDatabaseChain from langchain_experimental.sql module and add it to type_dict
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-11-03 16:13:15 -03:00
commit 9b23dae530
3 changed files with 11 additions and 6 deletions

View file

@ -127,7 +127,6 @@ async def stream_build(
flow_id: str,
chat_service: "ChatService" = Depends(get_chat_service),
cache_service: "BaseCacheService" = Depends(get_cache_service),
user=Depends(get_current_active_user),
):
"""Stream the build process based on stored flow data."""
@ -161,6 +160,11 @@ async def stream_build(
number_of_nodes = len(graph.nodes)
update_build_status(cache_service, flow_id, BuildStatus.IN_PROGRESS)
try:
user_id = cache_service[flow_id]["user_id"]
except KeyError:
logger.debug("No user_id found in cache_service")
user_id = None
for i, vertex in enumerate(graph.generator_build(), 1):
try:
log_dict = {
@ -168,9 +172,9 @@ async def stream_build(
}
yield str(StreamData(event="log", data=log_dict))
if vertex.is_task:
vertex = try_running_celery_task(vertex, user.id)
vertex = try_running_celery_task(vertex, user_id)
else:
vertex.build(user_id=user.id)
vertex.build(user_id=user_id)
params = vertex._built_object_repr()
valid = True
logger.debug(f"Building node {str(vertex.vertex_type)}")

View file

@ -20,8 +20,8 @@ chains:
documentation: "https://python.langchain.com/docs/modules/chains/additional/llm_math"
LLMCheckerChain:
documentation: "https://python.langchain.com/docs/modules/chains/additional/llm_checker"
ConversationChain:
documentation: ""
# ConversationChain:
# documentation: ""
SeriesCharacterChain:
documentation: ""
MidJourneyPromptChain:

View file

@ -9,6 +9,7 @@ from langflow.template.frontend_node.chains import ChainFrontendNode
from loguru import logger
from langflow.utils.util import build_template_from_class, build_template_from_method
from langchain import chains
from langchain_experimental.sql import SQLDatabaseChain
# Assuming necessary imports for Field, Template, and FrontendNode classes
@ -37,7 +38,7 @@ class ChainCreator(LangChainTypeCreator):
}
from langflow.interface.chains.custom import CUSTOM_CHAINS
# self.type_dict["SQLDatabaseChain"] = SQLDatabaseChain
self.type_dict["SQLDatabaseChain"] = SQLDatabaseChain
self.type_dict.update(CUSTOM_CHAINS)
# Filter according to settings.chains