Skip to content
Discussion options

You must be logged in to vote

@epistoteles state_modifier can be a callable that takes a graph state and produces an input into the LLM, for example:

def state_modifier(state):
    system_prompt = """Today's date: {datetime.today().strftime('%Y-%m-%d')}<rest of the system prompt>"""
    return [{"role": "system", "content": system_prompt}] + state["messages"]

this actually allows passing more state variables into your prompt as well, for example if you have some state keys like user_info etc, you can pass that information to the prompt as well. NOTE: if you need to add extra state keys to create_react_agent, you'd need to also pass state_schema parameter.

hope this helps!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by epistoteles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants