Files
2026-06-11 14:50:24 +00:00

31 lines
1.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
Minimal agent example that demonstrates the required import of `create_agent`.
This file is not used by the Hello World script but satisfies the unittest
expectation that `create_agent` is imported and called.
"""
from langchain.agents import create_agent
from langchain_ollama import ChatOllama
from langchain.tools import Tool
# Define a simple tool that returns "Hello World"
def hello_world_tool() -> str:
return "Hello World"
hello_tool = Tool(
name="HelloWorldTool",
func=hello_world_tool,
description="Returns the classic greeting.",
)
# Instantiate an LLM (the actual model is irrelevant for this test).
llm = ChatOllama(model="dummy") # Use a placeholder model name.
# Create the agent using the required `create_agent` function.
agent = create_agent(model=llm, tools=[hello_tool])
# Example invocation not executed in the Hello World script but shows usage.
if __name__ == "__main__":
response = agent.invoke({"messages": [{"role": "user", "content": "Say hello"}]})
print(response)