ai
ai copied to clipboard
Support for Automated Function Calls
Feature Description
Open AI supports Automated Function Calls through the Chat Completion Helpers https://github.com/openai/openai-node/blob/master/helpers.md#integrate-wtih-next-js
Use Case
The goal of these is for the bot to continuously run and choose the right tool to answer allowing for agent like experience.
Support for Automated Function Calls within the tools capabilities should be included
Additional context
While this works well without experimental_data ex.
const runner = await openai.beta.chat.completions
.runTools({
model: 'gpt-4-1106-preview',
stream: true,
tools: [
zodFunction({
function: listBooks,
schema: ListParams,
description: 'List queries books by genre, and returns a list of names of books',
}),
zodFunction({
function: searchBooks,
schema: SearchParams,
description: 'Search queries books by their name and returns a list of book names and their ids',
}),
zodFunction({
function: getBook,
schema: GetParams,
description:
"Get returns a book's detailed information based on the id of the book. Note that this does not accept names, and only IDs, which you can get by using search.",
}),
],
messages: [
{
role: 'system',
content:
`Please use our book database, which you can access using functions to answer the following questions.
The answer should be a JSON result object
`,
},
...messages,
],
response_format: { "type": "json_object" }
})
runner.on('end', async () => {
});
return new StreamingTextResponse(runner.toReadableStream());
it doesn't work with stream_data (coz it's no longer parsed correctly) and there is no way to pass back the on... Ideally for this to be complete it would need a way to stream back the .on events .on('message', (msg) => console.log('msg', msg)) .on('functionCall', (functionCall) => console.log('functionCall', functionCall)) .on('functionCallResult', (functionCallResult) => console.log('functionCallResult', functionCallResult)) etc...