15 lines
536 B
Python
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) |