messages = [ SystemMessage( content="You are a helpful assistant that answers general knowledge questions." ), HumanMessage(content="What is the capital of France?"),]chat.invoke(messages)
Copy
Ask AI
AIMessage(content=[{'role': 'human', 'text': 'What is the capital of France?'}, {'role': 'assistant', 'text': 'The capital of France is Paris.'}])
from langchain_core.prompts import ChatPromptTemplateprompt = ChatPromptTemplate.from_template("Tell me a joke about {topic}")chain = prompt | chat
Copy
Ask AI
chain.invoke({"topic": "cows"})
Copy
Ask AI
AIMessage(content=[{'role': 'human', 'text': 'Tell me a joke about cows'}, {'role': 'assistant', 'text': "Sure, here's a joke about cows:\n\nWhy did the cow cross the road?\n\nTo get to the udder side!"}])