fix: append memory functions to non-graph based agents on init
This commit is contained in:
+16
-1
@@ -2,6 +2,7 @@ use super::*;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::Model,
|
client::Model,
|
||||||
|
config::memory,
|
||||||
function::{Functions, run_llm_function},
|
function::{Functions, run_llm_function},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ use fancy_regex::Captures;
|
|||||||
use inquire::{Text, validator::Validation};
|
use inquire::{Text, validator::Validation};
|
||||||
use rust_embed::Embed;
|
use rust_embed::Embed;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{ffi::OsStr, path::Path};
|
use std::{env, ffi::OsStr, path::Path};
|
||||||
|
|
||||||
const DEFAULT_AGENT_NAME: &str = "rag";
|
const DEFAULT_AGENT_NAME: &str = "rag";
|
||||||
|
|
||||||
@@ -214,6 +215,20 @@ impl Agent {
|
|||||||
functions.append_skill_functions();
|
functions.append_skill_functions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if app.function_calling_support
|
||||||
|
&& !matches!(agent_config.memory, Some(false))
|
||||||
|
&& !matches!(app.memory, Some(false))
|
||||||
|
{
|
||||||
|
let memory_exists = paths::global_memory_index_path().exists()
|
||||||
|
|| env::current_dir()
|
||||||
|
.ok()
|
||||||
|
.and_then(|cwd| memory::discover_workspace_memory(&cwd))
|
||||||
|
.is_some();
|
||||||
|
if memory_exists {
|
||||||
|
functions.append_memory_functions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
agent_config.replace_tools_placeholder(&functions);
|
agent_config.replace_tools_placeholder(&functions);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
|||||||
Reference in New Issue
Block a user