pub struct Pack {
pub id: PackId,
pub name: String,
pub version: String,
pub object_types: BTreeMap<String, ObjectType>,
pub relation_types: BTreeMap<String, RelationType>,
pub policies: Vec<String>,
pub prompts: Vec<String>,
pub settings: Value,
}Fields§
§id: PackId§name: String§version: String§object_types: BTreeMap<String, ObjectType>§relation_types: BTreeMap<String, RelationType>§policies: Vec<String>§prompts: Vec<String>§settings: ValueImplementations§
Source§impl Pack
impl Pack
Sourcepub fn new(
id: PackId,
name: impl Into<String>,
version: impl Into<String>,
) -> Self
pub fn new( id: PackId, name: impl Into<String>, version: impl Into<String>, ) -> Self
Examples found in repository?
examples/typed_pack.rs (line 12)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let state = YoAgentState::load(MemoryEventStore::new()).await?;
10 let mut runtime = YoAgentRuntime::new(state.clone());
11 runtime.register_pack(
12 Pack::new(PackId::new("pack_lineage"), "lineage", "0.1.0")
13 .add_object_type(ObjectType::new("goal").require("title"))
14 .add_object_type(ObjectType::new("task").require("title"))
15 .add_relation_type(
16 RelationType::new("serves")
17 .from_kind("task")
18 .to_kind("goal"),
19 ),
20 );
21
22 runtime
23 .create_typed_node(
24 ActorRef::agent("demo"),
25 NodeId::new("goal_1"),
26 "goal",
27 json!({ "title": "Improve retry reliability" }),
28 )
29 .await?;
30 runtime
31 .create_typed_node(
32 ActorRef::agent("demo"),
33 NodeId::new("task_1"),
34 "task",
35 json!({ "title": "Investigate timeout" }),
36 )
37 .await?;
38 runtime
39 .create_typed_relation(
40 ActorRef::agent("demo"),
41 NodeId::new("task_1"),
42 "serves",
43 NodeId::new("goal_1"),
44 json!({}),
45 )
46 .await?;
47
48 println!("{}", serde_json::to_string_pretty(&state.graph().await)?);
49 Ok(())
50}Sourcepub fn add_object_type(self, object_type: ObjectType) -> Self
pub fn add_object_type(self, object_type: ObjectType) -> Self
Examples found in repository?
examples/typed_pack.rs (line 13)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let state = YoAgentState::load(MemoryEventStore::new()).await?;
10 let mut runtime = YoAgentRuntime::new(state.clone());
11 runtime.register_pack(
12 Pack::new(PackId::new("pack_lineage"), "lineage", "0.1.0")
13 .add_object_type(ObjectType::new("goal").require("title"))
14 .add_object_type(ObjectType::new("task").require("title"))
15 .add_relation_type(
16 RelationType::new("serves")
17 .from_kind("task")
18 .to_kind("goal"),
19 ),
20 );
21
22 runtime
23 .create_typed_node(
24 ActorRef::agent("demo"),
25 NodeId::new("goal_1"),
26 "goal",
27 json!({ "title": "Improve retry reliability" }),
28 )
29 .await?;
30 runtime
31 .create_typed_node(
32 ActorRef::agent("demo"),
33 NodeId::new("task_1"),
34 "task",
35 json!({ "title": "Investigate timeout" }),
36 )
37 .await?;
38 runtime
39 .create_typed_relation(
40 ActorRef::agent("demo"),
41 NodeId::new("task_1"),
42 "serves",
43 NodeId::new("goal_1"),
44 json!({}),
45 )
46 .await?;
47
48 println!("{}", serde_json::to_string_pretty(&state.graph().await)?);
49 Ok(())
50}Sourcepub fn add_relation_type(self, relation_type: RelationType) -> Self
pub fn add_relation_type(self, relation_type: RelationType) -> Self
Examples found in repository?
examples/typed_pack.rs (lines 15-19)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let state = YoAgentState::load(MemoryEventStore::new()).await?;
10 let mut runtime = YoAgentRuntime::new(state.clone());
11 runtime.register_pack(
12 Pack::new(PackId::new("pack_lineage"), "lineage", "0.1.0")
13 .add_object_type(ObjectType::new("goal").require("title"))
14 .add_object_type(ObjectType::new("task").require("title"))
15 .add_relation_type(
16 RelationType::new("serves")
17 .from_kind("task")
18 .to_kind("goal"),
19 ),
20 );
21
22 runtime
23 .create_typed_node(
24 ActorRef::agent("demo"),
25 NodeId::new("goal_1"),
26 "goal",
27 json!({ "title": "Improve retry reliability" }),
28 )
29 .await?;
30 runtime
31 .create_typed_node(
32 ActorRef::agent("demo"),
33 NodeId::new("task_1"),
34 "task",
35 json!({ "title": "Investigate timeout" }),
36 )
37 .await?;
38 runtime
39 .create_typed_relation(
40 ActorRef::agent("demo"),
41 NodeId::new("task_1"),
42 "serves",
43 NodeId::new("goal_1"),
44 json!({}),
45 )
46 .await?;
47
48 println!("{}", serde_json::to_string_pretty(&state.graph().await)?);
49 Ok(())
50}pub fn validate_node(&self, node: &Node) -> Result<(), StateError>
pub fn validate_relation( &self, relation: &Relation, from: &Node, to: &Node, ) -> Result<(), StateError>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Pack
impl<'de> Deserialize<'de> for Pack
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Pack
Auto Trait Implementations§
impl Freeze for Pack
impl RefUnwindSafe for Pack
impl Send for Pack
impl Sync for Pack
impl Unpin for Pack
impl UnsafeUnpin for Pack
impl UnwindSafe for Pack
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more