π OpenHands: AI-Driven Development
Add fn call in response debug logging (#5301)
Ryan H. Tran9fab9ae8a6f7
diff --git a/openhands/llm/llm.py b/openhands/llm/llm.pyindex 2ed9732e1e..49f8df364f 100644--- a/openhands/llm/llm.py+++ b/openhands/llm/llm.py@@ -12,6 +12,7 @@ from openhands.core.config import LLMConfigwith warnings.catch_warnings():warnings.simplefilter('ignore')import litellm+from litellm import Message as LiteLLMMessagefrom litellm import ModelInfo, PromptTokensDetailsfrom litellm import completion as litellm_completion@@ -245,6 +246,12 @@ class LLM(RetryMixin, DebugMixin):f.write(json.dumps(_d))message_back: str = resp['choices'][0]['message']['content']+ tool_calls = resp['choices'][0]['message'].get('tool_calls', [])+ if tool_calls:+ for tool_call in tool_calls:+ fn_name = tool_call.function.name+ fn_args = tool_call.function.arguments+ message_back += f'\nFunction call: {fn_name}({fn_args})'# log the LLM responseself.log_response(message_back)