Fix
This commit is contained in:
@@ -13,6 +13,17 @@ use crate::agent::skill_registry::SkillRegistry;
|
||||
use crate::memory::Memory;
|
||||
use crate::summarizer::Summarizer;
|
||||
|
||||
pub struct AgentConfig {
|
||||
pub agent_id: String,
|
||||
pub shared_core_path: String,
|
||||
pub soul_core_path: String,
|
||||
pub max_tokens: u32,
|
||||
pub max_loops: u32,
|
||||
pub history_window: usize,
|
||||
pub summary_every: usize,
|
||||
pub conversation_timeout_mins: u64,
|
||||
}
|
||||
|
||||
pub struct BaseAgent {
|
||||
pub id: AgentId,
|
||||
agent_id: String,
|
||||
@@ -36,36 +47,28 @@ pub struct BaseAgent {
|
||||
|
||||
impl BaseAgent {
|
||||
pub fn new(
|
||||
agent_id: impl Into<String>,
|
||||
shared_core_path: impl Into<String>,
|
||||
soul_core_path: impl Into<String>,
|
||||
config: AgentConfig,
|
||||
llm: Box<dyn LlmProvider>,
|
||||
registry: Arc<SkillRegistry>,
|
||||
memory: Arc<dyn Memory>,
|
||||
summarizer: Arc<dyn Summarizer>,
|
||||
max_tokens: u32,
|
||||
max_loops: u32,
|
||||
history_window: usize,
|
||||
summary_every: usize,
|
||||
conversation_timeout_mins: u64,
|
||||
) -> Self {
|
||||
let skill_format = llm.skill_format();
|
||||
let agent_id = agent_id.into();
|
||||
|
||||
Self {
|
||||
id: AgentId::new_v4(),
|
||||
agent_id: agent_id.clone(),
|
||||
max_tokens,
|
||||
max_loops,
|
||||
history_window,
|
||||
summary_every,
|
||||
conversation_timeout_mins,
|
||||
agent_id: config.agent_id.clone(),
|
||||
max_tokens: config.max_tokens,
|
||||
max_loops: config.max_loops,
|
||||
history_window: config.history_window,
|
||||
summary_every: config.summary_every,
|
||||
conversation_timeout_mins: config.conversation_timeout_mins,
|
||||
conversation_id: 0,
|
||||
messages_since_summary: 0,
|
||||
prompt_builder: PromptBuilder::new(
|
||||
&agent_id,
|
||||
shared_core_path,
|
||||
soul_core_path,
|
||||
&config.agent_id,
|
||||
config.shared_core_path,
|
||||
config.soul_core_path,
|
||||
),
|
||||
skill_executor: SkillExecutor::new(registry.clone(), skill_format.clone()),
|
||||
skill_format,
|
||||
@@ -243,17 +246,17 @@ impl BaseAgent {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(skill_name) = Self::parse_skill_info(&clean_raw) {
|
||||
if let Some(skill) = self.registry.get(&skill_name) {
|
||||
let details = format!(
|
||||
"[Skill-Details für '{}']\n{}",
|
||||
skill_name,
|
||||
skill.details()
|
||||
);
|
||||
loop_context.push(Message::assistant(&clean_raw));
|
||||
loop_context.push(Message::user(&details));
|
||||
continue;
|
||||
}
|
||||
if let Some(skill_name) = Self::parse_skill_info(&clean_raw)
|
||||
&& let Some(skill) = self.registry.get(&skill_name)
|
||||
{
|
||||
let details = format!(
|
||||
"[Skill-Details für '{}']\n{}",
|
||||
skill_name,
|
||||
skill.details()
|
||||
);
|
||||
loop_context.push(Message::assistant(&clean_raw));
|
||||
loop_context.push(Message::user(&details));
|
||||
continue;
|
||||
}
|
||||
|
||||
let (clean, feedback) = self.skill_executor.process(
|
||||
|
||||
@@ -120,11 +120,7 @@ impl SkillExecutor {
|
||||
let mut calls = Vec::new();
|
||||
let mut clean = response.to_string();
|
||||
|
||||
loop {
|
||||
let start = match clean.find("<skill name=\"") {
|
||||
Some(s) => s,
|
||||
None => break,
|
||||
};
|
||||
while let Some(start) = clean.find("<skill name=\"") {
|
||||
let end = match clean[start..].find("</skill>") {
|
||||
Some(e) => start + e,
|
||||
None => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// nazarick-core/src/llm/traits.rs
|
||||
|
||||
use std::str::FromStr;
|
||||
use crate::types::Result;
|
||||
use crate::llm::types::{LlmRequest, LlmResponse};
|
||||
|
||||
@@ -13,13 +14,14 @@ pub enum SkillFormat {
|
||||
None,
|
||||
}
|
||||
|
||||
impl SkillFormat {
|
||||
/// Parsed aus config.toml String
|
||||
pub fn from_str(s: &str) -> Self {
|
||||
impl FromStr for SkillFormat {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
|
||||
match s {
|
||||
"tool_use" => Self::ToolUse,
|
||||
"none" => Self::None,
|
||||
_ => Self::Xml, // default
|
||||
"tool_use" => Ok(Self::ToolUse),
|
||||
"none" => Ok(Self::None),
|
||||
_ => Ok(Self::Xml),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user