Hello @inventing2022 ,
I would need more information. Anyway, I tried to do some tests.
Using your function definition and a prompt like “some test to print
” the result was:
function call: yes
function name: print_text
function args: {
"body": "This is a test message."
}
But the arg "body":
is different from user prompt. So I added a system message like “Your task is to always return text delimited by three hash as function argument
” and I used a prompt like “###Whiskers of snow, purrs bring joy and quiet solace.###
”. Using your function definition, the result was:
function call: yes
function name: print_text
function args: {
"body": "Whiskers of snow, purrs bring joy and quiet solace."
}
So, a first advice could be to use a system message. This help the model to better understand the task.
But what differ from my tests and your function definition is the definition itself. Beginning from November, older function definition are deprecated. The payload structure is changed. Now functions are array of tools
.
The following is my working JSON
payload. Try to print your payload and compare if there are any difference:
{
"response_format": {
"type": "text"
},
"tools": [
{
"function": {
"parameters": {
"type": "object",
"properties": {
"body": {
"description": "The text to print.",
"type": "string"
}
}
},
"name": "print_text",
"description": "Prints text using a printer."
},
"type": "function"
}
],
"messages": [
{
"role": "system",
"content": "Your task is to always return text delimited by three hash as function argument"
},
{
"role": "user",
"content": "###Whiskers of snow, purrs bring joy and quiet solace.###"
}
],
"model": "gpt-3.5-turbo",
"tool_choice": "auto",
"temperature": 0,
"top_p": 1,
"presence_penalty": 0,
"frequency_penalty": 0,
"n": 1,
"max_tokens": 1000,
"stream": false,
"logprobs": false
}
Here some documentation about tools
API: https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools