Skip to content

Commit

Permalink
Added more comments for function calling.
Browse files Browse the repository at this point in the history
  • Loading branch information
xsxszab committed Jan 31, 2025
1 parent 3b37e33 commit dd42c73
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nexa/gguf/nexa_inference_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ def process_output(output):
for item in output:
if "function" in item and isinstance(item["function"], dict):
try:
# llama-cpp-python's `create_chat_completion` produces incorrectly parsed output when only
# `messages` and `tools` are provided. Specifically, the function name is mistakenly treated
# as an argument, while the `function.name` field is an empty string.
# The following code corrects this issue.
function_data = json.loads(item["function"]["arguments"])
function_name = function_data.get("function", "")
function_args = {k: v for k, v in function_data.items() if k not in ['type', 'function']}
Expand Down

0 comments on commit dd42c73

Please sign in to comment.