summaryrefslogtreecommitdiff
path: root/client.py
blob: 438f1fbbc91d1878dfb1b9c3a81d12182db386d2 (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from agent import Agent
from identity import load_agent_identity, load_user_profile
from llm import LLM
from tools import (
    CalculatorTool,
    FileSystemListTool,
    FileSystemReadTool,
    HelloTool,
    ToolRegistry,
    WeatherTool,
)

llm = LLM(
    "http://localhost:8080/v1/chat/completions",
)

agent_identity = load_agent_identity("agent.toml")
user_profile = load_user_profile("user.toml")

tools = ToolRegistry()
tools.register(HelloTool())
tools.register(CalculatorTool())
tools.register(WeatherTool())
tools.register(FileSystemListTool())
tools.register(FileSystemReadTool())

agent = Agent(
    llm,
    agent_identity,
    user_profile,
    tools,
)

while True:
    user_input = input("You: ")

    if user_input.lower() in {"exit", "quit"}:
        break

    match user_input:
        case "/end":
            agent.end_task()
            print("[task ended]")
            continue

        case "/task":
            print(f"\n[memory: {agent.working_memory}]\n")
            continue

        case "/pause":
            agent.pause_task()
            print("[task paused]")
            continue

        case "/resume":
            agent.resume_task()
            print("[task resumed]")
            continue

        case "/complete":
            agent.complete_task()
            print("[task completed]")
            continue

    answer = agent.chat(user_input)
    print(f"Agent: {answer}")