Spaces:
Runtime error
Runtime error
File size: 713 Bytes
e8eed08 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import os
from langchain_core.messages import HumanMessage, AIMessage
from dotenv import load_dotenv
from langchain_google_genai import ChatGoogleGenerativeAI
load_dotenv()
# Memory is handled by passing a list of messages back and forth
chat_history = [
HumanMessage(content="My name is Dnyan."),
AIMessage(content="Nice to meet you, Dnyan! How can I assist with your emails?")
]
# The agent now 'remembers' the context
follow_up = "What is my name and can you draft a thank you note?"
llm = ChatGoogleGenerativeAI(model="gemini-2.5-flash")
response = llm.invoke(chat_history + [HumanMessage(content=follow_up)])
print(response.content)
# The agent will correctly identify your name from the history |