Is 'functions' parameter not supported?
Problem
Describe the bug I'm trying to use the functions parameter to help force JSON response. Is this not supported? To Reproduce Call createChatCompletion with 'functions' array. Code snippets [code block] Results in the error: [code block] ``` OS macOS Node version 18.7.0 Library version 3.3.0
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Update API Call to Support Functions Parameter
The 'functions' parameter may not be supported in the current version of the OpenAI API you are using (3.3.0). This could be due to either the API version not implementing this feature or incorrect usage in your code. Ensure that you are using a version of the API that supports the 'functions' parameter.
Awaiting Verification
Be the first to verify this fix
- 1
Check API Documentation
Review the OpenAI API documentation to confirm that the 'functions' parameter is supported in the version you are using. If it is not mentioned, you may need to upgrade to a newer version.
- 2
Upgrade OpenAI Library
If the 'functions' parameter is supported in a later version, upgrade your OpenAI library to the latest version using npm. This can be done by running the following command in your terminal.
bashnpm install openai@latest - 3
Modify API Call
Ensure that your API call correctly includes the 'functions' parameter as per the latest API specifications. Here is an example of how to structure the call.
typescriptconst response = await openai.createChatCompletion({ model: 'gpt-3.5-turbo', functions: [{ name: 'functionName', description: 'Function description' }], ...otherParams }); - 4
Test the API Call
Run your application again to test if the API call with the 'functions' parameter works as expected. Monitor for any errors or unexpected behavior.
Validation
Confirm that the API call executes successfully without errors and that the response includes the expected JSON format. You can log the response to verify its structure.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep