refac
This commit is contained in:
@@ -1304,6 +1304,7 @@ async def get_available_models(request: Request) -> list[dict]:
|
||||
try:
|
||||
async with session.get(
|
||||
f'{request.app.state.config.TTS_OPENAI_API_BASE_URL}/audio/models',
|
||||
ssl=AIOHTTP_CLIENT_SESSION_SSL,
|
||||
) as response:
|
||||
response.raise_for_status()
|
||||
data = await response.json()
|
||||
@@ -1315,6 +1316,7 @@ async def get_available_models(request: Request) -> list[dict]:
|
||||
try:
|
||||
async with session.get(
|
||||
f'{request.app.state.config.TTS_OPENAI_API_BASE_URL}/models',
|
||||
ssl=AIOHTTP_CLIENT_SESSION_SSL,
|
||||
) as response:
|
||||
response.raise_for_status()
|
||||
data = await response.json()
|
||||
@@ -1335,6 +1337,7 @@ async def get_available_models(request: Request) -> list[dict]:
|
||||
'xi-api-key': request.app.state.config.TTS_API_KEY,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
ssl=AIOHTTP_CLIENT_SESSION_SSL,
|
||||
) as response:
|
||||
response.raise_for_status()
|
||||
models = await response.json()
|
||||
@@ -1362,6 +1365,7 @@ async def get_available_voices(request) -> dict:
|
||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:
|
||||
async with session.get(
|
||||
f'{request.app.state.config.TTS_OPENAI_API_BASE_URL}/audio/voices',
|
||||
ssl=AIOHTTP_CLIENT_SESSION_SSL,
|
||||
) as response:
|
||||
response.raise_for_status()
|
||||
data = await response.json()
|
||||
@@ -1401,7 +1405,7 @@ async def get_available_voices(request) -> dict:
|
||||
|
||||
timeout = aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT_MODEL_LIST)
|
||||
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_SSL) as response:
|
||||
response.raise_for_status()
|
||||
voices = await response.json()
|
||||
|
||||
@@ -1422,6 +1426,7 @@ async def get_available_voices(request) -> dict:
|
||||
headers={
|
||||
'Authorization': f'Bearer {api_key}',
|
||||
},
|
||||
ssl=AIOHTTP_CLIENT_SESSION_SSL,
|
||||
) as response:
|
||||
response.raise_for_status()
|
||||
voices_data = await response.json()
|
||||
@@ -1456,6 +1461,7 @@ async def get_elevenlabs_voices(api_key: str) -> dict:
|
||||
'xi-api-key': api_key,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
ssl=AIOHTTP_CLIENT_SESSION_SSL,
|
||||
) as response:
|
||||
response.raise_for_status()
|
||||
voices_data = await response.json()
|
||||
|
||||
@@ -810,7 +810,7 @@ async def signout(request: Request, response: Response, db: AsyncSession = Depen
|
||||
oauth_id_token = session.token.get('id_token')
|
||||
try:
|
||||
async with ClientSession(trust_env=True) as session:
|
||||
async with session.get(oauth_server_metadata_url) as r:
|
||||
async with session.get(oauth_server_metadata_url, ssl=AIOHTTP_CLIENT_SESSION_SSL) as r:
|
||||
if r.status == 200:
|
||||
openid_data = await r.json()
|
||||
logout_url = openid_data.get('end_session_endpoint')
|
||||
|
||||
@@ -6,7 +6,7 @@ import aiohttp
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from open_webui.env import AIOHTTP_CLIENT_TIMEOUT
|
||||
from open_webui.env import AIOHTTP_CLIENT_SESSION_SSL, AIOHTTP_CLIENT_TIMEOUT
|
||||
from open_webui.utils.auth import get_admin_user, get_verified_user
|
||||
from open_webui.config import get_config, save_config, async_save_config
|
||||
from open_webui.config import BannerModel
|
||||
@@ -293,7 +293,7 @@ async def verify_terminal_server_connection(
|
||||
) as session:
|
||||
# Orchestrators expose a policies API; plain terminals don't.
|
||||
try:
|
||||
async with session.get(f'{base_url}/api/v1/policies', headers=headers) as resp:
|
||||
async with session.get(f'{base_url}/api/v1/policies', headers=headers, ssl=AIOHTTP_CLIENT_SESSION_SSL) as resp:
|
||||
if resp.ok:
|
||||
return {'status': True, 'type': 'orchestrator'}
|
||||
except Exception:
|
||||
@@ -301,7 +301,7 @@ async def verify_terminal_server_connection(
|
||||
|
||||
# Fall back to open-terminal config endpoint.
|
||||
try:
|
||||
async with session.get(f'{base_url}/api/config', headers=headers) as resp:
|
||||
async with session.get(f'{base_url}/api/config', headers=headers, ssl=AIOHTTP_CLIENT_SESSION_SSL) as resp:
|
||||
if resp.ok:
|
||||
return {'status': True, 'type': 'terminal'}
|
||||
except Exception:
|
||||
@@ -342,7 +342,7 @@ async def put_terminal_server_policy(
|
||||
timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT),
|
||||
) as session:
|
||||
policy_url = f'{base_url}/api/v1/policies/{form_data.policy_id}'
|
||||
async with session.put(policy_url, headers=headers, json=form_data.policy_data) as resp:
|
||||
async with session.put(policy_url, headers=headers, json=form_data.policy_data, ssl=AIOHTTP_CLIENT_SESSION_SSL) as resp:
|
||||
if resp.ok:
|
||||
return await resp.json()
|
||||
detail = await resp.text()
|
||||
@@ -369,7 +369,7 @@ async def verify_tool_servers_config(request: Request, form_data: ToolServerConn
|
||||
trust_env=True,
|
||||
timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT),
|
||||
) as session:
|
||||
async with session.get(discovery_url) as oauth_server_metadata_response:
|
||||
async with session.get(discovery_url, ssl=AIOHTTP_CLIENT_SESSION_SSL) as oauth_server_metadata_response:
|
||||
if oauth_server_metadata_response.status == 200:
|
||||
try:
|
||||
oauth_server_metadata = OAuthMetadata.model_validate(
|
||||
|
||||
Reference in New Issue
Block a user