-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (52 loc) · 2.03 KB
/
Copy pathmain.py
File metadata and controls
63 lines (52 loc) · 2.03 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
58
59
60
61
62
63
import os
from orchestrator import SelfImprovingOrchestrator
from regression_runner import RegressionRunner, TestCase
os.environ["OPENAI_API_KEY"] = "your-key-here"
def seed_test_cases():
"""Pre-load test cases for tools we expect the agent to create."""
runner = RegressionRunner()
runner.store_test_case("fetch_exchange_rate", TestCase(
input_args={"from_currency": "USD", "to_currency": "EUR"},
expected_type="float",
max_latency_ms=3000,
description="USD to EUR returns a float",
))
runner.store_test_case("fetch_exchange_rate", TestCase(
input_args={"from_currency": "USD", "to_currency": "ILS"},
expected_type="float",
max_latency_ms=3000,
description="USD to ILS returns a float",
))
runner.store_test_case("convert_currency", TestCase(
input_args={"amount": 100.0, "rate": 3.5},
expected_type="float",
max_latency_ms=100,
description="Simple multiplication returns float",
))
def main():
seed_test_cases()
agent = SelfImprovingOrchestrator()
tasks = [
"What is the current USD to ILS exchange rate? Convert 5000 USD.",
"What is the current EUR to GBP rate? Convert 2000 EUR.",
"Convert 10000 JPY to USD using the latest rate.",
]
for task in tasks:
result = agent.run(task)
print(f"\n Result: {result}\n")
print("-" * 60)
# Print final performance report
print("\n" + "=" * 60)
print("PERFORMANCE REPORT")
print("=" * 60)
from performance_memory import memory
for tool_name in ["fetch_exchange_rate", "convert_currency"]:
summary = memory.summary(tool_name)
if summary["invocations"] > 0:
print(f"\n{tool_name}:")
print(f" Invocations: {summary['invocations']}")
print(f" Success rate: {summary['success_rate']:.1%}")
print(f" Avg latency: {summary['avg_latency_ms']:.0f}ms")
print(f" Version: v{summary['current_version']}")
if __name__ == "__main__":
main()