-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitial_files.rs
More file actions
61 lines (52 loc) · 1.79 KB
/
initial_files.rs
File metadata and controls
61 lines (52 loc) · 1.79 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
//! Example: create a session with initial files
//!
//! Run with:
//! `EVERRUNS_API_KEY=evr_... cargo run --example initial_files`
use everruns_sdk::{CreateSessionRequest, Error, Everruns, InitialFile};
#[tokio::main]
async fn main() -> Result<(), Error> {
let client = Everruns::from_env()?;
let agent = client
.agents()
.create(
"initial-files-example-rs",
"You are a helpful assistant. Read the starter files before answering.",
)
.await?;
let session = client
.sessions()
.create_with_options(
CreateSessionRequest::new()
.agent_id(&agent.id)
.title("Session with starter files")
.initial_files(vec![
InitialFile::new(
"/workspace/README.md",
"# Demo Project\n\nThis workspace contains starter files.\n",
)
.encoding("text")
.is_readonly(true),
InitialFile::new(
"/workspace/src/app.py",
"def greet(name: str) -> str:\n return f\"hello, {name}\"\n",
)
.encoding("text"),
]),
)
.await?;
println!("Created session {}", session.id);
println!("Starter files:");
println!(" - /workspace/README.md");
println!(" - /workspace/src/app.py");
let message = client
.messages()
.create(
&session.id,
"Summarize the project and suggest one improvement to src/app.py.",
)
.await?;
println!("Created message {}", message.id);
client.sessions().delete(&session.id).await?;
client.agents().delete(&agent.id).await?;
Ok(())
}