-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.example.py
More file actions
65 lines (57 loc) · 3.03 KB
/
Copy pathconfig.example.py
File metadata and controls
65 lines (57 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# =============================================================================
# AutoAssignment 配置文件模板
# =============================================================================
# 使用说明:
# 1. 复制本文件为 config.py
# 2. 填写你的实际配置信息
# 3. 确保 config.py 不被提交到 Git(已在 .gitignore 中配置)
# =============================================================================
import os
# -----------------------------------------------------------------------------
# 1. API 配置
# -----------------------------------------------------------------------------
# Kimi API Token,用于调用月之暗面大模型服务
# 获取方式:访问 https://platform.moonshot.cn/ 注册并创建 API Key
#
# 安全建议:使用环境变量存储 Token,避免硬编码
# 设置环境变量方法:
# - Windows PowerShell: $env:KIMI_API_TOKEN = "your-token"
# - Windows CMD: set KIMI_API_TOKEN=your-token
# - macOS/Linux: export KIMI_API_TOKEN="your-token"
# -----------------------------------------------------------------------------
KIMI_API_TOKEN = os.getenv("KIMI_API_TOKEN", "your-api-token-here")
# -----------------------------------------------------------------------------
# 2. 个人信息配置
# -----------------------------------------------------------------------------
# 用于自动填充文档中的个人信息区域
# 请根据实际情况修改以下字段
# -----------------------------------------------------------------------------
PERSONAL_INFO = {
"date": "2026年4月2日", # 日期,格式可自定义
"major_class": "软件工程01", # 专业和班级
"name": "张三", # 姓名
"student_id": "20230001" # 学号
}
# -----------------------------------------------------------------------------
# 3. 文件夹配置
# -----------------------------------------------------------------------------
# 输入文件夹:放置待处理的原始文档(.docx 格式)
# 输出文件夹:保存处理完成的文档
# 文件夹会在运行时自动创建(如果不存在)
# -----------------------------------------------------------------------------
INPUT_FOLDER = "input" # 输入文件夹路径/名称
OUTPUT_FOLDER = "output" # 输出文件夹路径/名称
# =============================================================================
# 配置验证(可选)
# =============================================================================
def validate_config():
"""验证配置是否完整"""
if not KIMI_API_TOKEN or KIMI_API_TOKEN == "your-api-token-here":
raise ValueError("错误:请配置 KIMI_API_TOKEN,获取方式见 README.md")
required_fields = ["date", "major_class", "name", "student_id"]
for field in required_fields:
if field not in PERSONAL_INFO or not PERSONAL_INFO[field]:
raise ValueError(f"错误:PERSONAL_INFO 中缺少 {field} 字段")
print("✅ 配置验证通过")
# 运行验证(取消注释以启用)
# validate_config()