refactor: Changed the name of agent_prelude to agent_session to make its purpose more clear
This commit is contained in:
@@ -5,13 +5,13 @@
|
|||||||
# - <agent-name>_MODEL
|
# - <agent-name>_MODEL
|
||||||
# - <agent-name>_TEMPERATURE
|
# - <agent-name>_TEMPERATURE
|
||||||
# - <agent-name>_TOP_P
|
# - <agent-name>_TOP_P
|
||||||
# - <agent-name>_AGENT_PRELUDE
|
# - <agent-name>_AGENT_SESSION
|
||||||
# - <agent-name>_VARIABLES (as JSON array of key-value pairs; e.g. '[{"name": "username", "value": "alex"}]')
|
# - <agent-name>_VARIABLES (as JSON array of key-value pairs; e.g. '[{"name": "username", "value": "alex"}]')
|
||||||
|
|
||||||
model: openai:gpt-4o # Specify the LLM to use
|
model: openai:gpt-4o # Specify the LLM to use
|
||||||
temperature: null # Set default temperature parameter, range (0, 1)
|
temperature: null # Set default temperature parameter, range (0, 1)
|
||||||
top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model
|
top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model
|
||||||
agent_prelude: null # Set a session to use when starting the agent. (e.g. temp, default); defaults to globally set agent_prelude
|
agent_session: null # Set a session to use when starting the agent. (e.g. temp, default); defaults to globally set agent_session
|
||||||
name: <agent-name> # Name of the agent, used in the UI and logs
|
name: <agent-name> # Name of the agent, used in the UI and logs
|
||||||
description: <description> # Description of the agent, used in the UI
|
description: <description> # Description of the agent, used in the UI
|
||||||
version: 1 # Version of the agent
|
version: 1 # Version of the agent
|
||||||
@@ -66,4 +66,4 @@ documents: # Optional documents to load for the agent
|
|||||||
- ~/some-file.txt # File in the user's home directory
|
- ~/some-file.txt # File in the user's home directory
|
||||||
- /absolute/path/to/some-file.md # File with absolute path
|
- /absolute/path/to/some-file.md # File with absolute path
|
||||||
- /absolute/path/**/NAME.txt # Find all NAME.txt files in the specified directory and all its subdirectories
|
- /absolute/path/**/NAME.txt # Find all NAME.txt files in the specified directory and all its subdirectories
|
||||||
- /absolute/path/to/*/README.md # Find all README.md files in all immediate subdirectories of the specified directory (depth=1)
|
- /absolute/path/to/*/README.md # Find all README.md files in all immediate subdirectories of the specified directory (depth=1)
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ use_tools: null # Which tools to use by default. (e.g. 'fs,web_
|
|||||||
# ---- prelude ----
|
# ---- prelude ----
|
||||||
repl_prelude: null # Set a default role or session for REPL mode (e.g. role:<name>, session:<name>, <session>:<role>)
|
repl_prelude: null # Set a default role or session for REPL mode (e.g. role:<name>, session:<name>, <session>:<role>)
|
||||||
cmd_prelude: null # Set a default role or session for CMD mode (e.g. role:<name>, session:<name>, <session>:<role>)
|
cmd_prelude: null # Set a default role or session for CMD mode (e.g. role:<name>, session:<name>, <session>:<role>)
|
||||||
agent_prelude: null # Set a session to use when starting an agent (e.g. temp, default)
|
agent_session: null # Set a session to use when starting an agent (e.g. temp, default)
|
||||||
|
|
||||||
# ---- session ----
|
# ---- session ----
|
||||||
# Controls the persistence of the session. if true, auto save; if false, not save; if null, asking the user
|
# Controls the persistence of the session. if true, auto save; if false, not save; if null, asking the user
|
||||||
|
|||||||
+9
-9
@@ -2,11 +2,11 @@ use super::*;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client::Model,
|
client::Model,
|
||||||
function::{run_llm_function, Functions},
|
function::{Functions, run_llm_function},
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use inquire::{validator::Validation, Text};
|
use inquire::{Text, validator::Validation};
|
||||||
use rust_embed::Embed;
|
use rust_embed::Embed;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{fs::read_to_string, path::Path};
|
use std::{fs::read_to_string, path::Path};
|
||||||
@@ -283,8 +283,8 @@ impl Agent {
|
|||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn agent_prelude(&self) -> Option<&str> {
|
pub fn agent_session(&self) -> Option<&str> {
|
||||||
self.config.agent_prelude.as_deref()
|
self.config.agent_session.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn variables(&self) -> &AgentVariables {
|
pub fn variables(&self) -> &AgentVariables {
|
||||||
@@ -446,7 +446,7 @@ pub struct AgentConfig {
|
|||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub top_p: Option<f64>,
|
pub top_p: Option<f64>,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub agent_prelude: Option<String>,
|
pub agent_session: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub description: String,
|
pub description: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -481,8 +481,8 @@ impl AgentConfig {
|
|||||||
let name = &self.name;
|
let name = &self.name;
|
||||||
let with_prefix = |v: &str| normalize_env_name(&format!("{name}_{v}"));
|
let with_prefix = |v: &str| normalize_env_name(&format!("{name}_{v}"));
|
||||||
|
|
||||||
if self.agent_prelude.is_none() {
|
if self.agent_session.is_none() {
|
||||||
self.agent_prelude = config.agent_prelude.clone();
|
self.agent_session = config.agent_session.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(v) = read_env_value::<String>(&with_prefix("model")) {
|
if let Some(v) = read_env_value::<String>(&with_prefix("model")) {
|
||||||
@@ -494,8 +494,8 @@ impl AgentConfig {
|
|||||||
if let Some(v) = read_env_value::<f64>(&with_prefix("top_p")) {
|
if let Some(v) = read_env_value::<f64>(&with_prefix("top_p")) {
|
||||||
self.top_p = v;
|
self.top_p = v;
|
||||||
}
|
}
|
||||||
if let Some(v) = read_env_value::<String>(&with_prefix("agent_prelude")) {
|
if let Some(v) = read_env_value::<String>(&with_prefix("agent_session")) {
|
||||||
self.agent_prelude = v;
|
self.agent_session = v;
|
||||||
}
|
}
|
||||||
if let Ok(v) = env::var(with_prefix("variables")) {
|
if let Ok(v) = env::var(with_prefix("variables")) {
|
||||||
if let Ok(v) = serde_json::from_str(&v) {
|
if let Ok(v) = serde_json::from_str(&v) {
|
||||||
|
|||||||
+14
-14
@@ -3,17 +3,17 @@ mod input;
|
|||||||
mod role;
|
mod role;
|
||||||
mod session;
|
mod session;
|
||||||
|
|
||||||
pub use self::agent::{complete_agent_variables, list_agents, Agent, AgentVariables};
|
pub use self::agent::{Agent, AgentVariables, complete_agent_variables, list_agents};
|
||||||
pub use self::input::Input;
|
pub use self::input::Input;
|
||||||
pub use self::role::{
|
pub use self::role::{
|
||||||
Role, RoleLike, CODE_ROLE, CREATE_TITLE_ROLE, EXPLAIN_SHELL_ROLE, SHELL_ROLE,
|
CODE_ROLE, CREATE_TITLE_ROLE, EXPLAIN_SHELL_ROLE, Role, RoleLike, SHELL_ROLE,
|
||||||
};
|
};
|
||||||
use self::session::Session;
|
use self::session::Session;
|
||||||
use mem::take;
|
use mem::take;
|
||||||
|
|
||||||
use crate::client::{
|
use crate::client::{
|
||||||
create_client_config, list_client_types, list_models, ClientConfig, MessageContentToolCalls,
|
ClientConfig, MessageContentToolCalls, Model, ModelType, OPENAI_COMPATIBLE_PROVIDERS,
|
||||||
Model, ModelType, ProviderModels, OPENAI_COMPATIBLE_PROVIDERS,
|
ProviderModels, create_client_config, list_client_types, list_models,
|
||||||
};
|
};
|
||||||
use crate::function::{FunctionDeclaration, Functions, ToolResult};
|
use crate::function::{FunctionDeclaration, Functions, ToolResult};
|
||||||
use crate::rag::Rag;
|
use crate::rag::Rag;
|
||||||
@@ -22,11 +22,11 @@ use crate::repl::{run_repl_command, split_args_text};
|
|||||||
use crate::utils::*;
|
use crate::utils::*;
|
||||||
|
|
||||||
use crate::mcp::{
|
use crate::mcp::{
|
||||||
McpRegistry, MCP_INVOKE_META_FUNCTION_NAME_PREFIX, MCP_LIST_META_FUNCTION_NAME_PREFIX,
|
MCP_INVOKE_META_FUNCTION_NAME_PREFIX, MCP_LIST_META_FUNCTION_NAME_PREFIX, McpRegistry,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, bail, Context, Result};
|
use anyhow::{Context, Result, anyhow, bail};
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use inquire::{list_option::ListOption, validator::Validation, Confirm, MultiSelect, Select, Text};
|
use inquire::{Confirm, MultiSelect, Select, Text, list_option::ListOption, validator::Validation};
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -35,7 +35,7 @@ use std::collections::{HashMap, HashSet};
|
|||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
fs::{
|
fs::{
|
||||||
create_dir_all, read_dir, read_to_string, remove_dir_all, remove_file, File, OpenOptions,
|
File, OpenOptions, create_dir_all, read_dir, read_to_string, remove_dir_all, remove_file,
|
||||||
},
|
},
|
||||||
io::Write,
|
io::Write,
|
||||||
mem,
|
mem,
|
||||||
@@ -44,7 +44,7 @@ use std::{
|
|||||||
sync::{Arc, OnceLock},
|
sync::{Arc, OnceLock},
|
||||||
};
|
};
|
||||||
use syntect::highlighting::ThemeSet;
|
use syntect::highlighting::ThemeSet;
|
||||||
use terminal_colorsaurus::{color_scheme, ColorScheme, QueryOptions};
|
use terminal_colorsaurus::{ColorScheme, QueryOptions, color_scheme};
|
||||||
use tokio::runtime::Handle;
|
use tokio::runtime::Handle;
|
||||||
|
|
||||||
pub const TEMP_ROLE_NAME: &str = "temp";
|
pub const TEMP_ROLE_NAME: &str = "temp";
|
||||||
@@ -131,7 +131,7 @@ pub struct Config {
|
|||||||
|
|
||||||
pub repl_prelude: Option<String>,
|
pub repl_prelude: Option<String>,
|
||||||
pub cmd_prelude: Option<String>,
|
pub cmd_prelude: Option<String>,
|
||||||
pub agent_prelude: Option<String>,
|
pub agent_session: Option<String>,
|
||||||
|
|
||||||
pub save_session: Option<bool>,
|
pub save_session: Option<bool>,
|
||||||
pub compress_threshold: usize,
|
pub compress_threshold: usize,
|
||||||
@@ -213,7 +213,7 @@ impl Default for Config {
|
|||||||
|
|
||||||
repl_prelude: None,
|
repl_prelude: None,
|
||||||
cmd_prelude: None,
|
cmd_prelude: None,
|
||||||
agent_prelude: None,
|
agent_session: None,
|
||||||
|
|
||||||
save_session: None,
|
save_session: None,
|
||||||
compress_threshold: 4000,
|
compress_threshold: 4000,
|
||||||
@@ -1629,7 +1629,7 @@ impl Config {
|
|||||||
if config.read().macro_flag {
|
if config.read().macro_flag {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
agent.agent_prelude().map(|v| v.to_string())
|
agent.agent_session().map(|v| v.to_string())
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
config.write().rag = agent.rag();
|
config.write().rag = agent.rag();
|
||||||
@@ -2557,8 +2557,8 @@ impl Config {
|
|||||||
if let Some(v) = read_env_value::<String>(&get_env_name("cmd_prelude")) {
|
if let Some(v) = read_env_value::<String>(&get_env_name("cmd_prelude")) {
|
||||||
self.cmd_prelude = v;
|
self.cmd_prelude = v;
|
||||||
}
|
}
|
||||||
if let Some(v) = read_env_value::<String>(&get_env_name("agent_prelude")) {
|
if let Some(v) = read_env_value::<String>(&get_env_name("agent_session")) {
|
||||||
self.agent_prelude = v;
|
self.agent_session = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(v) = read_env_bool(&get_env_name("save_session")) {
|
if let Some(v) = read_env_bool(&get_env_name("save_session")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user