File size: 1,077 Bytes
9fced79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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")