Agent: durable turn and queue state, visible inbox closure, OpenAI phase; prompt fixes; fetch/bench fixes
This commit is contained in:
+20
-3
@@ -22,7 +22,15 @@ fn main() {
|
||||
}
|
||||
```
|
||||
|
||||
Use `Inbox` for an actor that needs HTTP or timers. Enable the SDK's `async` feature. Use `wstd` for HTTP:
|
||||
Use `Inbox` for an actor that needs HTTP or timers. Add these dependencies to `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
sausage-actor = { version = "0.1", features = ["async"] }
|
||||
wstd = "0.6"
|
||||
```
|
||||
|
||||
Use `wstd` for HTTP:
|
||||
|
||||
```rust
|
||||
use sausage_actor::{Inbox, json, reply};
|
||||
@@ -38,8 +46,9 @@ fn main() {
|
||||
let url = message.body["url"].as_str().unwrap();
|
||||
let request = Request::get(url).body(Body::empty()).unwrap();
|
||||
let response = Client::new().send(request).await.unwrap();
|
||||
let text = response.into_body().str_contents().await.unwrap();
|
||||
let _ = reply(&message, json!({"type": "fetched", "text": text.to_string()}));
|
||||
let mut body = response.into_body();
|
||||
let text = body.str_contents().await.unwrap().to_string();
|
||||
let _ = reply(&message, json!({"type": "fetched", "text": text}));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -53,6 +62,14 @@ The broker tests each `tests/*.json` file before an upgrade or spawn. Each file
|
||||
|
||||
Send `{"type":"build","source":"/actor/agent/public/drafts/<name>"}` to `cargo`. Then send `spawn` or `upgrade` to `broker` with the returned WASM path and the source folder. Check the actor with a message.
|
||||
|
||||
Send broker requests with `body.type` set to the operation name. The fields are:
|
||||
- `spawn`, `upgrade`: `actor`, `wasm`, `source`, `built_by`.
|
||||
- `rollback`: `actor`, optional `version`.
|
||||
- `stop`, `start`, `remove`, `subscribe`, `unsubscribe`: `actor`.
|
||||
- `scan`, `list`: no extra fields.
|
||||
|
||||
The full contract is at `/actor/broker/public/PROTOCOL.md`.
|
||||
|
||||
## Filesystem
|
||||
|
||||
Your private state lives under `/data`. Your public files live under `/public`. Other actors' `data/` directories are hidden.
|
||||
|
||||
Reference in New Issue
Block a user