-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.py
More file actions
62 lines (50 loc) · 1.98 KB
/
basic.py
File metadata and controls
62 lines (50 loc) · 1.98 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
"""Basic example of using the Everruns SDK."""
import asyncio
from everruns_sdk import AgentCapabilityConfig, Everruns, generate_harness_id
async def main():
# Initialize client from environment
client = Everruns()
try:
# Create an agent with current_time capability
agent = await client.agents.create(
name="Example Assistant",
system_prompt="You are a helpful assistant for examples.",
capabilities=[AgentCapabilityConfig(ref="current_time")],
)
print("Created agent:")
print(f" Name: {agent.name}")
print(f" ID: {agent.id}")
print(f" Status: {agent.status}")
print(f" Capabilities: {agent.capabilities}")
print(f" Created: {agent.created_at}")
# Create a session with a harness (agent is optional)
harness_id = generate_harness_id()
session = await client.sessions.create(
harness_id,
agent_id=agent.id,
capabilities=[AgentCapabilityConfig(ref="current_time")],
)
print("Created session:")
print(f" ID: {session.id}")
print(f" Harness: {session.harness_id}")
print(f" Agent: {session.agent_id}")
print(f" Status: {session.status}")
print(f" Created: {session.created_at}")
# Send a message that uses the current_time capability
message = await client.messages.create(
session_id=session.id,
text="What time is it right now? Generate a short joke about the current time.",
)
print(f"Sent message: {message.id}")
# Stream events
async for event in client.events.stream(session.id):
print(f"Event: {event.type}")
if event.type == "turn.completed":
break
# Clean up
await client.sessions.delete(session.id)
await client.agents.delete(agent.id)
finally:
await client.close()
if __name__ == "__main__":
asyncio.run(main())