summaryrefslogtreecommitdiffstats
path: root/src/client/openai.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-05-22 21:29:23 +0800
committerGitHub <noreply@github.com>2024-05-22 21:29:23 +0800
commitba3bcfd67c1d6fea5d3d3c5908c975682ee7909b (patch)
tree29811c719f131f946cd37634507885ee8c63534d /src/client/openai.rs
parent91a06543b24733cf578f3f2d4cb0884e2b18cf2f (diff)
downloadaichat-ba3bcfd67c1d6fea5d3d3c5908c975682ee7909b.tar.gz
feat: allow patching req body with client config (#534)
Diffstat (limited to 'src/client/openai.rs')
-rw-r--r--src/client/openai.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/client/openai.rs b/src/client/openai.rs
index f2fd222..c8275cc 100644
--- a/src/client/openai.rs
+++ b/src/client/openai.rs
@@ -1,6 +1,7 @@
use super::{
- catch_error, message::*, sse_stream, CompletionOutput, ExtraConfig, Model, ModelData,
- OpenAIClient, PromptAction, PromptKind, SendData, SsMmessage, SseHandler, ToolCall,
+ catch_error, message::*, sse_stream, Client, CompletionOutput, ExtraConfig, Model, ModelData,
+ ModelPatches, OpenAIClient, PromptAction, PromptKind, SendData, SsMmessage, SseHandler,
+ ToolCall,
};
use anyhow::{bail, Result};
@@ -18,6 +19,7 @@ pub struct OpenAIConfig {
pub organization_id: Option<String>,
#[serde(default)]
pub models: Vec<ModelData>,
+ pub patches: Option<ModelPatches>,
pub extra: Option<ExtraConfig>,
}
@@ -32,7 +34,8 @@ impl OpenAIClient {
let api_key = self.get_api_key()?;
let api_base = self.get_api_base().unwrap_or_else(|_| API_BASE.to_string());
- let body = openai_build_body(data, &self.model);
+ let mut body = openai_build_body(data, &self.model);
+ self.patch_request_body(&mut body);
let url = format!("{api_base}/chat/completions");