summaryrefslogtreecommitdiffstats
path: root/src/config
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2025-02-03 22:35:01 +0800
committerGitHub <noreply@github.com>2025-02-03 22:35:01 +0800
commit700d8a3245f1133c37e035039e511a1e5dce1a5d (patch)
tree7b1b2cf2e816adb0af399c9ca34051d3fcbef47f /src/config
parent07e58aaacd8c7f486a0d2a7c8d35a195f27d487e (diff)
downloadaichat-700d8a3245f1133c37e035039e511a1e5dce1a5d.tar.gz
feat: strip reasoning contents (#1141)
Diffstat (limited to 'src/config')
-rw-r--r--src/config/input.rs7
-rw-r--r--src/config/mod.rs6
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);
}