This commit is contained in:
Slipstream 2025-04-28 22:33:27 -06:00
parent d497ed8599
commit 6bb19c4bb2
Signed by: slipstream
GPG Key ID: 13E498CE010AC6FD
2 changed files with 4 additions and 2 deletions

View File

@ -296,7 +296,7 @@ async def get_ai_response(cog: 'GurtCog', message: discord.Message, model_name:
chat_history=chat_history_factory, # Pass the factory function
prompt=prompt_template, # Pass the constructed prompt template
model_kwargs=model_kwargs,
# verbose=True, # Enable for debugging agent steps
verbose=True, # Enable for debugging agent steps
# handle_parsing_errors=True, # Let the agent try to recover from parsing errors
# max_iterations=10, # Limit tool execution loops
)

View File

@ -714,10 +714,12 @@ def calculate(cog: commands.Cog, expression: str) -> Dict[str, Any]:
else: result_str = repr(result) # Fallback
print(f"Calculation result: {result_str}")
return {"expression": expression, "result": result_str, "status": "success"}
# Return only the result string on success, as expected by some agent frameworks
return result_str
except Exception as e:
error_message = f"Unexpected error during calculation: {str(e)}"
print(error_message); traceback.print_exc()
# Return error message as string on failure
return {"error": error_message, "expression": expression}
async def run_python_code(cog: commands.Cog, code: str) -> Dict[str, Any]: