-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_agent_many.py
More file actions
49 lines (37 loc) · 1.43 KB
/
run_agent_many.py
File metadata and controls
49 lines (37 loc) · 1.43 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
#!/usr/bin/env python3
"""
Run Agent Many Example
This example demonstrates how to run an agent with multiple inputs in a batch.
"""
import os
from roe import RoeClient
# Configuration - set these environment variables
AGENT_ID = os.getenv("AGENT_ID", "your-agent-uuid-here")
def main():
# Initialize client
client = RoeClient(base_url="http://localhost:8000/api/")
# Batch inputs
# batch_inputs = [
# {"text": "The quick brown fox jumps over the lazy dog.", "task": "sentiment"},
# {"text": "I absolutely love this product!", "task": "sentiment"},
# {"text": "This is terrible and I want my money back.", "task": "sentiment"},
# {"text": "The weather is okay today.", "task": "sentiment"},
# ]
batch_inputs = [
{"text": "The quick brown fox jumps over the lazy dog."},
{"text": "I absolutely love this product!"},
{"text": "This is terrible and I want my money back."},
{"text": "The weather is okay today."},
]
# Run agent with multiple inputs
batch = client.agents.run_many(agent_id=AGENT_ID, batch_inputs=batch_inputs)
# Wait for all jobs to complete
results = batch.wait()
# Display results
print(f"Completed {len(results)} jobs:")
for i, result in enumerate(results, 1):
print(f"\nJob {i}:")
for output in result.outputs:
print(f" {output.key}: {output.value}")
if __name__ == "__main__":
main()