Skip to content

Commit

Permalink
print an error message when a function call generates an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenfreund committed May 24, 2024
1 parent 8ce4b48 commit 24ed5d8
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/chatdbg/assistant/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,12 @@ def _make_call(self, tool_call) -> str:
call, result = function["function"](**args)
result = remove_non_printable_chars(strip_ansi(result).expandtabs())
self._broadcast("on_function_call", call, result)
except OSError as e:
# function produced some error -- move this to client???
# likely to be an exception from the code we ran, not a bug...
result = f"Error: {e}"
except KeyboardInterrupt as e:
raise e
except Exception as e:
# likely to be an exception from the code we ran, not a bug...
result = f"Ill-formed function call: {e}"
result = f"Exception in function call: {e}"
self._broadcast("on_warn", result)
return result

def _batch_query(self, prompt: str, user_text):
Expand Down

0 comments on commit 24ed5d8

Please sign in to comment.