Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SmartTavern 环境变量配置示例
# 复制此文件为 .env 并填写实际值

# ==================== API 网关配置 ====================
# API 网关监听地址和端口
MODULARFLOW_API_BASE_URL=http://localhost:8050
MODULARFLOW_API_PREFIX=/api

# ==================== JWT 认证配置 ====================
# JWT 密钥(必须设置,建议使用随机字符串)
# 生成方法: python -c "import secrets; print(secrets.token_urlsafe(32))"
JWT_SECRET_KEY=your-secret-key-here-change-me

# ==================== API Key 加密配置 ====================
# API Key 加密密钥(必须设置)
# 生成方法: python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
API_KEY_ENCRYPTION_KEY=your-encryption-key-here-change-me

# ==================== CORS 配置 ====================
# 允许的跨域来源(多个用逗号分隔,生产环境必须限制)
# 默认值:http://localhost:5173,http://localhost:8080,http://localhost:3000
CORS_ORIGINS=http://localhost:5173,http://localhost:8080,http://localhost:3000

# ==================== 开发配置 ====================
# 是否启用调试模式
DEBUG=False

# 是否启用 API 文档
ENABLE_API_DOCS=True

# ==================== 日志配置 ====================
# 日志级别: DEBUG, INFO, WARNING, ERROR, CRITICAL
LOG_LEVEL=INFO

# ==================== 安全建议 ====================
# 1. 务必修改 JWT_SECRET_KEY 和 API_KEY_ENCRYPTION_KEY
# 2. 不要将 .env 文件提交到 Git
# 3. 生产环境应使用 HTTPS
# 4. 限制 CORS_ORIGINS 为可信来源
30 changes: 30 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[flake8]
# 遵循 PEP 8 规范,兼容 Black 格式化器
max-line-length = 88
extend-ignore = E203, E266, E501, W503
exclude =
.git,
__pycache__,
.venv,
venv,
env,
build,
dist,
*.egg-info,
.tox,
.eggs,
node_modules,
.pytest_cache,
.mypy_cache

# 每个文件最大复杂度
max-complexity = 10

# 每个函数最大行数
max-function-length = 50

# 忽略的错误代码说明:
# E203: whitespace before ':' (与 Black 冲突)
# E266: too many leading '#' for block comment
# E501: line too long (由 Black 处理)
# W503: line break before binary operator (PEP 8 已更新)
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,14 @@ __pycache__/
*.py[cod]
*$py.class
demo_branch_backend
demo_branch_frontend
demo_branch_frontend

# Virtual environments
.venv/
.env

# macOS files
.DS_Store

# prompt files
.prompt/
23 changes: 23 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 依赖和构建产物
node_modules/
dist/
build/
.venv/
venv/
env/
*.egg-info/

# 配置文件
package-lock.json
yarn.lock
pnpm-lock.yaml

# 缓存
.cache/
.pytest_cache/
.mypy_cache/
__pycache__/

# 文档
.prompt/
docs/
26 changes: 26 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "es5",
"printWidth": 100,
"arrowParens": "avoid",
"endOfLine": "lf",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"overrides": [
{
"files": "*.vue",
"options": {
"parser": "vue"
}
},
{
"files": "*.md",
"options": {
"proseWrap": "preserve"
}
}
]
}
2 changes: 1 addition & 1 deletion api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
_REPO_ROOT = os.path.abspath(os.path.join(_API_DIR, ".."))

if _REPO_ROOT not in sys.path:
sys.path.insert(0, _REPO_ROOT)
sys.path.insert(0, _REPO_ROOT)
3 changes: 2 additions & 1 deletion api/modules/SmartTavern/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
- 统一通过 import core 门面进行跨模块调用,不直接 import 其他模块的 impl
- 该 __init__.py 文件用于确保服务发现(rglob("__init__.py"))能识别此为包
"""
__all__ = []

__all__ = []
10 changes: 5 additions & 5 deletions api/modules/SmartTavern/assets_normalizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"""

from .assets_normalizer import ( # noqa: F401
normalize,
extract_preset_regex,
extract_character_world_book,
extract_character_regex,
merge_world_books,
extract_character_world_book,
extract_preset_regex,
merge_regex,
)
merge_world_books,
normalize,
)
Loading