summaryrefslogtreecommitdiffstats
path: root/src/client/common.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-05-14 11:16:55 +0800
committerGitHub <noreply@github.com>2024-05-14 11:16:55 +0800
commit5284a18248bb8e48eaa4a1e6ddcf73d944d23783 (patch)
treefe60e7b0be7c4ea40051f40f88362e0487da6355 /src/client/common.rs
parent154c1e0b4b7fad08094c601893b081581d2ee0c8 (diff)
downloadaichat-5284a18248bb8e48eaa4a1e6ddcf73d944d23783.tar.gz
refactor: config::Input (#503)
Diffstat (limited to 'src/client/common.rs')
-rw-r--r--src/client/common.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/client/common.rs b/src/client/common.rs
index 24e6f8e..495160b 100644
--- a/src/client/common.rs
+++ b/src/client/common.rs
@@ -290,11 +290,11 @@ pub trait Client: Sync + Send {
async fn send_message(&self, input: Input) -> Result<(String, CompletionDetails)> {
let global_config = self.config().0;
if global_config.read().dry_run {
- let content = global_config.read().echo_messages(&input);
+ let content = input.echo_messages();
return Ok((content, CompletionDetails::default()));
}
let client = self.build_client()?;
- let data = global_config.read().prepare_send_data(&input, false)?;
+ let data = input.prepare_send_data(false)?;
self.send_message_inner(&client, data)
.await
.with_context(|| "Failed to get answer")
@@ -315,7 +315,7 @@ pub trait Client: Sync + Send {
ret = async {
let global_config = self.config().0;
if global_config.read().dry_run {
- let content = global_config.read().echo_messages(&input);
+ let content = input.echo_messages();
let tokens = tokenize(&content);
for token in tokens {
tokio::time::sleep(Duration::from_millis(10)).await;
@@ -324,7 +324,7 @@ pub trait Client: Sync + Send {
return Ok(());
}
let client = self.build_client()?;
- let data = global_config.read().prepare_send_data(&input, true)?;
+ let data = input.prepare_send_data(true)?;
self.send_message_streaming_inner(&client, handler, data).await
} => {
handler.done()?;