Chat completions of function calling

hello,

I am trying to make a call with chat completions but are unable to get the message list correctly configured. The code is written as part of a teams chat-bot using node.js and rest api calls and have enabled the function calling features of the latest API’s

The issue I am seeing is that after processing the function calls, I append the results to the message list before returning to the chat-bot. For the assistant message that asked for the function calls I add that message into the queue.

This message has a content = null, tool_calls = object and role = assistant

This fails when submitted to the rest API saying the content is required

The responses to the function calls are added after the assistant message with a role=tool, content=functionResult and tool_call_id as the id of that call

If I try set the content to some other string (even a zero length string) I don’t get an error - but the bot makes another request for the same function call and I get stuck in a loop

Any idea’s on what I might be doing wrong?

REST API I have tried are:
2024-05-01-preview
2024-06-01

I am mostly using the azure OpenAI API’s

here is an example of the content of the API call:

{
temperature: 0.2,
max_tokens: 4096,
top_p: 0,
data_sources: [
{
type: “azure_search”,
parameters: {
endpoint: “httpsss://xxxxxxxxxxxxxxx.search.windows.net”,
index_name: “xxxxx”,
in_scope: false,
top_n_documents: 3,
query_type: “vector_semantic_hybrid”,
semantic_configuration: “default”,
role_information: “You are an AI assistant that designed to assist staff”,
fields_mapping: {
content_fields: [
“content”,
],
content_fields_separator: “\n”,
filepath_field: “filepath”,
title_field: “title”,
url_field: “url”,
},
authentication: {
type: “api_key”,
key: “xxxxxxxxxxxxxxx”,
},
embedding_dependency: {
type: “deployment_name”,
deployment_name: “text-embedding-ada-002”,
},
},
},
],
tools: [
{
type: “function”,
function: {
name: “askquestion”,
description: “This function queries the core databas”,
parameters: {
type: “object”,
properties: {
settingid: {
type: “integer”,
description: “This property is required and must be set to 48”,
},
question: {
type: “string”,
description: “The question you want to ask the bot”,
},
uniquesession: {
type: “boolean”,
description: “This is required and must be set to true”,
},
},
required: [
“settingid”,
“question”,
“uniquesession”,
],
additionalProperties: false,
},
},
},
],
messages: [
{
role: “system”,
content: “You are an AI chatbot that is designed to assist developers”,
},
{
role: “user”,
content: “Show me the contents of the kWWebSession class.”,
},
{
role: “assistant”,
content: “Function call in progress”,
tool_calls: [
{
function: {
arguments: “{"settingid":48,"question":"Show me the contents of the kWWebSession class","uniquesession":true}”,
name: “askaiquestion”,
},
id: “call_gVssvwFehW654B7xQRxIfbL7”,
type: “function”,
},
],
},
{
role: “tool”,
content: “The retrieved documents do not provide the full details of the kWWebSession class itself…”,
tool_call_id: “call_gVssvwFehW654B7xQRxIfbL7”,
},
],
}