added error catching for review
This commit is contained in:
@@ -12,7 +12,10 @@ def RunCommand(command) -> str:
|
|||||||
Returns:
|
Returns:
|
||||||
Output of command
|
Output of command
|
||||||
"""
|
"""
|
||||||
return os.popen(command).read()
|
try:
|
||||||
|
return os.popen(command).read()
|
||||||
|
except Exception as e:
|
||||||
|
return f"Error occourd while processing: {e}"
|
||||||
|
|
||||||
|
|
||||||
class review:
|
class review:
|
||||||
@@ -58,21 +61,36 @@ class review:
|
|||||||
if response.message.tool_calls:
|
if response.message.tool_calls:
|
||||||
print("attempted tool calling")
|
print("attempted tool calling")
|
||||||
for tool in response.message.tool_calls:
|
for tool in response.message.tool_calls:
|
||||||
print("-- TOOL CALLING RAN --")
|
try:
|
||||||
print(
|
print("-- TOOL CALLING RAN --")
|
||||||
"- The LLM is currently running tests on your computer in order to generate a review -"
|
print(
|
||||||
)
|
"- The LLM is currently running tests on your computer in order to generate a review -"
|
||||||
|
)
|
||||||
|
|
||||||
|
print(f"Command; {tool.function.arguments}")
|
||||||
|
result = RunCommand(**tool.function.arguments)
|
||||||
|
print(f"Result: {result}")
|
||||||
|
messageHistory.append(
|
||||||
|
{
|
||||||
|
"role": "tool",
|
||||||
|
"tool_name": tool.function.name,
|
||||||
|
"content": str(result),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
print("-- END OF TOOL CALL --")
|
||||||
|
except Exception as e:
|
||||||
|
print("-- TOOL CALLING ERROR --")
|
||||||
|
print("- Error occourd while using tool calling -")
|
||||||
|
|
||||||
|
print(f"Result: {e}")
|
||||||
|
messageHistory.append(
|
||||||
|
{
|
||||||
|
"role": "tool",
|
||||||
|
"tool_name": tool.function.name,
|
||||||
|
"content": str(e),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
print("-- END OF TOOL ERROR --")
|
||||||
|
|
||||||
print(f"Command; {tool.function.arguments}")
|
|
||||||
result = RunCommand(**tool.function.arguments)
|
|
||||||
print(f"Result: {result}")
|
|
||||||
messageHistory.append(
|
|
||||||
{
|
|
||||||
"role": "tool",
|
|
||||||
"tool_name": tool.function.name,
|
|
||||||
"content": str(result),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
print("-- END OF TOOL CALL --")
|
|
||||||
else:
|
else:
|
||||||
return response["message"]["content"]
|
return response["message"]["content"]
|
||||||
|
|||||||
Reference in New Issue
Block a user