pub fn agent(spec: &str) -> AxResult<AxAgent>Examples found in repository?
examples/runtime_adapter.rs (line 59)
57fn main() -> AxResult<()> {
58 let mut runtime = DemoRuntime;
59 let mut runner = agent("question:string -> answer:string")?;
60 let step = runner.execute_actor_step(
61 &mut runtime,
62 "final()",
63 json!({"question": "adapter"}),
64 json!({}),
65 )?;
66 let snapshot = runner.export_session_state()?;
67 let timeout = runner.execute_actor_step(
68 &mut runtime,
69 "timeout()",
70 json!({"question": "adapter"}),
71 json!({}),
72 )?;
73 let closed = runner.close_runtime_session()?;
74 println!(
75 "{}",
76 serde_json::to_string_pretty(&json!({
77 "stepKind": step.payload["kind"],
78 "snapshotAnswer": snapshot["bindings"]["answer"],
79 "timeoutCategory": timeout.payload["error_category"],
80 "closed": closed
81 }))?
82 );
83 Ok(())
84}More examples
examples/runtime_protocol.rs (line 13)
5fn main() -> AxResult<()> {
6 let repo_root = env::var("AXIR_REPO_ROOT")
7 .map_err(|_| axllm::AxError::runtime("AXIR_REPO_ROOT is required"))?;
8 let server = env::var("AXIR_AXJS_RUNTIME_SERVER")
9 .map_err(|_| axllm::AxError::runtime("AXIR_AXJS_RUNTIME_SERVER is required"))?;
10 let mut runtime =
11 ProcessCodeRuntime::new(["node".to_string(), "--import=tsx".to_string(), server]);
12 env::set_current_dir(repo_root).map_err(axllm::AxError::from)?;
13 let mut runner = agent("question:string -> answer:string")?;
14 let step = runner.execute_actor_step(
15 &mut runtime,
16 "answer = inputs.question; await final({ answer })",
17 json!({"question": "protocol"}),
18 json!({}),
19 )?;
20 assert_eq!(step.payload["kind"], "final");
21 runtime.shutdown()?;
22 println!("rust-runtime-protocol-ok");
23 Ok(())
24}