Why ChatGPT by API doesn't know today's date?

Hello, I am currently developing an AI calendar which is a widget based on ChatGPT.

My problem is simple. When I ask for the date on chatgpt directly it gives me today’s date without any problem. When I make an API call, it is unable to give me today’s date.

My question is simple. Why and how can I solve that ??

Thanks in advance. Looking forward to reading you.

Welcome to the forum.

You could likely use a Function call that would query the date/time on your system then return it in natural language.

You have to supply the date and other relevant information yourself before the AI can make use of it. I recommend putting the date in the system prompt.

2 Likes

AI Like Chat GPT is made out of Data. It is like a machine studying the data, once that machine studied the data, it will go to the market as a model.

This is why GPT does not know the date. Because it is based on data he has previously seen

There’s no need for a “function call” for a date - although dealing with dates you will find it beneficial to add some functions that can compute or display calendars, because the AI won’t do a good job of querying for a question of “got any available appointments next tuesday?”.

Instead, I’d recommend two system prompt dates to keep the AI straight, because a system prompt that appears earlier than later chat exchanges can also serve to confuse the understanding of what’s going on if you provide the precision of time: “Conversation session start time” AND “current time”.

3 Likes

Note I said you “could” not you “should”… :wink:

Concur with the other answers that just inserting it into prompt from your system is better and it should be able to recall it when requested. Does use a bit more tokens, but the cost is dropping all the time.

1 Like

This is the method I used and it works perfectly. Thanks for your help

Of course, my question is how OpenAI solves this problem on native ChatGPT but not on their API. And how I can fix that

Exact, works perfectly, thanks for your help :slight_smile:

1 Like

Ohh, now I understand. If you are using the api in a programming setup, you can just send the current date using the libraries from the programming language. If I may help, please tell me what you are using!

I can get the Unix Epoch time, when I request it.

Also you can fetch the timezone (it’s Zulu time, or default to zero / 0).

See request : Unix Epoch Date Request

Knowing this, you can use it as a “default” and do the math for your API yourself.

I am working with the assistant api. And had the best results with a function call that the assistant can use to request the time. Because assistants don’t have system prompt to my knowledge, and I still am debating your approach using prompts with session and current time. I was wondering if you have any success with such an approach for assistants?

Yes, as noted, in ChatGPT we have a system that takes todays date and adds it to the system prompt. You can do the same!