5959conversation_logger = None
6060
6161def get_config ():
62+ import httpx
63+
6264 API_KEY = None
65+
66+ # Create httpx client with SSL configuration
67+ ssl_verify = server_config .get ('ssl_verify' , True )
68+ ssl_cert_path = server_config .get ('ssl_cert_path' , '' )
69+
70+ # Determine SSL verification setting
71+ if not ssl_verify :
72+ logger .warning ("SSL certificate verification is DISABLED. This is insecure and should only be used for development." )
73+ http_client = httpx .Client (verify = False )
74+ elif ssl_cert_path :
75+ logger .info (f"Using custom CA certificate bundle: { ssl_cert_path } " )
76+ http_client = httpx .Client (verify = ssl_cert_path )
77+ else :
78+ http_client = httpx .Client (verify = True )
79+
6380 if os .environ .get ("OPTILLM_API_KEY" ):
6481 # Use local inference engine
6582 from optillm .inference import create_inference_client
@@ -70,9 +87,9 @@ def get_config():
7087 API_KEY = os .environ .get ("CEREBRAS_API_KEY" )
7188 base_url = server_config ['base_url' ]
7289 if base_url != "" :
73- default_client = Cerebras (api_key = API_KEY , base_url = base_url )
90+ default_client = Cerebras (api_key = API_KEY , base_url = base_url , http_client = http_client )
7491 else :
75- default_client = Cerebras (api_key = API_KEY )
92+ default_client = Cerebras (api_key = API_KEY , http_client = http_client )
7693 elif os .environ .get ("OPENAI_API_KEY" ):
7794 API_KEY = os .environ .get ("OPENAI_API_KEY" )
7895 base_url = server_config ['base_url' ]
@@ -91,6 +108,7 @@ def get_config():
91108 api_key = API_KEY ,
92109 api_version = API_VERSION ,
93110 azure_endpoint = AZURE_ENDPOINT ,
111+ http_client = http_client
94112 )
95113 else :
96114 from azure .identity import DefaultAzureCredential , get_bearer_token_provider
@@ -99,7 +117,8 @@ def get_config():
99117 default_client = AzureOpenAI (
100118 api_version = API_VERSION ,
101119 azure_endpoint = AZURE_ENDPOINT ,
102- azure_ad_token_provider = token_provider
120+ azure_ad_token_provider = token_provider ,
121+ http_client = http_client
103122 )
104123 else :
105124 # Import the LiteLLM wrapper
@@ -157,7 +176,7 @@ def count_reasoning_tokens(text: str, tokenizer=None) -> int:
157176
158177# Server configuration
159178server_config = {
160- 'approach' : 'none' ,
179+ 'approach' : 'none' ,
161180 'mcts_simulations' : 2 ,
162181 'mcts_exploration' : 0.2 ,
163182 'mcts_depth' : 1 ,
@@ -172,6 +191,8 @@ def count_reasoning_tokens(text: str, tokenizer=None) -> int:
172191 'return_full_response' : False ,
173192 'port' : 8000 ,
174193 'log' : 'info' ,
194+ 'ssl_verify' : True ,
195+ 'ssl_cert_path' : '' ,
175196}
176197
177198# List of known approaches
@@ -984,7 +1005,19 @@ def parse_args():
9841005 base_url_default = os .environ .get ("OPTILLM_BASE_URL" , "" )
9851006 parser .add_argument ("--base-url" , "--base_url" , dest = "base_url" , type = str , default = base_url_default ,
9861007 help = "Base url for OpenAI compatible endpoint" )
987-
1008+
1009+ # SSL configuration arguments
1010+ ssl_verify_default = os .environ .get ("OPTILLM_SSL_VERIFY" , "true" ).lower () in ("true" , "1" , "yes" )
1011+ parser .add_argument ("--ssl-verify" , dest = "ssl_verify" , action = "store_true" if ssl_verify_default else "store_false" ,
1012+ default = ssl_verify_default ,
1013+ help = "Enable SSL certificate verification (default: True)" )
1014+ parser .add_argument ("--no-ssl-verify" , dest = "ssl_verify" , action = "store_false" ,
1015+ help = "Disable SSL certificate verification" )
1016+
1017+ ssl_cert_path_default = os .environ .get ("OPTILLM_SSL_CERT_PATH" , "" )
1018+ parser .add_argument ("--ssl-cert-path" , dest = "ssl_cert_path" , type = str , default = ssl_cert_path_default ,
1019+ help = "Path to custom CA certificate bundle for SSL verification" )
1020+
9881021 # Use the function to get the default path
9891022 default_config_path = get_config_path ()
9901023
0 commit comments