I put in whatever the user says I need and it just responds with the date and time.
For example my user says: twenty-third of November so API needs to return 23-11-2023 response.
Or my user says: eleven twenty AM so the API needs to return an 11:20AM response.
So let me know how it possible in OpenAI API.
Hi and welcome to the Developer Forum!
Just ask for the date to be returned in “ISO Date Format” and you will always get the ISO formatted date, you may need to experiment with your prompting to get the format you require, or make use of the Functions ability of the API.
Thank for reply. Which model should I use for this?
That is a single task that should be easily completed by the
gpt-3.5-turbo-instruct model (which uses the completion endpoint.
ISO date format is not the date format you indicate. You’d want to prompt the AI:
The current date is Oct 31 2023. From the following text, extract the date, in the format DD-MM-YYYY: “(your text)”\n\n
The \n are linefeeds in your programming language. I add today’s year so the AI can infer the year of the input.
You can also tell the AI if the date is expected to be in the future or the past.