5858conversation_logger = None
5959
6060def get_config ():
61+ import httpx
62+
6163 API_KEY = None
64+
65+ # Create httpx client with SSL configuration
66+ ssl_verify = server_config .get ('ssl_verify' , True )
67+ ssl_cert_path = server_config .get ('ssl_cert_path' , '' )
68+
69+ # Determine SSL verification setting
70+ if not ssl_verify :
71+ logger .warning ("SSL certificate verification is DISABLED. This is insecure and should only be used for development." )
72+ http_client = httpx .Client (verify = False )
73+ elif ssl_cert_path :
74+ logger .info (f"Using custom CA certificate bundle: { ssl_cert_path } " )
75+ http_client = httpx .Client (verify = ssl_cert_path )
76+ else :
77+ http_client = httpx .Client (verify = True )
78+
6279 if os .environ .get ("OPTILLM_API_KEY" ):
6380 # Use local inference engine
6481 from optillm .inference import create_inference_client
@@ -69,16 +86,16 @@ def get_config():
6986 API_KEY = os .environ .get ("CEREBRAS_API_KEY" )
7087 base_url = server_config ['base_url' ]
7188 if base_url != "" :
72- default_client = Cerebras (api_key = API_KEY , base_url = base_url )
89+ default_client = Cerebras (api_key = API_KEY , base_url = base_url , http_client = http_client )
7390 else :
74- default_client = Cerebras (api_key = API_KEY )
91+ default_client = Cerebras (api_key = API_KEY , http_client = http_client )
7592 elif os .environ .get ("OPENAI_API_KEY" ):
7693 API_KEY = os .environ .get ("OPENAI_API_KEY" )
7794 base_url = server_config ['base_url' ]
7895 if base_url != "" :
79- default_client = OpenAI (api_key = API_KEY , base_url = base_url )
96+ default_client = OpenAI (api_key = API_KEY , base_url = base_url , http_client = http_client )
8097 else :
81- default_client = OpenAI (api_key = API_KEY )
98+ default_client = OpenAI (api_key = API_KEY , http_client = http_client )
8299 elif os .environ .get ("AZURE_OPENAI_API_KEY" ):
83100 API_KEY = os .environ .get ("AZURE_OPENAI_API_KEY" )
84101 API_VERSION = os .environ .get ("AZURE_API_VERSION" )
@@ -88,6 +105,7 @@ def get_config():
88105 api_key = API_KEY ,
89106 api_version = API_VERSION ,
90107 azure_endpoint = AZURE_ENDPOINT ,
108+ http_client = http_client
91109 )
92110 else :
93111 from azure .identity import DefaultAzureCredential , get_bearer_token_provider
@@ -96,7 +114,8 @@ def get_config():
96114 default_client = AzureOpenAI (
97115 api_version = API_VERSION ,
98116 azure_endpoint = AZURE_ENDPOINT ,
99- azure_ad_token_provider = token_provider
117+ azure_ad_token_provider = token_provider ,
118+ http_client = http_client
100119 )
101120 else :
102121 # Import the LiteLLM wrapper
@@ -152,7 +171,7 @@ def count_reasoning_tokens(text: str, tokenizer=None) -> int:
152171
153172# Server configuration
154173server_config = {
155- 'approach' : 'none' ,
174+ 'approach' : 'none' ,
156175 'mcts_simulations' : 2 ,
157176 'mcts_exploration' : 0.2 ,
158177 'mcts_depth' : 1 ,
@@ -167,6 +186,8 @@ def count_reasoning_tokens(text: str, tokenizer=None) -> int:
167186 'return_full_response' : False ,
168187 'port' : 8000 ,
169188 'log' : 'info' ,
189+ 'ssl_verify' : True ,
190+ 'ssl_cert_path' : '' ,
170191}
171192
172193# List of known approaches
@@ -977,7 +998,19 @@ def parse_args():
977998 base_url_default = os .environ .get ("OPTILLM_BASE_URL" , "" )
978999 parser .add_argument ("--base-url" , "--base_url" , dest = "base_url" , type = str , default = base_url_default ,
9791000 help = "Base url for OpenAI compatible endpoint" )
980-
1001+
1002+ # SSL configuration arguments
1003+ ssl_verify_default = os .environ .get ("OPTILLM_SSL_VERIFY" , "true" ).lower () in ("true" , "1" , "yes" )
1004+ parser .add_argument ("--ssl-verify" , dest = "ssl_verify" , action = "store_true" if ssl_verify_default else "store_false" ,
1005+ default = ssl_verify_default ,
1006+ help = "Enable SSL certificate verification (default: True)" )
1007+ parser .add_argument ("--no-ssl-verify" , dest = "ssl_verify" , action = "store_false" ,
1008+ help = "Disable SSL certificate verification" )
1009+
1010+ ssl_cert_path_default = os .environ .get ("OPTILLM_SSL_CERT_PATH" , "" )
1011+ parser .add_argument ("--ssl-cert-path" , dest = "ssl_cert_path" , type = str , default = ssl_cert_path_default ,
1012+ help = "Path to custom CA certificate bundle for SSL verification" )
1013+
9811014 # Use the function to get the default path
9821015 default_config_path = get_config_path ()
9831016
0 commit comments