Better agent execution error handling (#54)

A few quality of life improvements around cache handling and repeated tool usage
This commit is contained in:
João Moura
2024-01-05 11:04:59 -03:00
committed by GitHub
parent 6b054651a7
commit 3f9c4df32d
16 changed files with 38 additions and 43 deletions

View File

@@ -0,0 +1,20 @@
from langchain_core.exceptions import OutputParserException
class TaskRepeatedUsageException(OutputParserException):
"""Exception raised when a task is used twice in a roll."""
error: str = "TaskRepeatedUsageException"
message: str = "\nI just used the {tool} tool with input {tool_input}. So I already know the result of that.\n"
def __init__(self, tool: str, tool_input: str):
self.tool = tool
self.tool_input = tool_input
self.message = self.message.format(tool=tool, tool_input=tool_input)
super().__init__(
error=self.error, observation=self.message, send_to_llm=True, llm_output=""
)
def __str__(self):
return self.message