Automated Deployment and local ollama #1

Merged
Sithies merged 5 commits from Automate-Deployment into master 2026-04-25 18:55:36 +00:00
7 changed files with 70 additions and 103 deletions
Showing only changes of commit b6a5618f78 - Show all commits
+1
View File
@@ -1,4 +1,5 @@
/target /target
/.claude
.env .env
*.key *.key
config/private/ config/private/
+3 -23
View File
@@ -1,5 +1,5 @@
use std::sync::Arc; use std::sync::Arc;
use nazarick_core::agent::base::BaseAgent; use nazarick_core::agent::base::{AgentConfig, BaseAgent};
use nazarick_core::agent::skill_registry::SkillRegistry; use nazarick_core::agent::skill_registry::SkillRegistry;
use nazarick_core::memory::Memory; use nazarick_core::memory::Memory;
use nazarick_core::summarizer::Summarizer; use nazarick_core::summarizer::Summarizer;
@@ -13,34 +13,14 @@ pub struct Lyra {
impl Lyra { impl Lyra {
pub fn new( pub fn new(
agent_id: impl Into<String>, config: AgentConfig,
shared_core_path: impl Into<String>,
soul_core_path: impl Into<String>,
llm: Box<dyn LlmProvider>, llm: Box<dyn LlmProvider>,
registry: Arc<SkillRegistry>, registry: Arc<SkillRegistry>,
memory: Arc<dyn Memory>, memory: Arc<dyn Memory>,
summarizer: Arc<dyn Summarizer>, summarizer: Arc<dyn Summarizer>,
max_tokens: u32,
max_loops: u32,
history_window: usize,
summary_every: usize,
conversation_timeout_mins: u64,
) -> Self { ) -> Self {
Self { Self {
base: BaseAgent::new( base: BaseAgent::new(config, llm, registry, memory, summarizer),
agent_id,
shared_core_path,
soul_core_path,
llm,
registry,
memory,
summarizer,
max_tokens,
max_loops,
history_window,
summary_every,
conversation_timeout_mins,
),
} }
} }
+32 -29
View File
@@ -13,6 +13,17 @@ use crate::agent::skill_registry::SkillRegistry;
use crate::memory::Memory; use crate::memory::Memory;
use crate::summarizer::Summarizer; 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 struct BaseAgent {
pub id: AgentId, pub id: AgentId,
agent_id: String, agent_id: String,
@@ -36,36 +47,28 @@ pub struct BaseAgent {
impl BaseAgent { impl BaseAgent {
pub fn new( pub fn new(
agent_id: impl Into<String>, config: AgentConfig,
shared_core_path: impl Into<String>,
soul_core_path: impl Into<String>,
llm: Box<dyn LlmProvider>, llm: Box<dyn LlmProvider>,
registry: Arc<SkillRegistry>, registry: Arc<SkillRegistry>,
memory: Arc<dyn Memory>, memory: Arc<dyn Memory>,
summarizer: Arc<dyn Summarizer>, summarizer: Arc<dyn Summarizer>,
max_tokens: u32,
max_loops: u32,
history_window: usize,
summary_every: usize,
conversation_timeout_mins: u64,
) -> Self { ) -> Self {
let skill_format = llm.skill_format(); let skill_format = llm.skill_format();
let agent_id = agent_id.into();
Self { Self {
id: AgentId::new_v4(), id: AgentId::new_v4(),
agent_id: agent_id.clone(), agent_id: config.agent_id.clone(),
max_tokens, max_tokens: config.max_tokens,
max_loops, max_loops: config.max_loops,
history_window, history_window: config.history_window,
summary_every, summary_every: config.summary_every,
conversation_timeout_mins, conversation_timeout_mins: config.conversation_timeout_mins,
conversation_id: 0, conversation_id: 0,
messages_since_summary: 0, messages_since_summary: 0,
prompt_builder: PromptBuilder::new( prompt_builder: PromptBuilder::new(
&agent_id, &config.agent_id,
shared_core_path, config.shared_core_path,
soul_core_path, config.soul_core_path,
), ),
skill_executor: SkillExecutor::new(registry.clone(), skill_format.clone()), skill_executor: SkillExecutor::new(registry.clone(), skill_format.clone()),
skill_format, skill_format,
@@ -243,17 +246,17 @@ impl BaseAgent {
continue; continue;
} }
if let Some(skill_name) = Self::parse_skill_info(&clean_raw) { if let Some(skill_name) = Self::parse_skill_info(&clean_raw)
if let Some(skill) = self.registry.get(&skill_name) { && let Some(skill) = self.registry.get(&skill_name)
let details = format!( {
"[Skill-Details für '{}']\n{}", let details = format!(
skill_name, "[Skill-Details für '{}']\n{}",
skill.details() skill_name,
); skill.details()
loop_context.push(Message::assistant(&clean_raw)); );
loop_context.push(Message::user(&details)); loop_context.push(Message::assistant(&clean_raw));
continue; loop_context.push(Message::user(&details));
} continue;
} }
let (clean, feedback) = self.skill_executor.process( let (clean, feedback) = self.skill_executor.process(
@@ -120,11 +120,7 @@ impl SkillExecutor {
let mut calls = Vec::new(); let mut calls = Vec::new();
let mut clean = response.to_string(); let mut clean = response.to_string();
loop { while let Some(start) = clean.find("<skill name=\"") {
let start = match clean.find("<skill name=\"") {
Some(s) => s,
None => break,
};
let end = match clean[start..].find("</skill>") { let end = match clean[start..].find("</skill>") {
Some(e) => start + e, Some(e) => start + e,
None => { None => {
+8 -6
View File
@@ -1,5 +1,6 @@
// nazarick-core/src/llm/traits.rs // nazarick-core/src/llm/traits.rs
use std::str::FromStr;
use crate::types::Result; use crate::types::Result;
use crate::llm::types::{LlmRequest, LlmResponse}; use crate::llm::types::{LlmRequest, LlmResponse};
@@ -13,13 +14,14 @@ pub enum SkillFormat {
None, None,
} }
impl SkillFormat { impl FromStr for SkillFormat {
/// Parsed aus config.toml String type Err = ();
pub fn from_str(s: &str) -> Self {
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
match s { match s {
"tool_use" => Self::ToolUse, "tool_use" => Ok(Self::ToolUse),
"none" => Self::None, "none" => Ok(Self::None),
_ => Self::Xml, // default _ => Ok(Self::Xml),
} }
} }
} }
+22 -17
View File
@@ -10,6 +10,7 @@ use tokio::sync::Mutex;
use tower_http::trace::TraceLayer; use tower_http::trace::TraceLayer;
use tracing::info; use tracing::info;
use nazarick_core::agent::base::AgentConfig;
use nazarick_core::agent::skill_registry::SkillRegistry; use nazarick_core::agent::skill_registry::SkillRegistry;
use nazarick_core::llm::{LlmProvider, SkillFormat}; use nazarick_core::llm::{LlmProvider, SkillFormat};
use api::llm::openai_compat::OpenAiCompatProvider; use api::llm::openai_compat::OpenAiCompatProvider;
@@ -26,7 +27,7 @@ use skills as _;
fn build_provider(model_cfg: &ModelConfig) -> Box<dyn LlmProvider> { fn build_provider(model_cfg: &ModelConfig) -> Box<dyn LlmProvider> {
let skill_format = model_cfg.skill_format let skill_format = model_cfg.skill_format
.as_deref() .as_deref()
.map(SkillFormat::from_str) .map(|s| s.parse::<SkillFormat>().unwrap_or(SkillFormat::Xml))
.unwrap_or(SkillFormat::Xml); .unwrap_or(SkillFormat::Xml);
match model_cfg.provider.as_str() { match model_cfg.provider.as_str() {
@@ -107,34 +108,38 @@ async fn main() -> anyhow::Result<()> {
info!("Memory geladen"); info!("Memory geladen");
let mut sebas = Sebas::new( let mut sebas = Sebas::new(
"sebas_tian", AgentConfig {
"config/shared_core.md", agent_id: "sebas_tian".to_string(),
"crates/sebas-tian/config/soul_core.md", shared_core_path: "config/shared_core.md".to_string(),
soul_core_path: "crates/sebas-tian/config/soul_core.md".to_string(),
max_tokens: sebas_cfg.max_tokens,
max_loops: sebas_cfg.max_loops,
history_window: sebas_cfg.history_window,
summary_every: sebas_cfg.summary_every,
conversation_timeout_mins: sebas_cfg.conversation_timeout_mins,
},
build_provider(sebas_model), build_provider(sebas_model),
registry.clone(), registry.clone(),
sebas_memory, sebas_memory,
summarizer.clone(), summarizer.clone(),
sebas_cfg.max_tokens,
sebas_cfg.max_loops,
sebas_cfg.history_window,
sebas_cfg.summary_every,
sebas_cfg.conversation_timeout_mins,
); );
sebas.init().await?; sebas.init().await?;
let mut lyra = Lyra::new( let mut lyra = Lyra::new(
"lyra", AgentConfig {
"config/shared_core.md", agent_id: "lyra".to_string(),
"crates/lyra/config/soul_core.md", shared_core_path: "config/shared_core.md".to_string(),
soul_core_path: "crates/lyra/config/soul_core.md".to_string(),
max_tokens: lyra_cfg.max_tokens,
max_loops: lyra_cfg.max_loops,
history_window: lyra_cfg.history_window,
summary_every: lyra_cfg.summary_every,
conversation_timeout_mins: lyra_cfg.conversation_timeout_mins,
},
build_provider(lyra_model), build_provider(lyra_model),
registry.clone(), registry.clone(),
lyra_memory, lyra_memory,
summarizer.clone(), summarizer.clone(),
lyra_cfg.max_tokens,
lyra_cfg.max_loops,
lyra_cfg.history_window,
lyra_cfg.summary_every,
lyra_cfg.conversation_timeout_mins,
); );
lyra.init().await?; lyra.init().await?;
+3 -23
View File
@@ -1,5 +1,5 @@
use std::sync::Arc; use std::sync::Arc;
use nazarick_core::agent::base::BaseAgent; use nazarick_core::agent::base::{AgentConfig, BaseAgent};
use nazarick_core::agent::skill_registry::SkillRegistry; use nazarick_core::agent::skill_registry::SkillRegistry;
use nazarick_core::memory::Memory; use nazarick_core::memory::Memory;
use nazarick_core::summarizer::Summarizer; use nazarick_core::summarizer::Summarizer;
@@ -13,34 +13,14 @@ pub struct Sebas {
impl Sebas { impl Sebas {
pub fn new( pub fn new(
agent_id: impl Into<String>, config: AgentConfig,
shared_core_path: impl Into<String>,
soul_core_path: impl Into<String>,
llm: Box<dyn LlmProvider>, llm: Box<dyn LlmProvider>,
registry: Arc<SkillRegistry>, registry: Arc<SkillRegistry>,
memory: Arc<dyn Memory>, memory: Arc<dyn Memory>,
summarizer: Arc<dyn Summarizer>, summarizer: Arc<dyn Summarizer>,
max_tokens: u32,
max_loops: u32,
history_window: usize,
summary_every: usize,
conversation_timeout_mins: u64,
) -> Self { ) -> Self {
Self { Self {
base: BaseAgent::new( base: BaseAgent::new(config, llm, registry, memory, summarizer),
agent_id,
shared_core_path,
soul_core_path,
llm,
registry,
memory,
summarizer,
max_tokens,
max_loops,
history_window,
summary_every,
conversation_timeout_mins,
),
} }
} }