From a56d5f2ddfcfb290c308f2b1a3464c3bebc340de Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 8 Sep 2024 19:50:02 +0800 Subject: feat: save rag in YAML instead of bin (#848) --- src/config/mod.rs | 6 +++--- src/config/session.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/config') diff --git a/src/config/mod.rs b/src/config/mod.rs index d2d7c2f..25f0cd6 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -338,7 +338,7 @@ impl Config { pub fn rag_file(&self, name: &str) -> Result { let path = match &self.agent { Some(agent) => Self::agent_rag_file(agent.name(), name)?, - None => Self::rags_dir()?.join(format!("{name}.bin")), + None => Self::rags_dir()?.join(format!("{name}.yaml")), }; Ok(path) } @@ -359,7 +359,7 @@ impl Config { } pub fn agent_rag_file(agent_name: &str, rag_name: &str) -> Result { - Ok(Self::agent_config_dir(agent_name)?.join(format!("{rag_name}.bin"))) + Ok(Self::agent_config_dir(agent_name)?.join(format!("{rag_name}.yaml"))) } pub fn agent_variables_file(name: &str) -> Result { @@ -1186,7 +1186,7 @@ impl Config { let mut names = vec![]; for entry in rd.flatten() { let name = entry.file_name(); - if let Some(name) = name.to_string_lossy().strip_suffix(".bin") { + if let Some(name) = name.to_string_lossy().strip_suffix(".yaml") { names.push(name.to_string()); } } diff --git a/src/config/session.rs b/src/config/session.rs index 4051936..476ad51 100644 --- a/src/config/session.rs +++ b/src/config/session.rs @@ -326,10 +326,10 @@ impl Session { self.path = Some(session_path.display().to_string()); let content = serde_yaml::to_string(&self) - .with_context(|| format!("Failed to serde session {}", self.name))?; + .with_context(|| format!("Failed to serde session '{}'", self.name))?; write(session_path, content).with_context(|| { format!( - "Failed to write session {} to {}", + "Failed to write session '{}' to '{}'", self.name, session_path.display() ) -- cgit v1.2.3