Add support for self-signed certs from model providers (#276)

* Add support for self-signed certs from model providers

* cleanup

---------

Co-authored-by: tonydoesathing <tmastromarino@cpacket.com>
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
Tony M
2025-06-25 19:17:26 -07:00
committed by GitHub
parent 9c2d4724e3
commit b7373fbe70
3 changed files with 31 additions and 1 deletions

View File

@@ -4,6 +4,8 @@
from pathlib import Path
from typing import Any, Dict
import os
import ssl
import httpx
from langchain_openai import ChatOpenAI
from langchain_deepseek import ChatDeepSeek
@@ -71,6 +73,16 @@ def _create_llm_use_conf(
if llm_type == "reasoning":
merged_conf["api_base"] = merged_conf.pop("base_url", None)
# Handle SSL verification settings
verify_ssl = merged_conf.pop("verify_ssl", True)
# Create custom HTTP client if SSL verification is disabled
if not verify_ssl:
http_client = httpx.Client(verify=False)
http_async_client = httpx.AsyncClient(verify=False)
merged_conf["http_client"] = http_client
merged_conf["http_async_client"] = http_async_client
return (
ChatOpenAI(**merged_conf)
if llm_type != "reasoning"
@@ -78,6 +90,7 @@ def _create_llm_use_conf(
)
def get_llm_by_type(
llm_type: LLMType,
) -> ChatOpenAI: