mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
enh: AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL
This commit is contained in:
parent
3b20c57ea8
commit
824238a620
@ -437,6 +437,11 @@ else:
|
|||||||
except Exception:
|
except Exception:
|
||||||
AIOHTTP_CLIENT_TIMEOUT_TOOL_SERVER_DATA = 10
|
AIOHTTP_CLIENT_TIMEOUT_TOOL_SERVER_DATA = 10
|
||||||
|
|
||||||
|
|
||||||
|
AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL = (
|
||||||
|
os.environ.get("AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL", "True").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# OFFLINE_MODE
|
# OFFLINE_MODE
|
||||||
####################################
|
####################################
|
||||||
|
@ -36,7 +36,10 @@ from langchain_core.utils.function_calling import (
|
|||||||
from open_webui.models.tools import Tools
|
from open_webui.models.tools import Tools
|
||||||
from open_webui.models.users import UserModel
|
from open_webui.models.users import UserModel
|
||||||
from open_webui.utils.plugin import load_tool_module_by_id
|
from open_webui.utils.plugin import load_tool_module_by_id
|
||||||
from open_webui.env import AIOHTTP_CLIENT_TIMEOUT_TOOL_SERVER_DATA
|
from open_webui.env import (
|
||||||
|
AIOHTTP_CLIENT_TIMEOUT_TOOL_SERVER_DATA,
|
||||||
|
AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL,
|
||||||
|
)
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
@ -431,8 +434,10 @@ async def get_tool_server_data(token: str, url: str) -> Dict[str, Any]:
|
|||||||
error = None
|
error = None
|
||||||
try:
|
try:
|
||||||
timeout = aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT_TOOL_SERVER_DATA)
|
timeout = aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT_TOOL_SERVER_DATA)
|
||||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:
|
||||||
async with session.get(url, headers=headers) as response:
|
async with session.get(
|
||||||
|
url, headers=headers, ssl=AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL
|
||||||
|
) as response:
|
||||||
if response.status != 200:
|
if response.status != 200:
|
||||||
error_body = await response.json()
|
error_body = await response.json()
|
||||||
raise Exception(error_body)
|
raise Exception(error_body)
|
||||||
@ -573,19 +578,26 @@ async def execute_tool_server(
|
|||||||
if token:
|
if token:
|
||||||
headers["Authorization"] = f"Bearer {token}"
|
headers["Authorization"] = f"Bearer {token}"
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession(trust_env=True) as session:
|
||||||
request_method = getattr(session, http_method.lower())
|
request_method = getattr(session, http_method.lower())
|
||||||
|
|
||||||
if http_method in ["post", "put", "patch"]:
|
if http_method in ["post", "put", "patch"]:
|
||||||
async with request_method(
|
async with request_method(
|
||||||
final_url, json=body_params, headers=headers
|
final_url,
|
||||||
|
json=body_params,
|
||||||
|
headers=headers,
|
||||||
|
ssl=AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL,
|
||||||
) as response:
|
) as response:
|
||||||
if response.status >= 400:
|
if response.status >= 400:
|
||||||
text = await response.text()
|
text = await response.text()
|
||||||
raise Exception(f"HTTP error {response.status}: {text}")
|
raise Exception(f"HTTP error {response.status}: {text}")
|
||||||
return await response.json()
|
return await response.json()
|
||||||
else:
|
else:
|
||||||
async with request_method(final_url, headers=headers) as response:
|
async with request_method(
|
||||||
|
final_url,
|
||||||
|
headers=headers,
|
||||||
|
ssl=AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL,
|
||||||
|
) as response:
|
||||||
if response.status >= 400:
|
if response.status >= 400:
|
||||||
text = await response.text()
|
text = await response.text()
|
||||||
raise Exception(f"HTTP error {response.status}: {text}")
|
raise Exception(f"HTTP error {response.status}: {text}")
|
||||||
|
Loading…
Reference in New Issue
Block a user