diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-23 22:09:47 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-23 22:09:47 +0800 |
| commit | f9e7efd41c475519d8f7a01c539d9ee4a3d56208 (patch) | |
| tree | 73536710a148b6db8463fa0e4a3a67e1b4a64bec | |
| parent | 777638049b7ea4187b152d70ccc9d38d91948b2e (diff) | |
| download | aichat-f9e7efd41c475519d8f7a01c539d9ee4a3d56208.tar.gz | |
refactor: reorder config items (#639)
| -rw-r--r-- | config.example.yaml | 41 | ||||
| -rw-r--r-- | src/config/mod.rs | 69 |
2 files changed, 63 insertions, 47 deletions
diff --git a/config.example.yaml b/config.example.yaml index 90c480d..0c3d985 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -1,23 +1,14 @@ # ---- llm ---- -model: openai:gpt-3.5-turbo # Specify the language model to use -temperature: null # Set default temperature parameter, range (0, 2) +model: openai:gpt-4o # Specify the LLM to use +temperature: null # Set default temperature parameter top_p: null # Set default top-p parameter, range (0, 1) -# ---- apperence ---- -highlight: true # Controls syntax highlighting -light_theme: false # Activates a light color theme when true. ENV: AICHAT_LIGHT_THEME -# Custom REPL prompt, see https://github.com/sigoden/aichat/wiki/Custom-REPL-Prompt for more detils -left_prompt: - '{color.green}{?session {?agent {agent}>}{session}{?role /}}{!session {?agent {agent}>}}{role}{?rag @{rag}}{color.cyan}{?session )}{!session >}{color.reset} ' -right_prompt: - '{color.purple}{?session {?consume_tokens {consume_tokens}({consume_percent}%)}{!consume_tokens {consume_tokens}}}{color.reset}' - # ---- behavior ---- save: true # Indicates whether to persist the message +keybindings: emacs # Choose keybinding style (emacs, vi) +buffer_editor: null # Command used to edit the current input with ctrl+o, env: EDITOR wrap: no # Controls text wrapping (no, auto, <max-width>) wrap_code: false # Enables or disables wrapping of code blocks -keybindings: emacs # Choose keybinding style (emacs, vi) -buffer_editor: null # Command used to edit the current input with Ctrl+O # ---- prelude ---- prelude: null # Set a default role or session to start with (e.g. role:<name>, session:<name>) @@ -34,13 +25,14 @@ summarize_prompt: 'Summarize the discussion briefly in 200 words or less to use # Text prompt used for including the summary of the entire session summary_prompt: 'This is a summary of the chat history as a recap: ' -# ---- function-calling ---- +# ---- function-calling & agent ---- # Controls the function calling feature. For setup instructions, visit https://github.com/sigoden/llm-functions function_calling: false -# Regex for seletecting dangerous functions. -# User confirmation is required when executing these functions. +# Regex for seletecting dangerous functions +# User confirmation is required when executing these functions # e.g. 'execute_command|execute_js_code' 'execute_.*' dangerously_functions_filter: null +# Per-Agent configuration agents: - name: todo-sh model: null @@ -48,12 +40,12 @@ agents: top_p: null dangerously_functions_filter: null -# ---- rag ---- +# ---- RAG ---- rag_embedding_model: null # Specifies the embedding model to use rag_rerank_model: null # Specifies the rerank model to use +rag_top_k: 4 # Specifies the number of documents to retrieve rag_chunk_size: null # Specifies the chunk size rag_chunk_overlap: null # Specifies the chunk overlap -rag_top_k: 4 # Specifies the number of documents to retrieve rag_min_score_vector_search: 0 # Specifies the minimum relevance score for vector-based searching rag_min_score_keyword_search: 0 # Specifies the minimum relevance score for keyword-based searching rag_min_score_rerank: 0 # Specifies the minimum relevance score for reranking @@ -73,7 +65,16 @@ rag_template: | Given the context information, answer the query. Query: __INPUT__ -# ---- client ---- +# ---- apperence ---- +highlight: true # Controls syntax highlighting +light_theme: false # Activates a light color theme when true. env: AICHAT_LIGHT_THEME +# Custom REPL prompt, see https://github.com/sigoden/aichat/wiki/Custom-REPL-Prompt for more details +left_prompt: + '{color.green}{?session {?agent {agent}>}{session}{?role /}}{!session {?agent {agent}>}}{role}{?rag @{rag}}{color.cyan}{?session )}{!session >}{color.reset} ' +right_prompt: + '{color.purple}{?session {?consume_tokens {consume_tokens}({consume_percent}%)}{!consume_tokens {consume_tokens}}}{color.reset}' + +# ---- clients ---- clients: # All clients have the following configuration: # - type: xxxx @@ -106,7 +107,7 @@ clients: # For any platform compatible with OpenAI's API - type: openai-compatible - name: localai + name: local api_base: http://localhost:8080/v1 # ENV: {client}_API_BASE api_key: xxx # ENV: {client}_API_KEY chat_endpoint: /chat/completions # Optional diff --git a/src/config/mod.rs b/src/config/mod.rs index 4c0e1e7..0c1c6ac 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -86,36 +86,44 @@ pub struct Config { pub model_id: String, pub temperature: Option<f64>, pub top_p: Option<f64>, + pub dry_run: bool, pub save: bool, - pub save_session: Option<bool>, - pub highlight: bool, - pub light_theme: bool, + pub keybindings: Keybindings, + pub buffer_editor: Option<String>, pub wrap: Option<String>, pub wrap_code: bool, - pub keybindings: Keybindings, + pub prelude: Option<String>, pub repl_prelude: Option<String>, - pub buffer_editor: Option<String>, + pub agent_prelude: Option<String>, + + pub save_session: Option<bool>, + pub compress_threshold: usize, + pub summarize_prompt: Option<String>, + pub summary_prompt: Option<String>, + pub function_calling: bool, pub dangerously_functions_filter: Option<FunctionsFilter>, - pub agent_prelude: Option<String>, pub agents: Vec<AgentConfig>, + pub rag_embedding_model: Option<String>, pub rag_rerank_model: Option<String>, + pub rag_top_k: usize, pub rag_chunk_size: Option<usize>, pub rag_chunk_overlap: Option<usize>, - pub rag_top_k: usize, pub rag_min_score_vector_search: f32, pub rag_min_score_keyword_search: f32, pub rag_min_score_rerank: f32, pub rag_template: Option<String>, - pub compress_threshold: usize, - pub summarize_prompt: Option<String>, - pub summary_prompt: Option<String>, + + pub highlight: bool, + pub light_theme: bool, pub left_prompt: Option<String>, pub right_prompt: Option<String>, + pub clients: Vec<ClientConfig>, + #[serde(skip)] pub roles: Vec<Role>, #[serde(skip)] @@ -142,36 +150,44 @@ impl Default for Config { model_id: Default::default(), temperature: None, top_p: None, - save: false, - save_session: None, - highlight: true, + dry_run: false, - light_theme: false, + save: false, + keybindings: Default::default(), + buffer_editor: None, wrap: None, wrap_code: false, - keybindings: Default::default(), + prelude: None, repl_prelude: None, - buffer_editor: None, + agent_prelude: None, + function_calling: false, dangerously_functions_filter: None, - agent_prelude: None, agents: vec![], + rag_embedding_model: None, rag_rerank_model: None, + rag_top_k: 4, rag_chunk_size: None, rag_chunk_overlap: None, - rag_top_k: 4, rag_min_score_vector_search: 0.0, rag_min_score_keyword_search: 0.0, rag_min_score_rerank: 0.0, rag_template: None, + + save_session: None, compress_threshold: 4000, summarize_prompt: None, summary_prompt: None, + + highlight: true, + light_theme: false, left_prompt: None, right_prompt: None, + clients: vec![], + roles: vec![], role: None, session: None, @@ -453,22 +469,21 @@ impl Config { ), ("temperature", format_option_value(&role.temperature())), ("top_p", format_option_value(&role.top_p())), + ("dry_run", self.dry_run.to_string()), + ("save", self.save.to_string()), + ("keybindings", self.keybindings.stringify().into()), + ("wrap", wrap), + ("wrap_code", self.wrap_code.to_string()), + ("save_session", format_option_value(&self.save_session)), + ("compress_threshold", self.compress_threshold.to_string()), + ("function_calling", self.function_calling.to_string()), ( "rag_rerank_model", format_option_value(&self.rag_rerank_model), ), ("rag_top_k", self.rag_top_k.to_string()), - ("function_calling", self.function_calling.to_string()), - ("compress_threshold", self.compress_threshold.to_string()), - ("dry_run", self.dry_run.to_string()), - ("save", self.save.to_string()), - ("save_session", format_option_value(&self.save_session)), ("highlight", self.highlight.to_string()), ("light_theme", self.light_theme.to_string()), - ("wrap", wrap), - ("wrap_code", self.wrap_code.to_string()), - ("keybindings", self.keybindings.stringify().into()), - ("prelude", format_option_value(&self.prelude)), ("config_file", display_path(&Self::config_file()?)), ("roles_file", display_path(&Self::roles_file()?)), ("functions_dir", display_path(&Self::functions_dir()?)), |
