#OpenAI returns date variables instead of text (using Python openAI library)

12 messages · Page 1 of 1 (latest)

ripe narwhal
#

Hello everyone, I just started using the API and I'm messing around with things, I made a simple code in Python using the openai and a ChatCompletion object using gpt-3.5-turbo as a model. Everthing works great but sometimes OpenAI just gives me variables instead of the value. The strange thing is I tell it my name then it calls me by my name correctly, but dates show up like this:

"choices": [ { "finish_reason": "stop", "index": 0, "message": { "content": "Today's date is {{ date('now', 'Europe/Lisbon').strftime('%A, %d de %B de %Y') }}, according to the timezone of Portugal.", "role": "assistant" } } ]

Anyone have any idea why? Is it just a bug?

tranquil fable
#

How are you providing the date to it?

#

ChatGPT for example uses this prompt

["You are ChatGPT, a large language model trained by OpenAI, based on the GPT-4 architecture.\nKnowledge cutoff: 2021-09\nCurrent date: 2023-04-21"]

#

With the API, though, it doesn't get that prompt so you need to provide any date/time info you want it to know about.

pine flame
#

@ripe narwhal ⬆️

ripe narwhal
#

I didn't realize I would have to give it the time in the prompt in order for it to print it back to me. I've done that but it still doesn't seem to work properly

#
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "Certainly! Based on the information you provided previously, you're in the Lisbon time zone and the current date and time in Lisbon is:\nPlease note that the date and time may be different depending on your actual location and time zone changes.",
        "role": "assistant"
      }
    }
  ],
#

in this case it didn't even give a date at all

tranquil fable
#

Here is how my assistant is coded, maybe it will help you

ripe narwhal
#

It did, I wasn't aware of the system role. I think I'll manage now, many thanks! ✌🏻