File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change 99 * File Created: 2025-03-01 21:55:58
1010 *
1111 * Modified By: mingcheng ([email protected] ) 12- * Last Modified: 2025-03-05 10:46:26
12+ * Last Modified: 2025-03-06 17:59:08
1313 */
1414
1515use askama:: Template ;
@@ -66,17 +66,23 @@ impl OpenAI {
6666 } ) ;
6767
6868 // Set up proxy if specified
69- let proxy_addr = env:: var ( "OPENAI_APT_PROXY" ) . unwrap_or_else ( |_| String :: from ( "" ) ) ;
69+ let proxy_addr: String = env:: var ( "OPENAI_APT_PROXY" ) . unwrap_or_else ( |_| String :: from ( "" ) ) ;
7070 if !proxy_addr. is_empty ( ) {
7171 trace ! ( "Using proxy: {}" , proxy_addr) ;
7272 http_client_builder = http_client_builder. proxy ( Proxy :: all ( proxy_addr) . unwrap ( ) ) ;
7373 }
7474
75+ let request_timeout =
76+ env:: var ( "OPENAI_REQUEST_TIMEOUT" ) . unwrap_or_else ( |_| String :: from ( "" ) ) ;
77+ if !request_timeout. is_empty ( ) {
78+ if let Ok ( timeout) = request_timeout. parse :: < u64 > ( ) {
79+ trace ! ( "Setting request timeout to: {}ms" , request_timeout) ;
80+ http_client_builder = http_client_builder. timeout ( Duration :: from_millis ( timeout) ) ;
81+ }
82+ }
83+
7584 // Set up timeout and build the HTTP client
76- let http_client = http_client_builder
77- . timeout ( Duration :: from_secs ( 10 ) )
78- . build ( )
79- . unwrap ( ) ;
85+ let http_client = http_client_builder. build ( ) . unwrap ( ) ;
8086
8187 let client = Client :: with_config ( ai_config) . with_http_client ( http_client) ;
8288 OpenAI { client }
You can’t perform that action at this time.
0 commit comments