diff options
| author | sigoden <sigoden@gmail.com> | 2024-07-29 17:21:52 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-29 17:21:52 +0800 |
| commit | 44aac171b79835048ae09150d392a683930077e1 (patch) | |
| tree | 6f9669e2225dbdb3ceb732d207586661ef0dbb7a /src/config | |
| parent | 14bfd4e97d0ea7d633e54595e17a54eb66529232 (diff) | |
| download | aichat-44aac171b79835048ae09150d392a683930077e1.tar.gz | |
fix: unable to rebuild agent rag (#763)
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/agent.rs | 2 | ||||
| -rw-r--r-- | src/config/mod.rs | 14 |
2 files changed, 6 insertions, 10 deletions
diff --git a/src/config/agent.rs b/src/config/agent.rs index 2b319ed..5f36097 100644 --- a/src/config/agent.rs +++ b/src/config/agent.rs @@ -36,7 +36,7 @@ impl Agent { let definition_file_path = functions_dir.join("index.yaml"); let functions_file_path = functions_dir.join("functions.json"); let variables_path = Config::agent_variables_file(name)?; - let rag_path = Config::agent_rag_file(name)?; + let rag_path = Config::agent_rag_file(name, "rag")?; let config_path = Config::agent_config_file(name)?; let agent_config = if config_path.exists() { AgentConfig::load(&config_path)? diff --git a/src/config/mod.rs b/src/config/mod.rs index 9ebf34b..c9a4a73 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -49,7 +49,6 @@ const FUNCTIONS_DIR_NAME: &str = "functions"; const FUNCTIONS_FILE_NAME: &str = "functions.json"; const FUNCTIONS_BIN_DIR_NAME: &str = "bin"; const AGENTS_DIR_NAME: &str = "agents"; -const AGENT_RAG_FILE_NAME: &str = "rag.bin"; const AGENT_VARIABLES_FILE_NAME: &str = "variables.yaml"; pub const TEMP_ROLE_NAME: &str = "%%"; @@ -331,12 +330,9 @@ impl Config { } pub fn rag_file(&self, name: &str) -> Result<PathBuf> { - let path = if self.agent.is_none() { - Self::rags_dir()?.join(format!("{name}.bin")) - } else { - Self::rags_dir()? - .join(AGENTS_DIR_NAME) - .join(format!("{name}.bin")) + let path = match &self.agent { + Some(agent) => Self::agent_rag_file(agent.name(), name)?, + None => Self::rags_dir()?.join(format!("{name}.bin")), }; Ok(path) } @@ -356,8 +352,8 @@ impl Config { Ok(Self::agent_config_dir(name)?.join(CONFIG_FILE_NAME)) } - pub fn agent_rag_file(name: &str) -> Result<PathBuf> { - Ok(Self::agent_config_dir(name)?.join(AGENT_RAG_FILE_NAME)) + pub fn agent_rag_file(agent_name: &str, rag_name: &str) -> Result<PathBuf> { + Ok(Self::agent_config_dir(agent_name)?.join(format!("{rag_name}.bin"))) } pub fn agent_variables_file(name: &str) -> Result<PathBuf> { |
