diff options
| author | sigoden <sigoden@gmail.com> | 2025-02-03 22:35:01 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-03 22:35:01 +0800 |
| commit | 700d8a3245f1133c37e035039e511a1e5dce1a5d (patch) | |
| tree | 7b1b2cf2e816adb0af399c9ca34051d3fcbef47f /src/config | |
| parent | 07e58aaacd8c7f486a0d2a7c8d35a195f27d487e (diff) | |
| download | aichat-700d8a3245f1133c37e035039e511a1e5dce1a5d.tar.gz | |
feat: strip reasoning contents (#1141)
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/input.rs | 7 | ||||
| -rw-r--r-- | src/config/mod.rs | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/config/input.rs b/src/config/input.rs index e468f19..482b1d5 100644 --- a/src/config/input.rs +++ b/src/config/input.rs @@ -244,6 +244,13 @@ impl Input { init_client(&self.config, Some(self.role().model().clone())) } + pub async fn fetch_chat_text(&self) -> Result<String> { + let client = self.create_client()?; + let text = client.chat_completions(self.clone()).await?.text; + let text = strip_think_tag(&text).to_string(); + Ok(text) + } + pub fn prepare_completion_data( &self, model: &Model, diff --git a/src/config/mod.rs b/src/config/mod.rs index c9efd72..38f2f79 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1262,8 +1262,7 @@ impl Config { .clone() .unwrap_or_else(|| SUMMARIZE_PROMPT.into()); let input = Input::from_str(config, &prompt, None); - let client = input.create_client()?; - let summary = client.chat_completions(input).await?.text; + let summary = input.fetch_chat_text().await?; let summary_prompt = config .read() .summary_prompt @@ -1322,8 +1321,7 @@ impl Config { }; let role = config.read().retrieve_role(CREATE_TITLE_ROLE)?; let input = Input::from_str(config, &text, Some(role)); - let client = input.create_client()?; - let text = client.chat_completions(input).await?.text; + let text = input.fetch_chat_text().await?; if let Some(session) = config.write().session.as_mut() { session.set_autoname(&text); } |
