Function calling returning values when no arguments included in message

The below function is always called when a question such as: “when can i join? or how many days ?”, it is giving a current date value: {‘role’: ‘assistant’, ‘content’: None, ‘function_call’: {‘name’: ‘get_n_days’, ‘arguments’: ‘{\n “date”: “2023-07-28”\n}’}}. However, it should return the answer of this question from the Q&A that i provided in the prompt.
I try to change in the description of the function multiple times but it gave me same result. So, is there any way to prevent such issue to occur?
I am using GPT 3.5

messages.append({“role”: “system”, “content”: “Today is Friday, 2023-7-28. Don’t use function if the user ask a question and strictly use the function only for getting
dates.”})

functions = [
{
“name”: “get_n_days”,
“description”: " get the date",
“parameters”: {
“type”: “object”,
“properties”: {

            "date": {
                "type": "string",
                "description": " Date in the format: 'yyyy-mm-dd'",
            }
        },
        "required": ["date"]
    },
}

]

I’m glad to try to help you here.

First, the system role with instructions will have more power if it is the first message and all operational parameters are contained within. Not randomly appended. Try always inserting it as the first role message before then chat history and then the latest input when you send your list of messages.

Secondly, I’m unclear why you’d need a date function when you just told the AI the date.

It looks like it is supposed to provide the date to the function, but why, and what’s on the other end? You should make this clear.

Functions are typically there to assist the AI in answering a user’s question.

Is AI supposed to request the function when AI needs to obtain some kind of calculation? You don’t say what kind of calculation or operation the function does, and how that function would help the AI answer particular questions.

A function description that would be clear:

“name”: “day_of_week”,
“description”: “Calculates the name of the day of the week (example: “Wednesday”) when provided a calendar date.”

Here’s an example function for those that would write a chat assistant that needs to schedule appointments but can’t understand the calendar:

“name”: “get_monthly_calendar”
“description”: “returns a graphical calendar of the whole month containing a particular date, so AI can understand the month’s days of the week”

@_j thank you for your help, but I already try to specify its role in previous test. However, it gave me same issue. Is the issue due to the fact that questions are related to the purpose of the function (when can i join? or how many days ?)?
“description”: "calculate the number of days from the current date to a specific future date. This calculation can be used to determine the time remaining until a user can join our company. "

I was saying that if you are adding a date and some more instructions, don’t inject it as a new system role. Simply add it to the text of the first and only system prompt. If that’s your only system prompt, it should tell the AI more what type of chatbot it is and its purpose.

Your new description for a function looks better. However it only asks for one date, which is unclear.

The AI is smart enough to figure out when to use a useful calculation utility that you provide:

function_list=[
{
"name": "days_between_dates",
"description": "Calculate how many days between two dates, because AI math is unreliable",
"parameters": {
	"type": "object",
	"properties": {
		"start date": {
			"type": "string",
			"description": "the earlier date, input format: yyyy-mm-dd"
			}
		"end date": {
			"type": "string",
			"description": "format: yyyy-mm-dd"
			}
		}
	}
}
]