Files
task-69b06a202a32e307dd6e40b9/main.py
T
2026-06-11 14:45:12 +00:00

15 lines
536 B
Python

from langchain_ollama import ChatOllama
from langchain.agents import create_agent
# Initialize the LLM (using a local Ollama model)
llm = ChatOllama(model="llama3")
# No external tools needed for this simple greeting agent
tools = []
# Create the agent using the modern API
agent = create_agent(model=llm, tools=tools)
# Invoke the agent with a user message asking for a greeting
response = agent.invoke({"messages": [{"role": "user", "content": "Hello"}]})
print(response["output_text"] if isinstance(response, dict) else response)