added suggestions

This commit is contained in:
kahghi 2025-01-21 14:47:56 +08:00
parent 55cc127b03
commit b1887fef1b
3 changed files with 54 additions and 20 deletions

View File

@ -146,10 +146,12 @@ class GCSStorageProvider(StorageProvider):
def __init__(self): def __init__(self):
self.bucket_name = GCS_BUCKET_NAME self.bucket_name = GCS_BUCKET_NAME
if GCS_BUCKET_NAME and GOOGLE_APPLICATION_CREDENTIALS_JSON: if GOOGLE_APPLICATION_CREDENTIALS_JSON:
self.gcs_client = storage.Client.from_service_account_info(info=json.loads(GOOGLE_APPLICATION_CREDENTIALS_JSON)) self.gcs_client = storage.Client.from_service_account_info(info=json.loads(GOOGLE_APPLICATION_CREDENTIALS_JSON))
else: else:
# defaults to environment, be it GCE VM or user credentials # if no credentials json is provided, credentials will be picked up from the environment
# if running on local environment, credentials would be user credentials
# if running on a Compute Engine instance, credentials would be from Google Metadata server
self.gcs_client = storage.Client() self.gcs_client = storage.Client()
self.bucket = self.gcs_client.bucket(GCS_BUCKET_NAME) self.bucket = self.gcs_client.bucket(GCS_BUCKET_NAME)
@ -206,7 +208,7 @@ def get_storage_provider(storage_provider: str):
Storage = LocalStorageProvider() Storage = LocalStorageProvider()
elif storage_provider == "s3": elif storage_provider == "s3":
Storage = S3StorageProvider() Storage = S3StorageProvider()
elif storage_provider == "gcs": elif storage_provider == "gcs" and GCS_BUCKET_NAME:
Storage = GCSStorageProvider() Storage = GCSStorageProvider()
else: else:
raise RuntimeError(f"Unsupported storage provider: {storage_provider}") raise RuntimeError(f"Unsupported storage provider: {storage_provider}")

View File

@ -13,17 +13,17 @@ dependencies = [
"Flask==3.1.0", "Flask==3.1.0",
"Flask-Cors==5.0.0", "Flask-Cors==5.0.0",
"python-socketio==5.11.3", "python-socketio==5.11.3",
"python-jose==3.3.0", "python-jose==3.3.0",
"passlib[bcrypt]==1.7.4", "passlib[bcrypt]==1.7.4",
"requests==2.32.3", "requests==2.32.3",
"aiohttp==3.11.8", "aiohttp==3.11.8",
"async-timeout", "async-timeout",
"aiocache", "aiocache",
"aiofiles", "aiofiles",
"sqlalchemy==2.0.32", "sqlalchemy==2.0.32",
"alembic==1.14.0", "alembic==1.14.0",
"peewee==3.17.8", "peewee==3.17.8",
@ -32,33 +32,33 @@ dependencies = [
"pgvector==0.3.5", "pgvector==0.3.5",
"PyMySQL==1.1.1", "PyMySQL==1.1.1",
"bcrypt==4.2.0", "bcrypt==4.2.0",
"pymongo", "pymongo",
"redis", "redis",
"boto3==1.35.53", "boto3==1.35.53",
"argon2-cffi==23.1.0", "argon2-cffi==23.1.0",
"APScheduler==3.10.4", "APScheduler==3.10.4",
"openai", "openai",
"anthropic", "anthropic",
"google-generativeai==0.7.2", "google-generativeai==0.7.2",
"tiktoken", "tiktoken",
"langchain==0.3.7", "langchain==0.3.7",
"langchain-community==0.3.7", "langchain-community==0.3.7",
"fake-useragent==1.5.1", "fake-useragent==1.5.1",
"chromadb==0.6.2", "chromadb==0.6.2",
"pymilvus==2.5.0", "pymilvus==2.5.0",
"qdrant-client~=1.12.0", "qdrant-client~=1.12.0",
"opensearch-py==2.7.1", "opensearch-py==2.7.1",
"transformers", "transformers",
"sentence-transformers==3.3.1", "sentence-transformers==3.3.1",
"colbert-ai==0.2.21", "colbert-ai==0.2.21",
"einops==0.8.0", "einops==0.8.0",
"ftfy==6.2.3", "ftfy==6.2.3",
"pypdf==4.3.1", "pypdf==4.3.1",
"fpdf2==2.8.2", "fpdf2==2.8.2",
@ -77,34 +77,35 @@ dependencies = [
"psutil", "psutil",
"sentencepiece", "sentencepiece",
"soundfile==0.12.1", "soundfile==0.12.1",
"opencv-python-headless==4.10.0.84", "opencv-python-headless==4.10.0.84",
"rapidocr-onnxruntime==1.3.24", "rapidocr-onnxruntime==1.3.24",
"rank-bm25==0.2.2", "rank-bm25==0.2.2",
"faster-whisper==1.0.3", "faster-whisper==1.0.3",
"PyJWT[crypto]==2.10.1", "PyJWT[crypto]==2.10.1",
"authlib==1.3.2", "authlib==1.3.2",
"black==24.8.0", "black==24.8.0",
"langfuse==2.44.0", "langfuse==2.44.0",
"youtube-transcript-api==0.6.3", "youtube-transcript-api==0.6.3",
"pytube==15.0.0", "pytube==15.0.0",
"extract_msg", "extract_msg",
"pydub", "pydub",
"duckduckgo-search~=6.3.5", "duckduckgo-search~=6.3.5",
"docker~=7.1.0", "docker~=7.1.0",
"pytest~=8.3.2", "pytest~=8.3.2",
"pytest-docker~=3.1.1", "pytest-docker~=3.1.1",
"moto[s3]>=5.0.26", "moto[s3]>=5.0.26",
"googleapis-common-protos==1.63.2", "googleapis-common-protos==1.63.2",
"ldap3==2.9.1", "ldap3==2.9.1",
"google-cloud-storage==2.19.0", "google-cloud-storage==2.19.0",
"gcp-storage-emulator>=2024.8.3", "gcp-storage-emulator>=2024.8.3",
"pytest-env>=1.1.5",
] ]
readme = "README.md" readme = "README.md"
requires-python = ">= 3.11, < 3.13.0a1" requires-python = ">= 3.11, < 3.13.0a1"
@ -126,6 +127,11 @@ open-webui = "open_webui:app"
requires = ["hatchling"] requires = ["hatchling"]
build-backend = "hatchling.build" build-backend = "hatchling.build"
[tool.pytest.ini_options]
env = [
"GCS_BUCKET_NAME=my-bucket"
]
[tool.rye] [tool.rye]
managed = true managed = true
dev-dependencies = [] dev-dependencies = []

26
uv.lock
View File

@ -24,6 +24,9 @@ resolution-markers = [
"python_full_version < '3.12' and platform_system == 'Darwin'", "python_full_version < '3.12' and platform_system == 'Darwin'",
"python_full_version < '3.12' and platform_system == 'Darwin'", "python_full_version < '3.12' and platform_system == 'Darwin'",
"python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_system == 'Darwin'", "python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_system == 'Darwin'",
"python_full_version < '3.12' and platform_system == 'Darwin'",
"python_full_version < '3.12' and platform_system == 'Darwin'",
"python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_system == 'Darwin'",
"python_full_version < '3.13' and platform_system == 'Darwin'", "python_full_version < '3.13' and platform_system == 'Darwin'",
"python_full_version >= '3.13' and platform_system == 'Darwin'", "python_full_version >= '3.13' and platform_system == 'Darwin'",
"python_full_version >= '3.13' and platform_system == 'Darwin'", "python_full_version >= '3.13' and platform_system == 'Darwin'",
@ -32,6 +35,10 @@ resolution-markers = [
"python_full_version >= '3.13' and platform_system == 'Darwin'", "python_full_version >= '3.13' and platform_system == 'Darwin'",
"python_full_version >= '3.13' and platform_system == 'Darwin'", "python_full_version >= '3.13' and platform_system == 'Darwin'",
"python_full_version >= '3.13' and platform_system == 'Darwin'", "python_full_version >= '3.13' and platform_system == 'Darwin'",
"python_full_version >= '3.13' and platform_system == 'Darwin'",
"python_full_version < '3.12' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version < '3.12' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version < '3.12' and platform_machine == 'aarch64' and platform_system == 'Linux'", "python_full_version < '3.12' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_machine == 'aarch64' and platform_system == 'Linux'", "python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version < '3.12' and platform_machine == 'aarch64' and platform_system == 'Linux'", "python_full_version < '3.12' and platform_machine == 'aarch64' and platform_system == 'Linux'",
@ -60,6 +67,10 @@ resolution-markers = [
"python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'", "python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'", "python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'", "python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"python_full_version >= '3.13' and platform_machine == 'aarch64' and platform_system == 'Linux'",
"(python_full_version < '3.12' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version < '3.12' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version < '3.12' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version < '3.12' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version < '3.12' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version < '3.12' and platform_system != 'Darwin' and platform_system != 'Linux')", "(python_full_version < '3.12' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version < '3.12' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_system != 'Darwin' and platform_system != 'Linux')", "(python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.12' and python_full_version < '3.12.4' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version < '3.12' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version < '3.12' and platform_system != 'Darwin' and platform_system != 'Linux')", "(python_full_version < '3.12' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version < '3.12' and platform_system != 'Darwin' and platform_system != 'Linux')",
@ -88,6 +99,7 @@ resolution-markers = [
"(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')", "(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')", "(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')", "(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')",
"(python_full_version >= '3.13' and platform_machine != 'aarch64' and platform_system != 'Darwin') or (python_full_version >= '3.13' and platform_system != 'Darwin' and platform_system != 'Linux')",
] ]
[[package]] [[package]]
@ -2850,6 +2862,7 @@ dependencies = [
{ name = "pypdf" }, { name = "pypdf" },
{ name = "pytest" }, { name = "pytest" },
{ name = "pytest-docker" }, { name = "pytest-docker" },
{ name = "pytest-env" },
{ name = "python-jose" }, { name = "python-jose" },
{ name = "python-multipart" }, { name = "python-multipart" },
{ name = "python-pptx" }, { name = "python-pptx" },
@ -2935,6 +2948,7 @@ requires-dist = [
{ name = "pypdf", specifier = "==4.3.1" }, { name = "pypdf", specifier = "==4.3.1" },
{ name = "pytest", specifier = "~=8.3.2" }, { name = "pytest", specifier = "~=8.3.2" },
{ name = "pytest-docker", specifier = "~=3.1.1" }, { name = "pytest-docker", specifier = "~=3.1.1" },
{ name = "pytest-env", specifier = ">=1.1.5" },
{ name = "python-jose", specifier = "==3.3.0" }, { name = "python-jose", specifier = "==3.3.0" },
{ name = "python-multipart", specifier = "==0.0.18" }, { name = "python-multipart", specifier = "==0.0.18" },
{ name = "python-pptx", specifier = "==1.0.0" }, { name = "python-pptx", specifier = "==1.0.0" },
@ -3940,6 +3954,18 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/1a/a4/69defc13bf77ee5aeb3e7b7c45393d6c7312e9c4d8b55d280a094ff76ff3/pytest_docker-3.1.1-py3-none-any.whl", hash = "sha256:fd0d48d6feac41f62acbc758319215ec9bb805c2309622afb07c27fa5c5ae362", size = 8243 }, { url = "https://files.pythonhosted.org/packages/1a/a4/69defc13bf77ee5aeb3e7b7c45393d6c7312e9c4d8b55d280a094ff76ff3/pytest_docker-3.1.1-py3-none-any.whl", hash = "sha256:fd0d48d6feac41f62acbc758319215ec9bb805c2309622afb07c27fa5c5ae362", size = 8243 },
] ]
[[package]]
name = "pytest-env"
version = "1.1.5"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "pytest" },
]
sdist = { url = "https://files.pythonhosted.org/packages/1f/31/27f28431a16b83cab7a636dce59cf397517807d247caa38ee67d65e71ef8/pytest_env-1.1.5.tar.gz", hash = "sha256:91209840aa0e43385073ac464a554ad2947cc2fd663a9debf88d03b01e0cc1cf", size = 8911 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/de/b8/87cfb16045c9d4092cfcf526135d73b88101aac83bc1adcf82dfb5fd3833/pytest_env-1.1.5-py3-none-any.whl", hash = "sha256:ce90cf8772878515c24b31cd97c7fa1f4481cd68d588419fd45f10ecaee6bc30", size = 6141 },
]
[[package]] [[package]]
name = "python-dateutil" name = "python-dateutil"
version = "2.9.0.post0" version = "2.9.0.post0"