Skip to content

How to make the bot aware of current date and time? #2863

@hugokoopmans

Description

@hugokoopmans

In my usecase i want the bot to be aware of the current date and time.

How can i best do this ?

I have added current_date to app.py in /ask and /chat routes like so

# hk add date to context context["current_datetime"] = datetime.now().isoformat() # Add current_datetime to overrides if "overrides" not in context: context["overrides"] = {} context["overrides"]["current_datetime"] = context["current_datetime"]

then i added the overrides to the prompt_mnager in chatreadretrieveread.py like so

' query_messages = self.prompt_manager.render_prompt(
self.query_rewrite_prompt, {"user_query": original_user_query,
"past_messages": messages[:-1],
**overrides, # include all override/context variables, such as current_datetime
}
)'

please advise, this seems very cumbersome?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions