feat: Added example for openAI function call#475
Conversation
|
| }); | ||
|
|
||
| //Function call example for OpenAI | ||
| const createCompletion = async () => { |
There was a problem hiding this comment.
This won't work, because the key param is the same on each call. Not sure why it's necessary to do two calls to createChatCompetion?
There was a problem hiding this comment.
In the first call, openAI returns JSON which contains the function name and arguments
Example:
{'index': 0,
'message': {'role': 'assistant',
'content': None,
'function_call': {'name': 'get_n_day_weather_forecast',
'arguments': '{\n "location": "Glasgow, Scotland",\n "format": "celsius",\n "num_days": 5\n}'}},
'finish_reason': 'function_call'}
Using this we need to call our functions. and pass the result to GPT again for summarization. so we need 2 calls.
|
|
||
| //Function call example for OpenAI | ||
| const createCompletion = async () => { | ||
| const chatCompletion = await io.openai.createChatCompletion("chat-completion", { |
There was a problem hiding this comment.
We should use the new way of doing this io.openai.chats.completions.create
There was a problem hiding this comment.
I didn't understand this part @ericallam,
Do I need to use await io.openai.chats.completions.create instead of await io.openai.createChatCompletion ?
|
Thanks @ericallam
Please check and share your feedback. |
|
HI @ericallam Did you get a chance to look into this? I have made the changes. |
Added function call example in openAI.
/claim #469
/closes #469
Note:
I can't able to test the changes because I don't have an active openAI key. I consumed all of my free quota 🥺🥺