-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_agent.py
More file actions
57 lines (39 loc) · 1.62 KB
/
Copy pathtest_agent.py
File metadata and controls
57 lines (39 loc) · 1.62 KB
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
# test for agent.py
from my_mono.tracing import setup; setup() # OTel aktivated
import asyncio
import logging
import colorama
from colorama import Fore, Style
from my_mono.agent import Agent, AgentOptions, UserMessage
from my_mono.tools import create_read_only_tools
from my_mono.test_helper import setup_logger
from my_mono.tracing import tracer
colorama.init()
# ─── SETUP ────────────────────────────────────────────
logging.basicConfig(level=logging.WARNING)
setup_logger("my_mono.agent")
MODEL_NAME = "gemma4"
tools = create_read_only_tools(cwd=".")
agent = Agent(AgentOptions(
model=MODEL_NAME,
system_prompt="You are a helpful assistant.",
tools=tools,
))
# ─── EVENT LISTENER ─────────────────────────────────────────
def on_event(event):
match event.type:
case "message_end":
print(Fore.BLUE + (event.payload.content or "") + Style.RESET_ALL,
end="", flush=True)
case "agent_end":
print()
agent.subscribe(on_event)
# ─── TESTS ──────────────────────────────────────────────────
@tracer.agent(name="test_agent")
async def main():
print("=" * 50)
print("Test: List and read a file")
print("=" * 50)
await agent.prompt(UserMessage(content="List the current directory and read the README.md if it exists."))
if __name__ == "__main__":
asyncio.run(main())