-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitial_files.py
More file actions
57 lines (45 loc) · 1.66 KB
/
initial_files.py
File metadata and controls
57 lines (45 loc) · 1.66 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
"""Example: create a session with initial files.
Run with:
EVERRUNS_API_KEY=evr_... uv run python examples/initial_files.py
"""
import asyncio
from everruns_sdk import Everruns, InitialFile
async def main():
client = Everruns()
try:
agent = await client.agents.create(
name="Initial Files Example",
system_prompt=("You are a helpful assistant. Read the starter files before answering."),
)
session = await client.sessions.create(
agent_id=agent.id,
title="Session with starter files",
initial_files=[
InitialFile(
path="/workspace/README.md",
content="# Demo Project\n\nThis workspace contains starter files.\n",
encoding="text",
is_readonly=True,
),
InitialFile(
path="/workspace/src/app.py",
content='def greet(name: str) -> str:\n return f"hello, {name}"\n',
encoding="text",
),
],
)
print(f"Created session {session.id}")
print("Starter files:")
print(" - /workspace/README.md")
print(" - /workspace/src/app.py")
message = await client.messages.create(
session_id=session.id,
text="Summarize the project and suggest one improvement to src/app.py.",
)
print(f"Created message {message.id}")
await client.sessions.delete(session.id)
await client.agents.delete(agent.id)
finally:
await client.close()
if __name__ == "__main__":
asyncio.run(main())