File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ use crate::{
1111 error:: ServerError ,
1212 server:: RustDocsServer , // Import the updated RustDocsServer
1313} ;
14- use async_openai:: Client as OpenAIClient ;
14+ use async_openai:: { Client as OpenAIClient , config :: OpenAIConfig } ;
1515use bincode:: config;
1616use cargo:: core:: PackageIdSpec ;
1717use clap:: Parser ; // Import clap Parser
@@ -182,7 +182,12 @@ async fn main() -> Result<(), ServerError> {
182182 let mut documents_for_server: Vec < Document > = loaded_documents_from_cache. unwrap_or_default ( ) ;
183183
184184 // --- Initialize OpenAI Client (needed for question embedding even if cache hit) ---
185- let openai_client = OpenAIClient :: new ( ) ;
185+ let openai_client = if let Ok ( api_base) = env:: var ( "OPENAI_API_BASE" ) {
186+ let config = OpenAIConfig :: new ( ) . with_api_base ( api_base) ;
187+ OpenAIClient :: with_config ( config)
188+ } else {
189+ OpenAIClient :: new ( )
190+ } ;
186191 OPENAI_CLIENT
187192 . set ( openai_client. clone ( ) ) // Clone the client for the OnceCell
188193 . expect ( "Failed to set OpenAI client" ) ;
You can’t perform that action at this time.
0 commit comments