Skip to content

Commit

Permalink
Fix issue with empty function call args for Open AI (#99)
Browse files Browse the repository at this point in the history
This may just affect some Open AI compatibile providers.

See discussion in #97, the
issues there should be fixed by this.
  • Loading branch information
ahyatt authored Nov 5, 2024
1 parent dcd02c4 commit 14dbbde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.org
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Centralize model list so things like Vertex and Open AI compatible libraries can have more accurate context lengths and capabilities.
- Update default Gemini chat model to Gemini 1.5 Pro.
- Update default Claude chat model to latest Sonnet version.
- Fix issue in some Open AI compatible providers with empty function call arguments
* Version 0.17.4
- Fix problem with Open AI's =llm-chat-token-limit=.
- Fix Open AI and Gemini's parallel function calling.
Expand Down
7 changes: 5 additions & 2 deletions llm-openai.el
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ STREAMING if non-nil, turn on response streaming."
(make-llm-provider-utils-function-call
:id (assoc-default 'id call)
:name (assoc-default 'name function)
:args (json-read-from-string (assoc-default 'arguments function)))))
:args (json-read-from-string
(let ((args (assoc-default 'arguments function)))
(if (= (length args) 0) "{}" args))))))
(assoc-default 'tool_calls
(assoc-default 'message
(aref (assoc-default 'choices response) 0)))))
Expand All @@ -211,7 +213,8 @@ FCS is a list of `make-llm-provider-utils-function-call'"
`(("id" . ,(llm-provider-utils-function-call-id fc))
("type" . "function")
("function" .
(("arguments" . ,(json-encode (llm-provider-utils-function-call-args fc)))
(("arguments" . ,(json-encode
(llm-provider-utils-function-call-args fc)))
("name" . ,(llm-provider-utils-function-call-name fc))))))
fcs))))

Expand Down

1 comment on commit 14dbbde

@dto
Copy link

@dto dto commented on 14dbbde Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would appear to have fixed the problem with Openrouter tool calls :) Thanks so much for your help, gentlemen!

Please sign in to comment.