Skip to content

Commit

Permalink
fix: Catch bad LLM function call
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Feb 22, 2024
1 parent b5123da commit 737566f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion models/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,14 @@ async def execute_function(self, plugins: object) -> str:

logger = build_logger(__name__)
name = self.function_name
args = json.loads(self.function_arguments)

try:
args = json.loads(self.function_arguments)
except json.JSONDecodeError:
logger.warn(
f"Error decoding JSON args for function {name}: {self.function_arguments}"
)
return f"Bad JSON format, impossible to execute function {name}"

try:
res = await getattr(plugins, name)(**args)
Expand Down

0 comments on commit 737566f

Please sign in to comment.