From ba3bcfd67c1d6fea5d3d3c5908c975682ee7909b Mon Sep 17 00:00:00 2001 From: sigoden Date: Wed, 22 May 2024 21:29:23 +0800 Subject: feat: allow patching req body with client config (#534) --- src/client/openai.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/client/openai.rs') 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, #[serde(default)] pub models: Vec, + pub patches: Option, pub extra: Option, } @@ -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"); -- cgit v1.2.3