File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -21,4 +21,4 @@ default-features = false
2121[dependencies .minreq ]
2222version = " 2"
2323default-features = false
24- features = [" https-rustls" , " json-using-serde" ]
24+ features = [" https-rustls" , " json-using-serde" , " proxy " ]
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ pub struct Client {
4747 pub api_endpoint : String ,
4848 pub api_key : String ,
4949 pub organization : Option < String > ,
50+ pub proxy : Option < String > ,
5051}
5152
5253impl Client {
@@ -60,6 +61,7 @@ impl Client {
6061 api_endpoint,
6162 api_key,
6263 organization : None ,
64+ proxy : None ,
6365 }
6466 }
6567
@@ -69,6 +71,17 @@ impl Client {
6971 api_endpoint : endpoint,
7072 api_key,
7173 organization : organization. into ( ) ,
74+ proxy : None ,
75+ }
76+ }
77+
78+ pub fn new_with_proxy ( api_key : String , proxy : String ) -> Self {
79+ let endpoint = std:: env:: var ( "OPENAI_API_BASE" ) . unwrap_or_else ( |_| API_URL_V1 . to_owned ( ) ) ;
80+ Self {
81+ api_endpoint : endpoint,
82+ api_key,
83+ organization : None ,
84+ proxy : Some ( proxy) ,
7285 }
7386 }
7487
@@ -82,6 +95,9 @@ impl Client {
8295 if is_beta {
8396 request = request. with_header ( "OpenAI-Beta" , "assistants=v1" ) ;
8497 }
98+ if let Some ( proxy) = & self . proxy {
99+ request = request. with_proxy ( minreq:: Proxy :: new ( proxy) . unwrap ( ) ) ;
100+ }
85101 request
86102 }
87103
You can’t perform that action at this time.
0 commit comments