diff options
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); } |
