I try the code as the following code, it return me 400 error. What should I do while there is no parameters in the function?
const completion = await openai.createChatCompletion({
"model": "gpt-3.5-turbo-0613",
"messages": [
{"role": "user", "content": "What time is it now?"}
],
"functions": [
{
"name": "getNow",
"description": "Get the current time",
"parameters": null
}
]
});
should look like this for java
const completion = await openai.createChatCompletion({
model: “gpt-3.5-turbo-0613”,
messages: [
{ role: “system”, content: “You are a helpful assistant.” },
{ role: “user”, content: “What time is it now?” }
],
functions: [
{
name: “getNow”,
description: “Get the current time”,
instructions: “Please provide the current time.”,
parameters: {
time: “now”
}
}
]
});
I try later, it works now.
const completion = await openai.createChatCompletion({
"model": "gpt-3.5-turbo-0613",
"messages": [
{ "role": "user", "content": "What time is it now?" }
],
"functions": [
{
"name": "getNow",
"description": "Get the current time",
"parameters": {
"type": "object",
"properties": {
"time": {
"type": "string",
"description": "Get the current time."
},
},
"required": []
}
}
]
});
1 Like
I tried, and it doesn’t work
_j
5
I experimented with the minimum function required to pass the endpoint schema, for example, for a function that is just a “trigger” with no input.
Here’s what I came up with:
function_list=[
{
"name": "fortune_of_the_day",
"description": "Displays fortune cookie in user interface",
"parameters": {
"type": "object",
"properties": {
"dummy_property": {
"type": "null",
}
}
}
}
]
The AI then calls the function with an empty array (same token count as nothing in a function’s parenthesis):
"message": {
"role": "assistant",
"content": null,
"function_call": {
"name": "fortune_of_the_day",
"arguments": "{}"
}
}
A return status role should still be included (or the time for a time function), if you don’t want an endless loop of fortune cookies.
2 Likes
{
name: "getNow",
description:
"Get the current time.",
parameters: {
type: "object",
properties: {},
required: [],
},
}
1 Like