How can i make a function for assistant to detect a season?

In my assistant integration i want the assistant to know what season is it now.
By default it doesn’t know. I need it to know if it is Winter or Summer etc. now .
How can i do this?
Maybe somehow with the assistant function. But how to do this?
Maybe there is some existent function to return a date?

I tried to send information abut current month as a “system” message to assistant thread. Bt it doesn’t work. Assistant thread accepts only “user” messages, no “system” role is supported.
My assistant is created once and instructions are provided once. I do not plan to update it.

So, i need somehow to allow the assistant to know what is current month and season

Simple, you can insert custom instructions on every Run, and it will replace the Assistant instructions with the fresh Run Instructions

(works the same for files)

So, in the new instructions you can include the current Season, Day, and even Time.

Whereas it’s the only solution that’s out there I’m really against their Custom instruction that overrides the assistant. There’s no sense in having the Assistant in the first because of this feature of overriding.

The logic OpenAi had is Assistant is like the Company Computer and the threads are the clients. Why the hell will a thread custom instruction override the Assistant Instruction? So I should mention all the clients and who they are in the Assistant???

What’s that Assistant for? The threads literally have everything it has. Why should we tie the threads to an Assistant every time we make a run?

That overriding just makes me boil in anger. There’s literally no way to give a context about the user using a given thread and the only option has been to oveeride a Company Structure instruction. What a mess

1 Like

Yes, its a big issue, the initial Assistant instructions are useless, since you need to rewrite the instructions on every run.

Honestly im coming back to the normal chat completions.

The new assistants api is not working as expected, also you dont really have real control over the full conversation, some times the assistants responds twice, for no reason.

One important thing that you can do with completions is to encrypt personal data, so the real conversation is slightly different to the api conversation, now you cant, since the API reads the conversation from its own database.

Another big issue is that you dont really have control over threads, you cant list them

1 Like

You need to get the previous instruction and append the date then set it back.

const assistant = await openai.beta.assistants.retrieve(process.env.OPENAI_ASSISTANT_ID)
const assistant_instructions = assistant.instructions

const thread = await openai.beta.threads.create()

const message = await openai.beta.threads.messages.create(, { role: 'user', content: 'message' })

const run = await openai.beta.threads.runs.create(, { 
                instructions: assistant_instructions + `\nToday is ${new Date()}.`

The problem with trying to get the season with just using date is, you do not know the place of the user. Although it might be winter right now in Northern Hemisphere but not for those in New Zealand. So you probably need some API service.

Function call can work, but that means the user must ask about it or the AI must determine the function to be necessary.

To answer “how can I make”. The answer is a dozen turns correcting GPT-4 and looking up stuff on the internet.

import datetime

def get_season(date_str: str = None) -> str:
    Determine the season for a given date. With time precision, times are Eastern time, USA

    date_str (str): The date as a string in the format 'YYYY-MM-DD HH:MM'. 
                    If no date is provided, the current date and time is used.
    str: The season for the given date. One of 'spring', 'summer', 'autumn', 'winter'.
    ValueError: If the year of the date is not between 2023 and 2026.
    seasons = {
        2023: {"spring": "03-20 21:24", "summer": "06-21 05:57", "autumn": "09-23 02:50", "winter": "12-21 16:27"}, # not accurate
        2024: {"spring": "03-19 23:06", "summer": "06-20 16:51", "autumn": "09-22 08:44", "winter": "12-21 04:21"},
        2025: {"spring": "03-20 05:01", "summer": "06-20 22:42", "autumn": "09-22 14:19", "winter": "12-21 10:03"},
        2026: {"spring": "03-20 10:46", "summer": "06-21 04:24", "autumn": "09-22 20:05", "winter": "12-21 15:50"},

    if date_str is None:
        date =
        if len(date_str) == 10:  # if only date is provided, append '12:00'
            date_str += ' 12:00'
        date = datetime.datetime.strptime(date_str, '%Y-%m-%d %H:%M')

    if not 2023 <= date.year <= 2026:
        raise ValueError("Year must be between 2023 and 2026")

    for season, start_date in seasons[date.year].items():
        if date >= datetime.datetime.strptime(f"{date.year}-{start_date}", '%Y-%m-%d %H:%M'):
            return season

    return "winter"  # default to winter if no other seasons match

if __name__ == "__main__":

Putting it into a real system prompt along with the date is less tokens than any function definition.