@@ -12,9 +12,7 @@ pub const OPENAI_ORGANIZATION_HEADER: &str = "OpenAI-Organization";
12
12
/// Calls to the Assistants API require that you pass a Beta header
13
13
pub const OPENAI_BETA_HEADER : & str = "OpenAI-Beta" ;
14
14
15
- /// [crate::Client] relies on this for every API call on OpenAI
16
- /// or Azure OpenAI service
17
- pub trait Config : ' static + Debug + Send + Sync {
15
+ pub trait BaseConfig : ' static + Debug + Send + Sync {
18
16
fn headers ( & self ) -> HeaderMap ;
19
17
fn url ( & self , path : & str ) -> String ;
20
18
fn query ( & self ) -> Vec < ( & str , & str ) > ;
@@ -24,6 +22,18 @@ pub trait Config: 'static + Debug + Send + Sync {
24
22
fn api_key ( & self ) -> & Secret < String > ;
25
23
}
26
24
25
+ /// [crate::Client] relies on this for every API call on OpenAI
26
+ /// or Azure OpenAI service
27
+ pub trait Config < Extra = ( ) > : BaseConfig {
28
+ fn extra_configs ( & self ) -> & Extra ;
29
+ }
30
+
31
+ impl < T : BaseConfig > Config < ( ) > for T {
32
+ fn extra_configs ( & self ) -> & ( ) {
33
+ & ( )
34
+ }
35
+ }
36
+
27
37
/// Configuration for OpenAI API
28
38
#[ derive( Clone , Debug , Deserialize ) ]
29
39
#[ serde( default ) ]
@@ -74,7 +84,7 @@ impl OpenAIConfig {
74
84
}
75
85
}
76
86
77
- impl Config for OpenAIConfig {
87
+ impl BaseConfig for OpenAIConfig {
78
88
fn headers ( & self ) -> HeaderMap {
79
89
let mut headers = HeaderMap :: new ( ) ;
80
90
if !self . org_id . is_empty ( ) {
@@ -167,7 +177,7 @@ impl AzureConfig {
167
177
}
168
178
}
169
179
170
- impl Config for AzureConfig {
180
+ impl BaseConfig for AzureConfig {
171
181
fn headers ( & self ) -> HeaderMap {
172
182
let mut headers = HeaderMap :: new ( ) ;
173
183
0 commit comments