diff options
| author | aichat-agent <agent@aichat.local> | 2026-10-01 14:58:06 +0000 |
|---|---|---|
| committer | aichat-agent <agent@aichat.local> | 2026-10-01 15:54:19 +0000 |
| commit | 83a2cd1ac24ca0feda34ae877aaf31f41b58b86c (patch) | |
| tree | cbc83678fa05fe6a82908c448a4e20eae673a9c7 /src/config/input.rs | |
| parent | 82976d349ad97ac9aae0655ad631dace5e2a6385 (diff) | |
| download | aichat-83a2cd1ac24ca0feda34ae877aaf31f41b58b86c.tar.gz | |
feat: add built-in subquery tool with hierarchical query ids
* Add config options subquery and subquery_max_depth.
* Register an internal subquery function that spawns a fresh LLM query
with the current model configuration but without the full context.
The model selects context numerically (message_indexes) or by text
excerpt (excerpts).
* Subqueries can use tools, including further nested subqueries up to
subquery_max_depth.
* Queries and subqueries get hierarchical ids ([0], [0/1], [0/1/2])
that prefix tool-call prints and spinner messages.
Diffstat (limited to 'src/config/input.rs')
| -rw-r--r-- | src/config/input.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/config/input.rs b/src/config/input.rs index d6d154b..71807f3 100644 --- a/src/config/input.rs +++ b/src/config/input.rs @@ -27,6 +27,13 @@ pub struct Input { medias: Vec<String>, data_urls: HashMap<String, String>, tool_calls: Option<MessageContentToolCalls>, + query_path: Vec<u64>, + subquery_data: Option<( + Vec<Message>, + Option<f64>, + Option<f64>, + Option<Vec<crate::function::FunctionDeclaration>>, + )>, role: Role, rag_name: Option<String>, with_session: bool, @@ -47,6 +54,8 @@ impl Input { medias: Default::default(), data_urls: Default::default(), tool_calls: None, + query_path: vec![], + subquery_data: None, role, rag_name: None, with_session, @@ -114,6 +123,8 @@ impl Input { medias, data_urls, tool_calls: Default::default(), + query_path: vec![], + subquery_data: None, role, rag_name: None, with_session, @@ -167,6 +178,25 @@ impl Input { self.config.read().stream && !self.role().model().no_stream() } + pub fn query_path(&self) -> Vec<u64> { + self.query_path.clone() + } + + pub fn set_query_path(&mut self, path: Vec<u64>) { + self.query_path = path; + } + + pub fn set_subquery( + &mut self, + messages: Vec<Message>, + temperature: Option<f64>, + top_p: Option<f64>, + functions: Option<Vec<crate::function::FunctionDeclaration>>, + ) { + self.subquery_data = Some((messages, temperature, top_p, functions)); + self.with_session = false; + } + pub fn continue_output(&self) -> Option<&str> { self.continue_output.as_deref() } @@ -235,6 +265,17 @@ impl Input { model: &Model, stream: bool, ) -> Result<ChatCompletionsData> { + if let Some((subquery_messages, subquery_temperature, subquery_top_p, subquery_functions)) = + &self.subquery_data + { + return Ok(crate::client::ChatCompletionsData { + messages: subquery_messages.clone(), + temperature: *subquery_temperature, + top_p: *subquery_top_p, + functions: subquery_functions.clone(), + stream, + }); + } let mut messages = self.build_messages()?; patch_messages(&mut messages, model); model.guard_max_input_tokens(&messages)?; |
