[project] name = "yuanqi" version = "0.1.0" description = "元炁 · 魂镜本地推理引擎 — LLM / Embedding / Reranker / Multimodal(纯 Python,直接推理)" authors = [{ name = "chenxin", email = "2685475410@qq.com" }] license = "MIT" requires-python = ">=3.12" dependencies = [ "fastapi>=0.139.0", "loguru>=0.7.3", "numba>=0.66.0", "pydantic>=2.13.4", "pydantic-settings>=2.14.2", "python-multipart>=0.0.12", "sentencepiece>=0.2.2", "torch>=2.11.0", "torchaudio>=2.11.0", "transformers>=5.13.1", "uvicorn[standard]>=0.51.0", ] [project.optional-dependencies] llm = ["llama-cpp-python>=0.3.34"] embedding = ["FlagEmbedding>=1.4.0"] asr = ["funasr>=1.2.0"] modelscope = ["modelscope>=1.16.0"] all = ["yuanqi[llm,embedding,asr,modelscope]"] dev = [ "pre-commit>=4.6.0", "pytest>=9.1.1", "pytest-asyncio>=1.4.0", "ruff>=0.15.21", ] lint = ["black>=26.5.1", "mypy>=2.3.0", "ruff>=0.15.21"] test = ["pytest>=9.1.1", "pytest-asyncio>=1.4.0", "pytest-cov>=7.1.0"] dev-all = ["yuanqi[dev,lint,test]"] # ============================================= # uv 配置 - 跨平台 PyTorch 自动适配 # ============================================= # 默认使用中科大镜像(所有平台通用)当前服务器对中科大源访问快,其他源可以按照下面方法测试来换源 # curl -o /dev/null -s -w '清华源: %{time_total}s\n' https://pypi.tuna.tsinghua.edu.cn/simple/ # curl -o /dev/null -s -w '阿里云: %{time_total}s\n' https://mirrors.aliyun.com/pypi/simple/ # curl -o /dev/null -s -w '南大源: %{time_total}s\n' https://mirror.nju.edu.cn/pypi/web/simple/ # curl -o /dev/null -s -w 'PyPI官方: %{time_total}s\n' https://pypi.org/simple/ # curl -o /dev/null -s -w '中科大源: %{time_total}s\n' https://pypi.mirrors.ustc.edu.cn/simple/ [[tool.uv.index]] name = "ustc" url = "https://pypi.mirrors.ustc.edu.cn/simple/" default = true # PyTorch CUDA 12.8 专用源(仅 Linux/Windows 使用) # 目前发现仅南京大学和阿里云(https://mirrors.aliyun.com/pytorch-wheels/cu128/)可用;中科大,清华源等都找不到 [[tool.uv.index]] name = "pytorch-cu128" url = "https://mirrors.nju.edu.cn/pytorch/whl/cu128/" explicit = true # === 包来源映射:根据操作系统自动选择 === [tool.uv.sources] # Linux/Windows:使用 CUDA 12.8 版本 torch = { index = "pytorch-cu128", marker = "sys_platform == 'linux' or sys_platform == 'win32'" } torchvision = { index = "pytorch-cu128", marker = "sys_platform == 'linux' or sys_platform == 'win32'" } torchaudio = { index = "pytorch-cu128", marker = "sys_platform == 'linux' or sys_platform == 'win32'" } yuanqi = { workspace = true } # macOS:从默认源(中科大)自动获取 CPU/MPS 版本 # 不需要额外配置,会自动回退到 default = true 的源 # macOS 验证(应该使用 MPS) # python -c "import torch; print(f'PyTorch: {torch.__version__}'); print(f'MPS available: {torch.backends.mps.is_available()}'); print(f'CUDA available: {torch.cuda.is_available()}')" # Linux/Windows 验证(应该使用 CUDA) # python -c "import torch; print(f'PyTorch: {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}'); print(f'CUDA version: {torch.version.cuda if torch.cuda.is_available() else \"N/A\"}')" [build-system] requires = ["hatchling"] build-backend = "hatchling.build" # 告诉 hatchling 包在 src/ 目录下 [tool.hatch.build.targets.wheel] packages = ["src"] [tool.ruff] line-length = 100 target-version = "py312" [tool.ruff.lint] select = ["E", "F", "I", "N", "W"] [tool.pytest.ini_options] asyncio_mode = "auto" testpaths = ["tests"]