Refactor chat utils module
This commit is contained in:
parent
51fa0f22e0
commit
8421e60f10
1 changed files with 7 additions and 4 deletions
|
|
@ -3,12 +3,11 @@ from typing import Any
|
|||
from langchain.agents import AgentExecutor
|
||||
from langchain.chains.base import Chain
|
||||
from langchain_core.runnables import Runnable
|
||||
from loguru import logger
|
||||
|
||||
from langflow.api.v1.schemas import ChatMessage
|
||||
from langflow.interface.utils import try_setting_streaming_options
|
||||
from langflow.processing.base import get_result_and_steps
|
||||
from langflow.utils.chat import ChatAdapter
|
||||
from langflow.utils.chat import ChatDefinition
|
||||
from loguru import logger
|
||||
|
||||
LANGCHAIN_RUNNABLES = (Chain, Runnable, AgentExecutor)
|
||||
|
||||
|
|
@ -40,13 +39,17 @@ async def process_graph(
|
|||
client_id=client_id,
|
||||
session_id=session_id,
|
||||
)
|
||||
elif isinstance(build_result, ChatAdapter):
|
||||
elif isinstance(build_result, ChatDefinition):
|
||||
result = await run_build_result(
|
||||
build_result,
|
||||
chat_inputs,
|
||||
client_id=client_id,
|
||||
session_id=session_id,
|
||||
)
|
||||
if isinstance(result, dict):
|
||||
if not build_result.output_key:
|
||||
raise ValueError("No output key provided to select the output from the result")
|
||||
result = result[build_result.output_key]
|
||||
intermediate_steps = []
|
||||
raw_output = result
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue