From e6aa585e0631fa5f9ffbd1b80fceaa544f5b70fd Mon Sep 17 00:00:00 2001 From: Developer Date: Tue, 17 Mar 2026 17:29:24 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 Python 项目配置 (pyproject.toml) - 添加环境变量示例 (.env.example) - 添加 Docker 忽略文件 (.dockerignore) - 添加 TypeScript 配置 (tsconfig.json, tsconfig.node.json) Co-Authored-By: Claude Opus 4.6 --- backend/.dockerignore | 50 +++++++++++++++ backend/.env.example | 24 +++++++ backend/pyproject.toml | 125 ++++++++++++++++++++++++++++++++++++ frontend/tsconfig.json | 26 ++++++++ frontend/tsconfig.node.json | 11 ++++ 5 files changed, 236 insertions(+) create mode 100644 backend/.dockerignore create mode 100644 backend/.env.example create mode 100644 backend/pyproject.toml create mode 100644 frontend/tsconfig.json create mode 100644 frontend/tsconfig.node.json diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..00e57d0 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,50 @@ +# Git +.git +.gitignore + +# Python +__pycache__ +*.py[cod] +*$py.class +*.so +.Python +venv/ +.venv/ +env/ +.env +*.egg-info/ +dist/ +build/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# Testing +.pytest_cache/ +.coverage +htmlcov/ + +# Logs +*.log +logs/ + +# Database +*.db +*.sqlite +*.sqlite3 + +# Uploads (should be persisted separately) +uploads/* +!uploads/.gitkeep + +# Docker +Dockerfile +.dockerignore + +# Misc +.DS_Store +*.md +docs/ diff --git a/backend/.env.example b/backend/.env.example new file mode 100644 index 0000000..0c0d9b4 --- /dev/null +++ b/backend/.env.example @@ -0,0 +1,24 @@ +# Application +APP_NAME=YG-Dataset +DEBUG=true +HOST=0.0.0.0 +PORT=8000 +ALLOWED_ORIGINS=* + +# Database - Use SQLite for development, PostgreSQL for production +DATABASE_URL=sqlite+aiosqlite:///./ygdataset.db +DATABASE_URL_SYNC=sqlite:///./ygdataset.db + +# Security +SECRET_KEY=your-secret-key-change-in-production + +# File Storage +UPLOAD_DIR=./uploads +MAX_FILE_SIZE=104857600 + +# LLM Settings +DEFAULT_MODEL_PROVIDER=openai +DEFAULT_MODEL_NAME=gpt-4o-mini + +# Logging +LOG_LEVEL=INFO diff --git a/backend/pyproject.toml b/backend/pyproject.toml new file mode 100644 index 0000000..44596e3 --- /dev/null +++ b/backend/pyproject.toml @@ -0,0 +1,125 @@ +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "yg-dataset" +version = "1.0.0" +description = "Dataset Generation Platform API" +readme = "README.md" +requires-python = ">=3.11" +license = {text = "MIT"} +authors = [ + {name = "YG-Dataset Team", email = "team@yg-dataset.com"} +] +keywords = ["dataset", "machine-learning", "llm", "data-generation"] +classifiers = [ + "Development Status :: 4 - Beta", + "Framework :: FastAPI", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] + +dependencies = [ + "fastapi>=0.115.0", + "uvicorn[standard]>=0.30.0", + "python-multipart>=0.0.9", + "sqlalchemy>=2.0.0", + "alembic>=1.13.0", + "pydantic>=2.0.0", + "pydantic-settings>=2.0.0", + "pdfplumber>=0.10.4", + "python-docx>=1.1.0", + "openpyxl>=3.1.2", + "pandas>=2.2.0", + "ebooklib>=0.5", + "PyMuPDF>=1.24.0", + "langchain>=0.3.0", + "langchain-community>=0.2.0", + "langchain-openai>=0.1.0", + "tiktoken>=0.7.0", + "python-dotenv>=1.0.0", + "python-dateutil>=2.8.2", + "httpx>=0.27.0", + "aiofiles>=23.2.1", +] + +[project.optional-dependencies] +dev = [ + "pytest>=8.0.0", + "pytest-asyncio>=0.23.0", + "pytest-cov>=4.1.0", + "ruff>=0.3.0", + "mypy>=1.8.0", + "pre-commit>=3.6.0", + "black>=24.2.0", +] + +[tool.uv] +dev-dependencies = [ + "pytest>=8.0.0", + "pytest-asyncio>=0.23.0", + "pytest-cov>=4.1.0", + "ruff>=0.3.0", + "mypy>=1.8.0", +] + +[tool.ruff] +line-length = 100 +target-version = "py311" + +[tool.ruff.lint] +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "I", # isort + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "UP", # pyupgrade +] +ignore = [ + "E501", # line too long (handled by formatter) + "B008", # do not perform function calls in argument defaults +] + +[tool.mypy] +python_version = "3.11" +warn_return_any = true +warn_unused_configs = true +disallow_untyped_defs = false +disallow_incomplete_defs = false +check_untyped_defs = true +no_implicit_optional = true +warn_redundant_casts = true +warn_unused_ignores = true +warn_no_return = true + +[tool.pytest.ini_options] +asyncio_mode = "auto" +testpaths = ["tests"] +python_files = ["test_*.py"] +python_classes = ["Test*"] +python_functions = ["test_*"] +addopts = "-v --tb=short" + +[tool.coverage.run] +source = ["app"] +omit = [ + "*/tests/*", + "*/venv/*", +] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise AssertionError", + "raise NotImplementedError", + "if __name__ == .__main__.:", +] + +[project.scripts] +yg-dataset = "app.main:main" diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json new file mode 100644 index 0000000..44ee1ca --- /dev/null +++ b/frontend/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "preserve", + "strict": true, + "noUnusedLocals": false, + "noUnusedParameters": false, + "noFallthroughCasesInSwitch": true, + "paths": { + "@/*": ["./src/*"] + }, + "baseUrl": ".", + "types": ["vite/client"] + }, + "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/frontend/tsconfig.node.json b/frontend/tsconfig.node.json new file mode 100644 index 0000000..97ede7e --- /dev/null +++ b/frontend/tsconfig.node.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "strict": true + }, + "include": ["vite.config.ts"] +}