mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-04 07:09:38 +08:00
* feat: enhance error handling and logging in DocumentAdder * feat: implement robust error handling utilities for API exceptions * style: fix formatting issues * feat: implement retry logic for LLM API calls to handle rate limits and timeouts * feat: enhance document validation and error handling in file uploads * feat: enhance valid tools configuration and error handling in project structure * feat: refactor error handling and validation functions for improved robustness * fix: pre-commit format * feat: implement configuration validation for tool consistency and enhance error handling in file uploads * feat: add exception hierarchy for LLM service errors to improve error handling * chore: update repo roster images [skip ci] * chore: update repo roster images [skip ci] * Integrate documentation updates and rebase onto upstream dev * Implement error handling utilities and validation functions * feat: implement multi-provider support with enhanced capability handling and model extraction * fix: enhance error handling and validation across multiple modules * chore: remove unused local environment configuration file * commit * fix: improve error handling and logging in utilities and error handler * fix: enhance error handling and logging across multiple modules * fix: enhance async initialization and validation in multiple modules * feat: implement LLM error framework - Add LLM-specific exception classes in exceptions.py - Create error mapping utilities for standardized error handling - Implement base provider interface with error handling - Add OpenAI provider implementation with error mapping - Define LLM types and response structures * feat: add missing registry and telemetry modules - Add registry.py for provider registration system - Add telemetry.py for basic LLM call tracking - Complete the LLM error framework implementation * fix(llm): safer sync wrapper + smarter retries + optional openai mapping * Fix LLM error framework and code quality improvements * feat: update environment configuration and improve logging in LLM services * Update README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Refactor code structure for improved readability and maintainability * chore: update documentation, improve error handling, and enhance file upload validation * feat: enhance error handling and configuration validation across multiple modules * feat: add configuration for pytest, improve error handling, and enhance byte formatting utilities --------- Co-authored-by: scrrlt <smo0051@student.monash.edu> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
183 lines
5.0 KiB
TOML
183 lines
5.0 KiB
TOML
# Python project configuration for DeepTutor
|
|
# This file configures Black, Ruff, and other Python tools
|
|
|
|
[build-system]
|
|
requires = ["setuptools>=61.0", "wheel"]
|
|
build-backend = "setuptools.build_meta"
|
|
|
|
[project]
|
|
name = "ai-tutor"
|
|
version = "0.4.1"
|
|
description = "An intelligent learning companion with multi-agent collaboration and RAG"
|
|
requires-python = ">=3.10"
|
|
readme = "README.md"
|
|
license = {text = "Apache-2.0"}
|
|
|
|
# Optional dependencies for different LLM providers
|
|
[project.optional-dependencies]
|
|
anthropic = ["anthropic>=0.30.0"]
|
|
dashscope = ["dashscope>=1.14.0"]
|
|
search = ["perplexityai>=0.1.0"]
|
|
all = [
|
|
"anthropic>=0.30.0",
|
|
"dashscope>=1.14.0",
|
|
"perplexityai>=0.1.0"
|
|
]
|
|
|
|
# ============================================
|
|
# Black code formatter configuration
|
|
# ============================================
|
|
[tool.black]
|
|
line-length = 100
|
|
target-version = ['py310', 'py311', 'py312']
|
|
include = '\.pyi?$'
|
|
extend-exclude = '''
|
|
/(
|
|
# Exclude directories
|
|
\.eggs
|
|
| \.git
|
|
| \.hg
|
|
| \.mypy_cache
|
|
| \.tox
|
|
| \.venv
|
|
| venv
|
|
| _build
|
|
| buck-out
|
|
| build
|
|
| dist
|
|
| __pycache__
|
|
| node_modules
|
|
| \.next
|
|
)/
|
|
'''
|
|
|
|
# ============================================
|
|
# Ruff linter and formatter configuration
|
|
# ============================================
|
|
[tool.ruff]
|
|
# Target Python version
|
|
target-version = "py310"
|
|
line-length = 100
|
|
|
|
[tool.ruff.lint]
|
|
# 只启用最基础的规则(放宽要求)
|
|
select = [
|
|
"E", # pycodestyle errors (语法错误)
|
|
"F", # pyflakes (未使用的导入、变量等)
|
|
"I", # isort (import 排序)
|
|
# 其他规则都忽略,不强制要求
|
|
]
|
|
|
|
# Ignore specific rules (放宽检查,只保留重要规则)
|
|
ignore = [
|
|
"E501", # Line too long (handled by formatter)
|
|
"B008", # Do not perform function calls in argument defaults
|
|
"PLR0911", # Too many return statements
|
|
"PLR0912", # Too many branches
|
|
"PLR0913", # Too many arguments
|
|
"PLR0915", # Too many statements
|
|
"PLR2004", # Magic value used in comparison
|
|
"TRY003", # Avoid specifying long messages outside exception class
|
|
"T201", # print found (允许 print 语句,用于调试)
|
|
"E722", # Do not use bare except (某些情况下需要)
|
|
"E402", # Module level import not at top of file (某些情况下需要)
|
|
"PLC0415", # import should be at top-level (某些情况下需要)
|
|
"PTH123", # open() should be replaced by Path.open() (允许使用 open)
|
|
"PTH103", # os.makedirs() should be replaced by Path.mkdir() (允许使用 os.makedirs)
|
|
"PTH118", # os.path.join() should be replaced by Path (允许使用 os.path.join)
|
|
"B904", # Within except clause, raise exceptions with raise ... from err
|
|
"EM101", # Exception must not use a string literal
|
|
"EM102", # Exception must not use an f-string literal
|
|
"TRY002", # Create your own exception
|
|
"TRY300", # Consider moving this statement to an else block
|
|
"DTZ005", # datetime.now() called without tz argument
|
|
"RET504", # Unnecessary assignment before return
|
|
"PLW2901", # for loop variable overwritten by assignment target
|
|
"F841", # Local variable assigned but never used
|
|
"ERA001", # Found commented-out code (允许注释代码)
|
|
"B006", # Do not use mutable data structures for argument defaults
|
|
]
|
|
|
|
# Exclude patterns
|
|
exclude = [
|
|
".bzr",
|
|
".direnv",
|
|
".eggs",
|
|
".git",
|
|
".git-rewrite",
|
|
".hg",
|
|
".mypy_cache",
|
|
".nox",
|
|
".pants.d",
|
|
".pyenv",
|
|
".pytest_cache",
|
|
".pytype",
|
|
".ruff_cache",
|
|
".svn",
|
|
".tox",
|
|
".venv",
|
|
".vscode",
|
|
"__pypackages__",
|
|
"_build",
|
|
"buck-out",
|
|
"build",
|
|
"dist",
|
|
"node_modules",
|
|
".next",
|
|
"out",
|
|
"venv",
|
|
"__pycache__",
|
|
]
|
|
|
|
# Allow autofix for all enabled rules
|
|
fixable = ["ALL"]
|
|
unfixable = []
|
|
|
|
# Allow unused variables when underscore-prefixed
|
|
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
|
|
[tool.ruff.format]
|
|
# Use double quotes for strings
|
|
quote-style = "double"
|
|
# Indent with spaces
|
|
indent-style = "space"
|
|
# Respect magic trailing comma
|
|
skip-magic-trailing-comma = false
|
|
# Automatically detect the appropriate line ending
|
|
line-ending = "auto"
|
|
|
|
# ============================================
|
|
# Ruff import sorting (isort replacement)
|
|
# ============================================
|
|
[tool.ruff.lint.isort]
|
|
known-first-party = ["src", "scripts"]
|
|
force-sort-within-sections = true
|
|
split-on-trailing-comma = true
|
|
|
|
# ============================================
|
|
# Ruff per-file-ignores
|
|
# ============================================
|
|
[tool.ruff.lint.per-file-ignores]
|
|
# Allow longer lines in test files
|
|
"**/test_*.py" = ["E501", "PLR2004"]
|
|
"**/__init__.py" = ["F401"] # Allow unused imports in __init__.py
|
|
|
|
# ============================================
|
|
# Ruff mccabe complexity
|
|
# ============================================
|
|
[tool.ruff.lint.mccabe]
|
|
max-complexity = 10
|
|
|
|
# ============================================
|
|
# Pytest configuration
|
|
# ============================================
|
|
[tool.pytest.ini_options]
|
|
testpaths = ["tests"]
|
|
pythonpath = ["."]
|
|
addopts = [
|
|
"--strict-markers",
|
|
"--strict-config",
|
|
"--disable-warnings",
|
|
"--tb=short"
|
|
]
|