summaryrefslogtreecommitdiffstats
path: root/src/client/qianwen.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-05-30 17:10:02 +0800
committerGitHub <noreply@github.com>2024-05-30 17:10:02 +0800
commit54a837784c3df7e73c7c95adfef96e68c842984b (patch)
treee090da40436bd3c1220d5ab88071ac33397ce57c /src/client/qianwen.rs
parentfa4bf14e02b1e6361b38014fe6a986738cf06837 (diff)
downloadaichat-54a837784c3df7e73c7c95adfef96e68c842984b.tar.gz
refactor: rename `SendData` to `CompletionData` (#553)
Diffstat (limited to 'src/client/qianwen.rs')
-rw-r--r--src/client/qianwen.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/client/qianwen.rs b/src/client/qianwen.rs
index 2063f20..3f4b73a 100644
--- a/src/client/qianwen.rs
+++ b/src/client/qianwen.rs
@@ -1,7 +1,7 @@
use super::{
- maybe_catch_error, message::*, sse_stream, Client, CompletionOutput, ExtraConfig, Model,
- ModelData, ModelPatches, PromptAction, PromptKind, QianwenClient, SendData, SseHandler,
- SseMmessage,
+ maybe_catch_error, message::*, sse_stream, Client, CompletionData, CompletionOutput,
+ ExtraConfig, Model, ModelData, ModelPatches, PromptAction, PromptKind, QianwenClient,
+ SseHandler, SseMmessage,
};
use crate::utils::{base64_decode, sha256};
@@ -38,7 +38,11 @@ impl QianwenClient {
pub const PROMPTS: [PromptAction<'static>; 1] =
[("api_key", "API Key:", true, PromptKind::String)];
- fn request_builder(&self, client: &ReqwestClient, data: SendData) -> Result<RequestBuilder> {
+ fn request_builder(
+ &self,
+ client: &ReqwestClient,
+ data: CompletionData,
+ ) -> Result<RequestBuilder> {
let api_key = self.get_api_key()?;
let stream = data.stream;
@@ -71,7 +75,7 @@ impl Client for QianwenClient {
async fn send_message_inner(
&self,
client: &ReqwestClient,
- mut data: SendData,
+ mut data: CompletionData,
) -> Result<CompletionOutput> {
let api_key = self.get_api_key()?;
patch_messages(self.model.name(), &api_key, &mut data.messages).await?;
@@ -83,7 +87,7 @@ impl Client for QianwenClient {
&self,
client: &ReqwestClient,
handler: &mut SseHandler,
- mut data: SendData,
+ mut data: CompletionData,
) -> Result<()> {
let api_key = self.get_api_key()?;
patch_messages(self.model.name(), &api_key, &mut data.messages).await?;
@@ -129,8 +133,8 @@ async fn send_message_streaming(
sse_stream(builder, handle).await
}
-fn build_body(data: SendData, model: &Model) -> Result<(Value, bool)> {
- let SendData {
+fn build_body(data: CompletionData, model: &Model) -> Result<(Value, bool)> {
+ let CompletionData {
messages,
temperature,
top_p,