MCPcopy
hub / github.com/algorithmicsuperintelligence/optillm / get_config

Function get_config

optillm/server.py:62–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60conversation_logger = None
61
62def get_config():
63 import httpx
64
65 API_KEY = None
66
67 # Create httpx client with SSL configuration
68 ssl_verify = server_config.get('ssl_verify', True)
69 ssl_cert_path = server_config.get('ssl_cert_path', '')
70
71 # Determine SSL verification setting
72 if not ssl_verify:
73 logger.warning("SSL certificate verification is DISABLED. This is insecure and should only be used for development.")
74 http_client = httpx.Client(verify=False)
75 elif ssl_cert_path:
76 logger.info(f"Using custom CA certificate bundle: {ssl_cert_path}")
77 http_client = httpx.Client(verify=ssl_cert_path)
78 else:
79 http_client = httpx.Client(verify=True)
80
81 if os.environ.get("OPTILLM_API_KEY"):
82 # Use local inference engine
83 from optillm.inference import create_inference_client
84 API_KEY = os.environ.get("OPTILLM_API_KEY")
85 default_client = create_inference_client()
86 # Cerebras, OpenAI, Azure, or LiteLLM API configuration
87 elif os.environ.get("CEREBRAS_API_KEY"):
88 API_KEY = os.environ.get("CEREBRAS_API_KEY")
89 base_url = server_config['base_url']
90 if base_url != "":
91 default_client = Cerebras(api_key=API_KEY, base_url=base_url, http_client=http_client)
92 else:
93 default_client = Cerebras(api_key=API_KEY, http_client=http_client)
94 elif os.environ.get("OPENAI_API_KEY"):
95 API_KEY = os.environ.get("OPENAI_API_KEY")
96 base_url = server_config['base_url']
97 if base_url != "":
98 default_client = OpenAI(api_key=API_KEY, base_url=base_url, http_client=http_client)
99 logger.info(f"Created OpenAI client with base_url: {base_url}")
100 else:
101 default_client = OpenAI(api_key=API_KEY, http_client=http_client)
102 logger.info("Created OpenAI client without base_url")
103 elif os.environ.get("AZURE_OPENAI_API_KEY"):
104 API_KEY = os.environ.get("AZURE_OPENAI_API_KEY")
105 API_VERSION = os.environ.get("AZURE_API_VERSION")
106 AZURE_ENDPOINT = os.environ.get("AZURE_API_BASE")
107 if API_KEY is not None:
108 default_client = AzureOpenAI(
109 api_key=API_KEY,
110 api_version=API_VERSION,
111 azure_endpoint=AZURE_ENDPOINT,
112 http_client=http_client
113 )
114 else:
115 from azure.identity import DefaultAzureCredential, get_bearer_token_provider
116 azure_credential = DefaultAzureCredential()
117 token_provider = get_bearer_token_provider(azure_credential, "https://cognitiveservices.azure.com/.default")
118 default_client = AzureOpenAI(
119 api_version=API_VERSION,

Calls 2

create_inference_clientFunction · 0.90
LiteLLMWrapperClass · 0.90