Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicovank committed Mar 20, 2024
1 parent dfa632c commit 5f765d7
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/chatdbg/assistant/lite_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,20 @@ def run(

if choice.finish_reason == "tool_calls":
responses = []
for tool_call in choice.message.tool_calls:
try:
try:
for tool_call in choice.message.tool_calls:
function_response = self._make_call(tool_call)
except Exception as e:
function_response = f"Error: {e}"
response = {
"tool_call_id": tool_call.id,
"role": "tool",
"name": tool_call.function.name,
"content": function_response,
}
responses.append(response)
self._print_message(response, 4, append_message)
response = {
"tool_call_id": tool_call.id,
"role": "tool",
"name": tool_call.function.name,
"content": function_response,
}
responses.append(response)
self._print_message(response, 4, append_message)
except Exception as e:
# Warning: potential infinite loop.
append_warning(f"error processing tool calls.")
self._conversation.append(choice.message)
self._conversation.extend(responses)
elif choice.finish_reason == "stop":
Expand Down

0 comments on commit 5f765d7

Please sign in to comment.