mirror of
https://github.com/open-webui/open-webui
synced 2025-05-14 02:27:19 +00:00
refac
This commit is contained in:
parent
37e0d47082
commit
c7a0e45bea
@ -12,7 +12,6 @@ import aiohttp
|
|||||||
import requests
|
import requests
|
||||||
from open_webui.apps.webui.models.models import Models
|
from open_webui.apps.webui.models.models import Models
|
||||||
from open_webui.config import (
|
from open_webui.config import (
|
||||||
AIOHTTP_CLIENT_TIMEOUT,
|
|
||||||
CORS_ALLOW_ORIGIN,
|
CORS_ALLOW_ORIGIN,
|
||||||
ENABLE_MODEL_FILTER,
|
ENABLE_MODEL_FILTER,
|
||||||
ENABLE_OLLAMA_API,
|
ENABLE_OLLAMA_API,
|
||||||
@ -21,6 +20,9 @@ from open_webui.config import (
|
|||||||
UPLOAD_DIR,
|
UPLOAD_DIR,
|
||||||
AppConfig,
|
AppConfig,
|
||||||
)
|
)
|
||||||
|
from open_webui.env import AIOHTTP_CLIENT_TIMEOUT
|
||||||
|
|
||||||
|
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
from open_webui.env import SRC_LOG_LEVELS
|
from open_webui.env import SRC_LOG_LEVELS
|
||||||
from fastapi import Depends, FastAPI, File, HTTPException, Request, UploadFile
|
from fastapi import Depends, FastAPI, File, HTTPException, Request, UploadFile
|
||||||
@ -117,7 +119,7 @@ async def update_ollama_api_url(form_data: UrlUpdateForm, user=Depends(get_admin
|
|||||||
|
|
||||||
|
|
||||||
async def fetch_url(url):
|
async def fetch_url(url):
|
||||||
timeout = aiohttp.ClientTimeout(total=5)
|
timeout = aiohttp.ClientTimeout(total=3)
|
||||||
try:
|
try:
|
||||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:
|
async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:
|
||||||
async with session.get(url) as response:
|
async with session.get(url) as response:
|
||||||
|
@ -9,7 +9,6 @@ import aiohttp
|
|||||||
import requests
|
import requests
|
||||||
from open_webui.apps.webui.models.models import Models
|
from open_webui.apps.webui.models.models import Models
|
||||||
from open_webui.config import (
|
from open_webui.config import (
|
||||||
AIOHTTP_CLIENT_TIMEOUT,
|
|
||||||
CACHE_DIR,
|
CACHE_DIR,
|
||||||
CORS_ALLOW_ORIGIN,
|
CORS_ALLOW_ORIGIN,
|
||||||
ENABLE_MODEL_FILTER,
|
ENABLE_MODEL_FILTER,
|
||||||
@ -19,6 +18,8 @@ from open_webui.config import (
|
|||||||
OPENAI_API_KEYS,
|
OPENAI_API_KEYS,
|
||||||
AppConfig,
|
AppConfig,
|
||||||
)
|
)
|
||||||
|
from open_webui.env import AIOHTTP_CLIENT_TIMEOUT
|
||||||
|
|
||||||
from open_webui.constants import ERROR_MESSAGES
|
from open_webui.constants import ERROR_MESSAGES
|
||||||
from open_webui.env import SRC_LOG_LEVELS
|
from open_webui.env import SRC_LOG_LEVELS
|
||||||
from fastapi import Depends, FastAPI, HTTPException, Request
|
from fastapi import Depends, FastAPI, HTTPException, Request
|
||||||
@ -178,7 +179,7 @@ async def speech(request: Request, user=Depends(get_verified_user)):
|
|||||||
|
|
||||||
|
|
||||||
async def fetch_url(url, key):
|
async def fetch_url(url, key):
|
||||||
timeout = aiohttp.ClientTimeout(total=5)
|
timeout = aiohttp.ClientTimeout(total=3)
|
||||||
try:
|
try:
|
||||||
headers = {"Authorization": f"Bearer {key}"}
|
headers = {"Authorization": f"Bearer {key}"}
|
||||||
async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:
|
async with aiohttp.ClientSession(timeout=timeout, trust_env=True) as session:
|
||||||
|
@ -561,16 +561,6 @@ OLLAMA_API_BASE_URL = os.environ.get(
|
|||||||
)
|
)
|
||||||
|
|
||||||
OLLAMA_BASE_URL = os.environ.get("OLLAMA_BASE_URL", "")
|
OLLAMA_BASE_URL = os.environ.get("OLLAMA_BASE_URL", "")
|
||||||
AIOHTTP_CLIENT_TIMEOUT = os.environ.get("AIOHTTP_CLIENT_TIMEOUT", "")
|
|
||||||
|
|
||||||
if AIOHTTP_CLIENT_TIMEOUT == "":
|
|
||||||
AIOHTTP_CLIENT_TIMEOUT = None
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
AIOHTTP_CLIENT_TIMEOUT = int(AIOHTTP_CLIENT_TIMEOUT)
|
|
||||||
except Exception:
|
|
||||||
AIOHTTP_CLIENT_TIMEOUT = 300
|
|
||||||
|
|
||||||
|
|
||||||
K8S_FLAG = os.environ.get("K8S_FLAG", "")
|
K8S_FLAG = os.environ.get("K8S_FLAG", "")
|
||||||
USE_OLLAMA_DOCKER = os.environ.get("USE_OLLAMA_DOCKER", "false")
|
USE_OLLAMA_DOCKER = os.environ.get("USE_OLLAMA_DOCKER", "false")
|
||||||
|
@ -305,3 +305,14 @@ ENABLE_WEBSOCKET_SUPPORT = (
|
|||||||
WEBSOCKET_MANAGER = os.environ.get("WEBSOCKET_MANAGER", "")
|
WEBSOCKET_MANAGER = os.environ.get("WEBSOCKET_MANAGER", "")
|
||||||
|
|
||||||
WEBSOCKET_REDIS_URL = os.environ.get("WEBSOCKET_REDIS_URL", "redis://localhost:6379/0")
|
WEBSOCKET_REDIS_URL = os.environ.get("WEBSOCKET_REDIS_URL", "redis://localhost:6379/0")
|
||||||
|
|
||||||
|
|
||||||
|
AIOHTTP_CLIENT_TIMEOUT = os.environ.get("AIOHTTP_CLIENT_TIMEOUT", "")
|
||||||
|
|
||||||
|
if AIOHTTP_CLIENT_TIMEOUT == "":
|
||||||
|
AIOHTTP_CLIENT_TIMEOUT = None
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
AIOHTTP_CLIENT_TIMEOUT = int(AIOHTTP_CLIENT_TIMEOUT)
|
||||||
|
except Exception:
|
||||||
|
AIOHTTP_CLIENT_TIMEOUT = 300
|
||||||
|
@ -2191,7 +2191,8 @@ async def get_app_latest_release_version():
|
|||||||
latest_version = data["tag_name"]
|
latest_version = data["tag_name"]
|
||||||
|
|
||||||
return {"current": VERSION, "latest": latest_version[1:]}
|
return {"current": VERSION, "latest": latest_version[1:]}
|
||||||
except aiohttp.ClientError:
|
except Exception as e:
|
||||||
|
log.debug(e)
|
||||||
return {"current": VERSION, "latest": VERSION}
|
return {"current": VERSION, "latest": VERSION}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user