2
2
3
3
from typing import Annotated , Literal , Self
4
4
5
+ from httpx import AsyncClient , Client
5
6
from pydantic import (
6
7
BaseModel ,
7
8
BeforeValidator ,
@@ -80,6 +81,7 @@ class LLMConfiguration(BaseModel):
80
81
"""Configuration for the LLM model."""
81
82
82
83
base_url : str | None = Field (default = None , alias = "baseURL" )
84
+ skip_tls_verify : bool | None = Field (default = None )
83
85
temperature : float | None = Field (default = 0 )
84
86
top_p : float | None = Field (default = None )
85
87
@@ -90,6 +92,8 @@ def to_load_model_kwargs(self) -> dict:
90
92
kwargs = {}
91
93
if self .base_url :
92
94
kwargs ["base_url" ] = self .base_url
95
+ if self .skip_tls_verify :
96
+ kwargs ["skip_tls_verify" ] = self .skip_tls_verify
93
97
if self .temperature :
94
98
kwargs ["temperature" ] = self .temperature
95
99
if self .top_p :
@@ -125,6 +129,16 @@ def to_load_model_kwargs(self: LLMConfig) -> dict:
125
129
remove_keys = []
126
130
if self .model_provider == "openai" and self .model == "o3-mini" :
127
131
remove_keys .extend (["temperature" , "top_p" ])
132
+ if kwargs .get ("skip_tls_verify" ):
133
+ if self .model_provider == "ollama" :
134
+ kwargs .update ({"client_kwargs" : {"verify" : False }})
135
+ elif self .model_provider == "openai" :
136
+ kwargs .update (
137
+ {
138
+ "http_client" : Client (verify = False ), # noqa: S501
139
+ "http_async_client" : AsyncClient (verify = False ), # noqa: S501
140
+ }
141
+ )
128
142
for key in remove_keys :
129
143
kwargs .pop (key , None )
130
144
return to_snake_dict (kwargs )
0 commit comments