Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch langchain agent errors #1539

Merged
merged 14 commits into from
Mar 11, 2024
Merged
11 changes: 8 additions & 3 deletions morpheus/llm/nodes/langchain_agent_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ async def _run_single(self, **kwargs: dict[str, typing.Any]) -> dict[str, typing
return results

# We are not dealing with a list, so run single
return await self._agent_executor.arun(**kwargs)

async def execute(self, context: LLMContext) -> LLMContext:
try:
return await self._agent_executor.arun(**kwargs)
dagardner-nv marked this conversation as resolved.
Show resolved Hide resolved
except Exception as e:
error_msg = f"Error running agent: {e}"
logger.exception(error_msg)
return error_msg
dagardner-nv marked this conversation as resolved.
Show resolved Hide resolved

async def execute(self, context: LLMContext) -> LLMContext: # pylint: disable=invalid-overridden-method

input_dict = context.get_inputs()

Expand Down
Loading