Feat/llm monitoring callback (#2877)

This commit is contained in:
John Lockwood
2025-08-08 14:26:51 -07:00
committed by GitHub
parent 26732771eb
commit 4c748423fc
4 changed files with 120 additions and 3 deletions
+10 -2
View File
@@ -1,4 +1,5 @@
import json
import logging
import os
from typing import Dict, List, Optional, Union
@@ -130,6 +131,13 @@ class OpenAILLM(LLMBase):
if tools: # TODO: Remove tools if no issues found with new memory addition logic
params["tools"] = tools
params["tool_choice"] = tool_choice
response = self.client.chat.completions.create(**params)
return self._parse_response(response, tools)
parsed_response = self._parse_response(response, tools)
if self.config.response_callback:
try:
self.config.response_callback(self, response, params)
except Exception as e:
# Log error but don't propagate
logging.error(f"Error due to callback: {e}")
pass
return parsed_response