I have found a way to add System Message in Langgraph in this link.
However, I feel that there would be a better way to do this, since this is the most common usecase.
Would like to know how can this be achieved?
I have found a way to add System Message in Langgraph in this link.
However, I feel that there would be a better way to do this, since this is the most common usecase.
Would like to know how can this be achieved?
Hi @dhirajsuvarna ! Are you trying to add a System Message at runtime? In that case that would be the correct way
Otherwise you could define your system prompt somewhere in your project (could be outside of the node, LangSmith Prompt Hub etc) and invoke your model like
system_prompt = """
You are a helpful assistant.
"""
def my_node(state: State):
...
response = llm.invoke([SystemMessage(system_prompt)] + state["messages"])
Example to manage the list of messages.
Let me know if it helped!