mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-16 23:43:03 +00:00
style(env): satisfy ruff (datetime alias, line length, identity check)
This commit is contained in:
parent
4e2240aada
commit
c3944bdd5d
1 changed files with 12 additions and 11 deletions
|
|
@ -1,21 +1,21 @@
|
|||
import datetime as dt
|
||||
import importlib.metadata
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import pkgutil
|
||||
import sys
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import traceback
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from uuid import uuid4
|
||||
from pathlib import Path
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
import re
|
||||
|
||||
|
||||
import markdown
|
||||
from bs4 import BeautifulSoup
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
|
||||
from open_webui.constants import ERROR_MESSAGES
|
||||
|
||||
####################################
|
||||
|
|
@ -43,7 +43,8 @@ except ImportError:
|
|||
|
||||
DOCKER = os.environ.get('DOCKER', 'False').lower() == 'true'
|
||||
|
||||
# device type embedding models - "cpu" (default), "cuda" (nvidia gpu required) or "mps" (apple silicon) - choosing this right can lead to better performance
|
||||
# device type for embedding models - "cpu" (default), "cuda" (nvidia gpu required), or "mps" (apple silicon)
|
||||
# choosing this correctly can lead to better performance
|
||||
USE_CUDA = os.environ.get('USE_CUDA_DOCKER', 'false')
|
||||
|
||||
if USE_CUDA.lower() == 'true':
|
||||
|
|
@ -87,7 +88,7 @@ class JSONFormatter(logging.Formatter):
|
|||
|
||||
def format(self, record: logging.LogRecord) -> str:
|
||||
log_entry: dict[str, Any] = {
|
||||
'ts': datetime.fromtimestamp(record.created, tz=timezone.utc).isoformat(timespec='milliseconds'),
|
||||
'ts': dt.datetime.fromtimestamp(record.created, tz=dt.UTC).isoformat(timespec='milliseconds'),
|
||||
'level': _LEVEL_MAP.get(record.levelname, record.levelname.lower()),
|
||||
'msg': record.getMessage(),
|
||||
'caller': record.name,
|
||||
|
|
@ -180,7 +181,7 @@ def parse_section(section):
|
|||
|
||||
try:
|
||||
changelog_path = BASE_DIR / 'CHANGELOG.md'
|
||||
with open(str(changelog_path.absolute()), 'r', encoding='utf8') as file:
|
||||
with open(str(changelog_path.absolute()), encoding='utf8') as file:
|
||||
changelog_content = file.read()
|
||||
|
||||
except Exception:
|
||||
|
|
@ -339,7 +340,7 @@ DATABASE_SCHEMA = os.environ.get('DATABASE_SCHEMA', None)
|
|||
|
||||
DATABASE_POOL_SIZE = os.environ.get('DATABASE_POOL_SIZE', None)
|
||||
|
||||
if DATABASE_POOL_SIZE != None:
|
||||
if DATABASE_POOL_SIZE is not None:
|
||||
try:
|
||||
DATABASE_POOL_SIZE = int(DATABASE_POOL_SIZE)
|
||||
except Exception:
|
||||
|
|
@ -652,7 +653,7 @@ if LICENSE_PUBLIC_KEY:
|
|||
-----BEGIN PUBLIC KEY-----
|
||||
{LICENSE_PUBLIC_KEY}
|
||||
-----END PUBLIC KEY-----
|
||||
""".encode('utf-8')
|
||||
""".encode()
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue