-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_agent.rs
More file actions
52 lines (42 loc) · 1.31 KB
/
Copy pathbasic_agent.rs
File metadata and controls
52 lines (42 loc) · 1.31 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
use std::sync::Arc;
use async_trait::async_trait;
use rig_compose::{
Agent, GenericAgent, InvestigationContext, KernelError, Skill, SkillOutcome, SkillRegistry,
ToolRegistry,
};
struct KeywordSkill;
#[async_trait]
impl Skill for KeywordSkill {
fn id(&self) -> &str {
"example.keyword"
}
fn description(&self) -> &str {
"raises confidence when the keyword signal is present"
}
fn applies(&self, context: &InvestigationContext) -> bool {
context.has_signal("keyword.match")
}
async fn execute(
&self,
_context: &mut InvestigationContext,
_tools: &ToolRegistry,
) -> Result<SkillOutcome, KernelError> {
Ok(SkillOutcome::default().with_delta(0.25))
}
}
#[tokio::main]
async fn main() -> Result<(), KernelError> {
let skills = SkillRegistry::new();
skills.register(Arc::new(KeywordSkill));
let tools = ToolRegistry::new();
let agent = GenericAgent::builder("triage")
.with_skills(["example.keyword"])
.build(&skills, &tools)?;
let mut context = InvestigationContext::new("entity-1", "default").with_signal("keyword.match");
let result = agent.step(&mut context).await?;
println!(
"skills run: {:?}; confidence: {}",
result.skills_run, result.confidence
);
Ok(())
}