Skip to content

Commit

Permalink
Add fn call in response debug logging (#5301)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhoangt authored Nov 27, 2024
1 parent 1a06906 commit 9fab9ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions openhands/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
with warnings.catch_warnings():
warnings.simplefilter('ignore')
import litellm

from litellm import Message as LiteLLMMessage
from litellm import ModelInfo, PromptTokensDetails
from litellm import completion as litellm_completion
Expand Down Expand Up @@ -245,6 +246,12 @@ def wrapper(*args, **kwargs):
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 response
self.log_response(message_back)
Expand Down

0 comments on commit 9fab9ae

Please sign in to comment.