Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"function_call" attribute should be an object and not a string #383

Closed
samirkhoja opened this issue Jun 16, 2023 · 1 comment
Closed

"function_call" attribute should be an object and not a string #383

samirkhoja opened this issue Jun 16, 2023 · 1 comment

Comments

@samirkhoja
Copy link

samirkhoja commented Jun 16, 2023

I am trying to test the recent function calling feature. The OpenAI API docs around this new feature are a bit confusing. The top level field "function_call" in a chat completion request can be either a string or object according to their examples and docs. The value is defaulted to "none" when "functions" are not provided and "auto" when functions are provided. "auto" allows the model to decide whether to use a function or not. To force the model to call a function, an object needs to be passed: Ex: {"name": "<function_name>"}. Right now, I can't force the model to use a function with the current implementation.

Reference: https://platform.openai.com/docs/guides/gpt/function-calling
Examples: https://github.com/openai/openai-cookbook/blob/main/examples/How_to_call_functions_with_chat_models.ipynb

Tested using curl as well and both type of string and object are accepted. Not sure why the API is designed this way but I think it makes sense to just support an object when providing the "function_call" value since the other two values are defaulted by OpenAI and depend on "functions" being available.

Here is where the updates should happen.

https://github.com/sashabaranov/go-openai/blob/master/chat.go#LL43C1-L59C2

@samirkhoja
Copy link
Author

duplicate : #374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant