mirror of https://github.com/Mai-with-u/MaiBot.git
精简依赖
parent
19fd667271
commit
817c4183bf
|
|
@ -330,3 +330,4 @@ config.toml
|
|||
|
||||
interested_rates.txt
|
||||
MaiBot.code-workspace
|
||||
*.lock
|
||||
|
|
@ -6,53 +6,32 @@ requires-python = ">=3.10"
|
|||
dependencies = [
|
||||
"aiohttp>=3.12.14",
|
||||
"aiohttp-cors>=0.8.1",
|
||||
"apscheduler>=3.11.0",
|
||||
"colorama>=0.4.6",
|
||||
"cryptography>=45.0.5",
|
||||
"customtkinter>=5.2.2",
|
||||
"dotenv>=0.9.9",
|
||||
"faiss-cpu>=1.11.0",
|
||||
"fastapi>=0.116.0",
|
||||
"google-genai>=1.39.1",
|
||||
"jieba>=0.42.1",
|
||||
"json-repair>=0.47.6",
|
||||
"jsonlines>=4.0.0",
|
||||
"maim-message>=0",
|
||||
"maim-message",
|
||||
"matplotlib>=3.10.3",
|
||||
"networkx>=3.4.2",
|
||||
"numpy>=2.2.6",
|
||||
"openai>=1.95.0",
|
||||
"packaging>=25.0",
|
||||
"pandas>=2.3.1",
|
||||
"peewee>=3.18.2",
|
||||
"pillow>=11.3.0",
|
||||
"psutil>=7.0.0",
|
||||
"pyarrow>=20.0.0",
|
||||
"pydantic>=2.11.7",
|
||||
"pymongo>=4.13.2",
|
||||
"pypinyin>=0.54.0",
|
||||
"python-dateutil>=2.9.0.post0",
|
||||
"python-dotenv>=1.1.1",
|
||||
"python-igraph>=0.11.9",
|
||||
"quick-algo>=0.1.3",
|
||||
"reportportal-client>=5.6.5",
|
||||
"requests>=2.32.4",
|
||||
"rich>=14.0.0",
|
||||
"ruff>=0.12.2",
|
||||
"scikit-learn>=1.7.0",
|
||||
"scipy>=1.15.3",
|
||||
"seaborn>=0.13.2",
|
||||
"setuptools>=80.9.0",
|
||||
"strawberry-graphql[fastapi]>=0.275.5",
|
||||
"structlog>=25.4.0",
|
||||
"toml>=0.10.2",
|
||||
"tomli>=2.2.1",
|
||||
"tomli-w>=1.2.0",
|
||||
"tomlkit>=0.13.3",
|
||||
"tqdm>=4.67.1",
|
||||
"urllib3>=2.5.0",
|
||||
"uvicorn>=0.35.0",
|
||||
"websockets>=15.0.1",
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,232 +0,0 @@
|
|||
# This file was autogenerated by uv via the following command:
|
||||
# uv pip compile requirements.txt -o requirements.lock
|
||||
aiohappyeyeballs==2.6.1
|
||||
# via aiohttp
|
||||
aiohttp==3.12.14
|
||||
# via
|
||||
# -r requirements.txt
|
||||
# aiohttp-cors
|
||||
# maim-message
|
||||
aiohttp-cors==0.8.1
|
||||
# via -r requirements.txt
|
||||
aiosignal==1.4.0
|
||||
# via aiohttp
|
||||
annotated-types==0.7.0
|
||||
# via pydantic
|
||||
anyio==4.9.0
|
||||
# via
|
||||
# google-genai
|
||||
# httpx
|
||||
# openai
|
||||
# starlette
|
||||
attrs==25.3.0
|
||||
# via
|
||||
# aiohttp
|
||||
# jsonlines
|
||||
cachetools==5.5.2
|
||||
# via google-auth
|
||||
certifi==2025.7.9
|
||||
# via
|
||||
# httpcore
|
||||
# httpx
|
||||
# requests
|
||||
cffi==1.17.1
|
||||
# via cryptography
|
||||
charset-normalizer==3.4.2
|
||||
# via requests
|
||||
click==8.2.1
|
||||
# via uvicorn
|
||||
colorama==0.4.6
|
||||
# via
|
||||
# -r requirements.txt
|
||||
# click
|
||||
# tqdm
|
||||
cryptography==45.0.5
|
||||
# via maim-message
|
||||
distro==1.9.0
|
||||
# via openai
|
||||
dnspython==2.7.0
|
||||
# via pymongo
|
||||
dotenv==0.9.9
|
||||
# via -r requirements.txt
|
||||
faiss-cpu==1.11.0
|
||||
# via -r requirements.txt
|
||||
fastapi==0.116.0
|
||||
# via
|
||||
# -r requirements.txt
|
||||
# maim-message
|
||||
# strawberry-graphql
|
||||
frozenlist==1.7.0
|
||||
# via
|
||||
# aiohttp
|
||||
# aiosignal
|
||||
google-auth==2.40.3
|
||||
# via google-genai
|
||||
google-genai==1.38.0
|
||||
# via -r requirements.txt
|
||||
graphql-core==3.2.6
|
||||
# via strawberry-graphql
|
||||
h11==0.16.0
|
||||
# via
|
||||
# httpcore
|
||||
# uvicorn
|
||||
httpcore==1.0.9
|
||||
# via httpx
|
||||
httpx==0.28.1
|
||||
# via
|
||||
# google-genai
|
||||
# openai
|
||||
idna==3.10
|
||||
# via
|
||||
# anyio
|
||||
# httpx
|
||||
# requests
|
||||
# yarl
|
||||
jieba==0.42.1
|
||||
# via -r requirements.txt
|
||||
jiter==0.10.0
|
||||
# via openai
|
||||
json-repair==0.47.6
|
||||
# via -r requirements.txt
|
||||
jsonlines==4.0.0
|
||||
# via -r requirements.txt
|
||||
maim-message==0.5.1
|
||||
# via -r requirements.txt
|
||||
markdown-it-py==3.0.0
|
||||
# via rich
|
||||
mdurl==0.1.2
|
||||
# via markdown-it-py
|
||||
multidict==6.6.3
|
||||
# via
|
||||
# aiohttp
|
||||
# yarl
|
||||
networkx==3.4.2
|
||||
# via -r requirements.txt
|
||||
numpy==2.2.6
|
||||
# via
|
||||
# -r requirements.txt
|
||||
# faiss-cpu
|
||||
# pandas
|
||||
# scipy
|
||||
openai==1.95.0
|
||||
# via -r requirements.txt
|
||||
packaging==25.0
|
||||
# via
|
||||
# -r requirements.txt
|
||||
# faiss-cpu
|
||||
# strawberry-graphql
|
||||
pandas==2.3.3
|
||||
# via -r requirements.txt
|
||||
peewee==3.18.2
|
||||
# via -r requirements.txt
|
||||
pillow==11.3.0
|
||||
# via -r requirements.txt
|
||||
propcache==0.3.2
|
||||
# via
|
||||
# aiohttp
|
||||
# yarl
|
||||
psutil==7.0.0
|
||||
# via -r requirements.txt
|
||||
pyasn1==0.6.1
|
||||
# via
|
||||
# pyasn1-modules
|
||||
# rsa
|
||||
pyasn1-modules==0.4.2
|
||||
# via google-auth
|
||||
pycparser==2.22
|
||||
# via cffi
|
||||
pydantic==2.11.7
|
||||
# via
|
||||
# -r requirements.txt
|
||||
# fastapi
|
||||
# google-genai
|
||||
# maim-message
|
||||
# openai
|
||||
pydantic-core==2.33.2
|
||||
# via pydantic
|
||||
pygments==2.19.2
|
||||
# via rich
|
||||
pymongo==4.13.2
|
||||
# via -r requirements.txt
|
||||
pypinyin==0.54.0
|
||||
# via -r requirements.txt
|
||||
python-dateutil==2.9.0.post0
|
||||
# via
|
||||
# pandas
|
||||
# strawberry-graphql
|
||||
python-dotenv==1.1.1
|
||||
# via
|
||||
# -r requirements.txt
|
||||
# dotenv
|
||||
python-multipart==0.0.20
|
||||
# via strawberry-graphql
|
||||
pytz==2025.2
|
||||
# via pandas
|
||||
quick-algo==0.1.3
|
||||
# via -r requirements.txt
|
||||
requests==2.32.4
|
||||
# via google-genai
|
||||
rich==14.0.0
|
||||
# via -r requirements.txt
|
||||
rsa==4.9.1
|
||||
# via google-auth
|
||||
ruff==0.12.2
|
||||
# via -r requirements.txt
|
||||
scipy==1.15.3
|
||||
# via -r requirements.txt
|
||||
setuptools==80.9.0
|
||||
# via -r requirements.txt
|
||||
six==1.17.0
|
||||
# via python-dateutil
|
||||
sniffio==1.3.1
|
||||
# via
|
||||
# anyio
|
||||
# openai
|
||||
starlette==0.46.2
|
||||
# via fastapi
|
||||
strawberry-graphql==0.275.5
|
||||
# via -r requirements.txt
|
||||
structlog==25.4.0
|
||||
# via -r requirements.txt
|
||||
tenacity==9.1.2
|
||||
# via google-genai
|
||||
toml==0.10.2
|
||||
# via -r requirements.txt
|
||||
tomli==2.2.1
|
||||
# via -r requirements.txt
|
||||
tomli-w==1.2.0
|
||||
# via -r requirements.txt
|
||||
tomlkit==0.13.3
|
||||
# via -r requirements.txt
|
||||
tqdm==4.67.1
|
||||
# via openai
|
||||
typing-extensions==4.14.1
|
||||
# via
|
||||
# aiosignal
|
||||
# anyio
|
||||
# fastapi
|
||||
# google-genai
|
||||
# openai
|
||||
# pydantic
|
||||
# pydantic-core
|
||||
# strawberry-graphql
|
||||
# typing-inspection
|
||||
typing-inspection==0.4.1
|
||||
# via pydantic
|
||||
tzdata==2025.2
|
||||
# via pandas
|
||||
urllib3==2.5.0
|
||||
# via
|
||||
# -r requirements.txt
|
||||
# requests
|
||||
uvicorn==0.35.0
|
||||
# via
|
||||
# -r requirements.txt
|
||||
# maim-message
|
||||
websockets==15.0.1
|
||||
# via
|
||||
# -r requirements.txt
|
||||
# google-genai
|
||||
# maim-message
|
||||
yarl==1.20.1
|
||||
# via aiohttp
|
||||
|
|
@ -1,37 +1,28 @@
|
|||
Pillow
|
||||
aiohttp
|
||||
aiohttp-cors
|
||||
colorama
|
||||
dotenv
|
||||
faiss-cpu
|
||||
fastapi
|
||||
jieba
|
||||
jsonlines
|
||||
maim-message>=0
|
||||
quick_algo
|
||||
networkx
|
||||
numpy
|
||||
openai
|
||||
peewee
|
||||
pydantic
|
||||
pypinyin
|
||||
python-dotenv
|
||||
pymongo
|
||||
ruff
|
||||
scipy
|
||||
setuptools
|
||||
toml
|
||||
tomli
|
||||
tomli_w
|
||||
tomlkit
|
||||
urllib3
|
||||
uvicorn
|
||||
websockets
|
||||
strawberry-graphql[fastapi]
|
||||
packaging
|
||||
rich
|
||||
psutil
|
||||
json-repair
|
||||
structlog
|
||||
google.genai
|
||||
pandas
|
||||
aiohttp>=3.12.14
|
||||
aiohttp-cors>=0.8.1
|
||||
colorama>=0.4.6
|
||||
faiss-cpu>=1.11.0
|
||||
fastapi>=0.116.0
|
||||
google-genai>=1.39.1
|
||||
jieba>=0.42.1
|
||||
json-repair>=0.47.6
|
||||
maim-message
|
||||
matplotlib>=3.10.3
|
||||
numpy>=2.2.6
|
||||
openai>=1.95.0
|
||||
pandas>=2.3.1
|
||||
peewee>=3.18.2
|
||||
pillow>=11.3.0
|
||||
pyarrow>=20.0.0
|
||||
pydantic>=2.11.7
|
||||
pypinyin>=0.54.0
|
||||
python-dotenv>=1.1.1
|
||||
quick-algo>=0.1.3
|
||||
rich>=14.0.0
|
||||
ruff>=0.12.2
|
||||
setuptools>=80.9.0
|
||||
structlog>=25.4.0
|
||||
toml>=0.10.2
|
||||
tomlkit>=0.13.3
|
||||
urllib3>=2.5.0
|
||||
uvicorn>=0.35.0
|
||||
|
|
@ -1,64 +1,9 @@
|
|||
import os
|
||||
from pymongo import MongoClient
|
||||
from peewee import SqliteDatabase
|
||||
from pymongo.database import Database
|
||||
from rich.traceback import install
|
||||
|
||||
install(extra_lines=3)
|
||||
|
||||
_client = None
|
||||
_db = None
|
||||
|
||||
|
||||
def __create_database_instance():
|
||||
uri = os.getenv("MONGODB_URI")
|
||||
host = os.getenv("MONGODB_HOST", "127.0.0.1")
|
||||
port = int(os.getenv("MONGODB_PORT", "27017"))
|
||||
# db_name 变量在创建连接时不需要,在获取数据库实例时才使用
|
||||
username = os.getenv("MONGODB_USERNAME")
|
||||
password = os.getenv("MONGODB_PASSWORD")
|
||||
auth_source = os.getenv("MONGODB_AUTH_SOURCE")
|
||||
|
||||
if uri:
|
||||
# 支持标准mongodb://和mongodb+srv://连接字符串
|
||||
if uri.startswith(("mongodb://", "mongodb+srv://")):
|
||||
return MongoClient(uri)
|
||||
else:
|
||||
raise ValueError(
|
||||
"Invalid MongoDB URI format. URI must start with 'mongodb://' or 'mongodb+srv://'. "
|
||||
"For MongoDB Atlas, use 'mongodb+srv://' format. "
|
||||
"See: https://www.mongodb.com/docs/manual/reference/connection-string/"
|
||||
)
|
||||
|
||||
if username and password:
|
||||
# 如果有用户名和密码,使用认证连接
|
||||
return MongoClient(host, port, username=username, password=password, authSource=auth_source)
|
||||
|
||||
# 否则使用无认证连接
|
||||
return MongoClient(host, port)
|
||||
|
||||
|
||||
def get_db():
|
||||
"""获取数据库连接实例,延迟初始化。"""
|
||||
global _client, _db
|
||||
if _client is None:
|
||||
_client = __create_database_instance()
|
||||
_db = _client[os.getenv("DATABASE_NAME", "MegBot")]
|
||||
return _db
|
||||
|
||||
|
||||
class DBWrapper:
|
||||
"""数据库代理类,保持接口兼容性同时实现懒加载。"""
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(get_db(), name)
|
||||
|
||||
def __getitem__(self, key):
|
||||
return get_db()[key] # type: ignore
|
||||
|
||||
|
||||
# 全局数据库访问点
|
||||
memory_db: Database = DBWrapper() # type: ignore
|
||||
|
||||
# 定义数据库文件路径
|
||||
ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
|
||||
|
|
|
|||
Loading…
Reference in New Issue