Spaces:
Runtime error
Runtime error
from langgraph import Tool, Memory, Agent | |
from langgraph.tools import WebSearchTool, CalculatorTool | |
# Define tools the agent can use | |
tools = [ | |
WebSearchTool(name="web_search", | |
description="Useful for searching the web"), | |
CalculatorTool(name="calculator", | |
description="Useful for arithmetic calculations") | |
] | |
# Set up simple memory (e.g., conversation history) | |
memory = Memory(max_tokens=500) | |
# Create the agent with reasoning and action capabilities | |
agent = Agent( | |
name="SimpleReasoningAgent", | |
tools=tools, | |
memory=memory, | |
reasoning_chain="explicit", # use explicit chain-of-thought | |
action_threshold=0.7 # confidence threshold to trigger actions | |
) | |
if __name__ == "__main__": | |
print("Welcome to SimpleReasoningAgent! Type 'exit' to quit.") | |
while True: | |
user_input = input("\nUser: ") | |
if user_input.lower() in ("exit", "quit"): | |
print("Goodbye!") | |
break | |
# Agent processes input | |
response = agent.run(user_input) | |
print(f"Agent: {response}\n") | |