profile-claw 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- profile_claw-0.1.0/PKG-INFO +688 -0
- profile_claw-0.1.0/README.md +665 -0
- profile_claw-0.1.0/pyproject.toml +49 -0
- profile_claw-0.1.0/src/profile_claw/__init__.py +19 -0
- profile_claw-0.1.0/src/profile_claw/cli.py +183 -0
- profile_claw-0.1.0/src/profile_claw/core.py +236 -0
- profile_claw-0.1.0/src/profile_claw/prompts/__init__.py +0 -0
- profile_claw-0.1.0/src/profile_claw/prompts/email_prompt.md +38 -0
- profile_claw-0.1.0/src/profile_claw/prompts/eval_prompt.md +58 -0
- profile_claw-0.1.0/src/profile_claw/prompts/format_prompt.md +72 -0
- profile_claw-0.1.0/src/profile_claw/prompts/summary_prompt.md +39 -0
- profile_claw-0.1.0/src/profile_claw/templates/index.html +447 -0
- profile_claw-0.1.0/src/profile_claw/web.py +238 -0
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: profile-claw
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 大模型简历处理工具:格式化、评估、邮件生成、总结概括
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Keywords: cli,formatter,llm,profile,resume
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Topic :: Text Processing
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Requires-Dist: fastapi>=0.100.0
|
|
16
|
+
Requires-Dist: jinja2>=3.1.0
|
|
17
|
+
Requires-Dist: llmdog>=0.0.3
|
|
18
|
+
Requires-Dist: python-multipart>=0.0.5
|
|
19
|
+
Requires-Dist: rich>=13.0.0
|
|
20
|
+
Requires-Dist: typer>=0.9.0
|
|
21
|
+
Requires-Dist: uvicorn>=0.20.0
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# profile-claw
|
|
25
|
+
|
|
26
|
+
**大模型简历处理工具** - 基于大语言模型的简历格式化、评估、邮件生成与总结概括命令行工具。
|
|
27
|
+
|
|
28
|
+
profile-claw 是一个 PyPI 可安装的 Python 模块,通过 [llmdog](https://pypi.org/project/llmdog/) 库调用大语言模型,支持兼容 OpenAI Chat Completions 格式的任意 API 端点。CLI 命令为 `profile`,同时提供 Python API 两种使用方式。
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 功能特性
|
|
33
|
+
|
|
34
|
+
- **格式化(format)**:将非结构化简历文本转换为标准 JSON 格式
|
|
35
|
+
- **评估(eval)**:对简历进行完整性、专业性、技能匹配度、呈现效果四维度评分分析
|
|
36
|
+
- **邮件生成(email)**:基于候选人简历生成招聘 outreach 邮件
|
|
37
|
+
- **总结概括(summary)**:提取简历核心信息,生成精炼总结
|
|
38
|
+
- **初始化(init)**:一键初始化本地 prompt 模板文件,支持自定义
|
|
39
|
+
- **批量处理**:支持单文件和目录批量处理
|
|
40
|
+
- **双重使用方式**:CLI 命令行 + Python 函数调用
|
|
41
|
+
- **Web 管理界面**:基于 FastAPI + Alpine.js 的 prompt 模板和 LLM 配置管理
|
|
42
|
+
- **灵活配置**:支持多种 LLM 模型、自定义 prompt 模板
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 安装和环境配置
|
|
47
|
+
|
|
48
|
+
### 前置要求
|
|
49
|
+
|
|
50
|
+
- Python >= 3.10
|
|
51
|
+
- pip 包管理器
|
|
52
|
+
|
|
53
|
+
### 方式一:直接安装(推荐用于生产)
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install profile-claw
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 方式二:开发模式安装
|
|
60
|
+
|
|
61
|
+
1. **克隆或下载项目**
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
cd /path/to/profile-claw
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
2. **创建虚拟环境**
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# 在项目根目录创建名为 venv 的虚拟环境
|
|
71
|
+
python -m venv venv
|
|
72
|
+
|
|
73
|
+
# 激活虚拟环境
|
|
74
|
+
# macOS / Linux:
|
|
75
|
+
source venv/bin/activate
|
|
76
|
+
|
|
77
|
+
# Windows:
|
|
78
|
+
venv\Scripts\activate
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
3. **安装依赖并以开发模式安装**
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install -e .
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
4. **验证安装**
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# 验证 CLI 命令
|
|
91
|
+
profile --version
|
|
92
|
+
# 输出: profile 0.1.0
|
|
93
|
+
|
|
94
|
+
# 验证 Python 导入
|
|
95
|
+
python -c "import profile_claw; print(profile_claw.__version__)"
|
|
96
|
+
# 输出: 0.1.0
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 虚拟环境说明
|
|
100
|
+
|
|
101
|
+
虚拟环境(venv)会将 Python 解释器和所有依赖项隔离在项目目录中,不影响系统全局环境。
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
project-root/
|
|
105
|
+
├── venv/ # 虚拟环境目录(隔离的 Python 环境)
|
|
106
|
+
├── src/
|
|
107
|
+
│ └── profile_claw/ # 源代码
|
|
108
|
+
└── pyproject.toml # 项目配置
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**常用虚拟环境操作:**
|
|
112
|
+
|
|
113
|
+
| 操作 | 命令 |
|
|
114
|
+
|------|------|
|
|
115
|
+
| 激活 | `source venv/bin/activate` (macOS/Linux) 或 `venv\Scripts\activate` (Windows) |
|
|
116
|
+
| 退出 | `deactivate` |
|
|
117
|
+
| 运行命令 | `venv/bin/profile --version`(无需激活) |
|
|
118
|
+
| 安装包 | `venv/bin/pip install <package>` |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 使用示例
|
|
123
|
+
|
|
124
|
+
### CLI 命令行使用
|
|
125
|
+
|
|
126
|
+
#### 查看帮助信息
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
profile --help
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
输出:
|
|
133
|
+
```
|
|
134
|
+
Usage: profile [OPTIONS] COMMAND [ARGS]...
|
|
135
|
+
|
|
136
|
+
大模型简历处理工具:格式化、评估、邮件生成、总结概括
|
|
137
|
+
|
|
138
|
+
Options:
|
|
139
|
+
--version, -v 显示版本号
|
|
140
|
+
--help Show this message and exit.
|
|
141
|
+
|
|
142
|
+
Commands:
|
|
143
|
+
init 初始化本地 prompt 模板文件到 profile-prompts/ 目录
|
|
144
|
+
format 格式化简历:将简历文本转换为标准 JSON 格式
|
|
145
|
+
eval 评估简历:对简历进行多维度评分和分析
|
|
146
|
+
email 生成招聘邮件:基于简历内容生成招聘 outreach 邮件
|
|
147
|
+
summary 总结简历:提取核心信息生成精炼总结
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### 初始化本地 prompt 模板
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# 在当前目录创建 profile-prompts/ 目录
|
|
154
|
+
profile init
|
|
155
|
+
|
|
156
|
+
# 指定目标目录
|
|
157
|
+
profile init --dir /path/to/project
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
执行后会在目标目录创建 `profile-prompts/` 子目录,包含四个 prompt 模板文件:
|
|
161
|
+
- `format_prompt.md`
|
|
162
|
+
- `eval_prompt.md`
|
|
163
|
+
- `email_prompt.md`
|
|
164
|
+
- `summary_prompt.md`
|
|
165
|
+
|
|
166
|
+
#### 格式化简历
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# 处理单个文件(输出到同目录:resume_format.json)
|
|
170
|
+
profile format resume.txt
|
|
171
|
+
|
|
172
|
+
# 处理目录(输出到同级 resume_format/ 目录)
|
|
173
|
+
profile format resume_dir/
|
|
174
|
+
|
|
175
|
+
# 指定输出目录
|
|
176
|
+
profile format resume.txt --output output/
|
|
177
|
+
|
|
178
|
+
# 使用自定义 prompt
|
|
179
|
+
profile format resume.txt --prompt "请将以下简历转为JSON格式:{content}"
|
|
180
|
+
|
|
181
|
+
# 使用自定义 prompt 文件
|
|
182
|
+
profile format resume.txt --prompt-file my_prompt.md
|
|
183
|
+
|
|
184
|
+
# 指定 LLM 模型
|
|
185
|
+
profile format resume.txt --model gpt-4
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### 评估简历
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
profile eval resume.txt
|
|
192
|
+
profile eval resume_dir/ --output eval_results/
|
|
193
|
+
profile eval resume.txt --model gpt-4
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### 生成招聘邮件
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
profile email resume.txt
|
|
200
|
+
profile email resume.txt --output emails/
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### 总结简历
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
profile summary resume.txt
|
|
207
|
+
profile summary resume_dir/ --output summaries/
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Python API 使用
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
import profile_claw
|
|
214
|
+
|
|
215
|
+
# 初始化本地 prompt 模板
|
|
216
|
+
profile_claw.init()
|
|
217
|
+
profile_claw.init(dir="/path/to/project")
|
|
218
|
+
|
|
219
|
+
# 格式化简历
|
|
220
|
+
output_files = profile_claw.format_resume("resume.txt")
|
|
221
|
+
output_files = profile_claw.format_resume("resume.txt", output_dir="output/")
|
|
222
|
+
output_files = profile_claw.format_resume("resume.txt", model="gpt-4")
|
|
223
|
+
output_files = profile_claw.format_resume("resume.txt", prompt="自定义prompt...{content}")
|
|
224
|
+
|
|
225
|
+
# 评估简历
|
|
226
|
+
output_files = profile_claw.eval_resume("resume.txt")
|
|
227
|
+
|
|
228
|
+
# 生成招聘邮件
|
|
229
|
+
output_files = profile_claw.generate_email("resume.txt")
|
|
230
|
+
|
|
231
|
+
# 总结简历
|
|
232
|
+
output_files = profile_claw.summary("resume.txt")
|
|
233
|
+
|
|
234
|
+
# 批量处理目录
|
|
235
|
+
output_files = profile_claw.format_resume("resume_dir/")
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**函数签名:**
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
def format_resume(
|
|
242
|
+
input_path: str | Path,
|
|
243
|
+
output_dir: str | Path | None = None,
|
|
244
|
+
prompt: str | None = None,
|
|
245
|
+
prompt_file: str | Path | None = None,
|
|
246
|
+
model: str | None = None,
|
|
247
|
+
) -> list[Path]:
|
|
248
|
+
"""格式化简历,返回输出文件路径列表。"""
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
其他函数(`eval_resume`、`generate_email`、`summary`)签名相同。
|
|
252
|
+
|
|
253
|
+
### Web 管理界面使用
|
|
254
|
+
|
|
255
|
+
启动 Web 管理界面:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
# 默认 127.0.0.1:7070
|
|
259
|
+
profile web
|
|
260
|
+
|
|
261
|
+
# 自定义地址和端口
|
|
262
|
+
profile web --host 0.0.0.0 --port 8080
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
打开浏览器访问 `http://127.0.0.1:7070`,界面提供:
|
|
266
|
+
|
|
267
|
+
| 功能 | 说明 |
|
|
268
|
+
|------|------|
|
|
269
|
+
| Prompt 模板管理 | 查看/编辑/新建/删除/重置 prompt 模板 |
|
|
270
|
+
| 内置模板 | 查看包内默认模板,可一键复制到本地 |
|
|
271
|
+
| 本地模板 | 管理 `profile-prompts/` 目录下的自定义模板 |
|
|
272
|
+
| LLM 配置 | 设置 API Key、URL、模型、超时时间、SSL 验证 |
|
|
273
|
+
|
|
274
|
+
**提示:** Web 界面配置的 LLM 参数仅在当前会话有效,重启后需重新设置。持久化配置请使用环境变量。
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## API 接口说明
|
|
279
|
+
|
|
280
|
+
### 公共 API
|
|
281
|
+
|
|
282
|
+
| 函数 | 说明 |
|
|
283
|
+
|------|------|
|
|
284
|
+
| `profile_claw.__version__` | 版本号字符串 |
|
|
285
|
+
| `profile_claw.init(dir=None)` | 初始化本地 prompt 模板,返回 prompt 目录路径 |
|
|
286
|
+
| `profile_claw.format_resume(input_path, ...)` | 格式化简历,返回输出文件路径列表 |
|
|
287
|
+
| `profile_claw.eval_resume(input_path, ...)` | 评估简历,返回输出文件路径列表 |
|
|
288
|
+
| `profile_claw.generate_email(input_path, ...)` | 生成招聘邮件,返回输出文件路径列表 |
|
|
289
|
+
| `profile_claw.summary(input_path, ...)` | 总结简历,返回输出文件路径列表 |
|
|
290
|
+
|
|
291
|
+
### 参数说明
|
|
292
|
+
|
|
293
|
+
| 参数 | 类型 | 说明 |
|
|
294
|
+
|------|------|------|
|
|
295
|
+
| `input_path` | `str \| Path` | 输入文件或目录路径(必填) |
|
|
296
|
+
| `output_dir` | `str \| Path \| None` | 输出目录,默认自动计算 |
|
|
297
|
+
| `prompt` | `str \| None` | 自定义 prompt 内容(优先级最高) |
|
|
298
|
+
| `prompt_file` | `str \| Path \| None` | 自定义 prompt 文件路径 |
|
|
299
|
+
| `model` | `str \| None` | 指定 LLM 模型名称 |
|
|
300
|
+
|
|
301
|
+
### 输出格式
|
|
302
|
+
|
|
303
|
+
**格式化输出(`*_format.json`):**
|
|
304
|
+
```json
|
|
305
|
+
{
|
|
306
|
+
"basic_info": { "name": "张三", "gender": "男", "age": 28, ... },
|
|
307
|
+
"education": [...],
|
|
308
|
+
"work_experience": [...],
|
|
309
|
+
"project_experience": [...],
|
|
310
|
+
"skills": { "technical": [...], "languages": [...], ... },
|
|
311
|
+
"self_evaluation": "..."
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**评估输出(`*_eval.json`):**
|
|
316
|
+
```json
|
|
317
|
+
{
|
|
318
|
+
"overall_score": 85,
|
|
319
|
+
"overall_level": "良好",
|
|
320
|
+
"dimensions": {
|
|
321
|
+
"completeness": { "score": 80, "comment": "..." },
|
|
322
|
+
"professionalism": { "score": 85, "comment": "..." },
|
|
323
|
+
"skill_match": { "score": 90, "comment": "..." },
|
|
324
|
+
"presentation": { "score": 80, "comment": "..." }
|
|
325
|
+
},
|
|
326
|
+
"highlights": [...],
|
|
327
|
+
"weaknesses": [...],
|
|
328
|
+
"suggestions": [...],
|
|
329
|
+
"summary": "..."
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
**邮件输出(`*_email.json`):**
|
|
334
|
+
```json
|
|
335
|
+
{
|
|
336
|
+
"subject": "高级Python工程师机会 - [公司名称]",
|
|
337
|
+
"greeting": "尊敬的张三:",
|
|
338
|
+
"body": {
|
|
339
|
+
"introduction": "我是XX公司技术招聘负责人...",
|
|
340
|
+
"highlights": ["您在Python后端开发方面的5年经验", "主导的高并发项目成果", "开源社区贡献"],
|
|
341
|
+
"motivation": "我们正在寻找...",
|
|
342
|
+
"closing": "期待与您进一步交流..."
|
|
343
|
+
},
|
|
344
|
+
"signature": "此致\n敬礼\n\n李四\n技术招聘经理",
|
|
345
|
+
"full_text": "完整邮件文本..."
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
**总结输出(`*_summary.json`):**
|
|
350
|
+
```json
|
|
351
|
+
{
|
|
352
|
+
"name": "张三",
|
|
353
|
+
"one_line_summary": "5年经验的Python后端工程师...",
|
|
354
|
+
"years_of_experience": 5,
|
|
355
|
+
"core_skills": ["Python", "Django", ...],
|
|
356
|
+
"key_achievements": [...],
|
|
357
|
+
"summary_paragraph": "综合总结..."
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## 依赖项清单
|
|
364
|
+
|
|
365
|
+
| 依赖 | 版本要求 | 用途 |
|
|
366
|
+
|------|----------|------|
|
|
367
|
+
| `typer` | >= 0.9.0 | CLI 命令行框架 |
|
|
368
|
+
| `llmdog` | >= 0.0.3 | LLM 调用库,支持 OpenAI 兼容格式 |
|
|
369
|
+
| `rich` | >= 13.0.0 | 终端美化和格式化输出 |
|
|
370
|
+
| `fastapi` | >= 0.100.0 | Web 框架 |
|
|
371
|
+
| `uvicorn` | >= 0.20.0 | ASGI 服务器 |
|
|
372
|
+
| `jinja2` | >= 3.1.0 | HTML 模板引擎 |
|
|
373
|
+
| `python-multipart` | >= 0.0.5 | 表单数据解析 |
|
|
374
|
+
|
|
375
|
+
**间接依赖(由 llmdog 和 typer 引入):**
|
|
376
|
+
- `requests` - HTTP 请求
|
|
377
|
+
- `tenacity` - 重试策略
|
|
378
|
+
- `pyyaml` - YAML 配置解析
|
|
379
|
+
- `typing-extensions` - 类型扩展
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## 配置方法详解
|
|
384
|
+
|
|
385
|
+
### LLM API 配置
|
|
386
|
+
|
|
387
|
+
profile-claw 通过 [llmdog](https://pypi.org/project/llmdog/) 库与 LLM API 通信。配置方式:
|
|
388
|
+
|
|
389
|
+
#### 1. 环境变量(推荐)
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
# 必填:API Key
|
|
393
|
+
export LLM_API_KEY="your-api-key-here"
|
|
394
|
+
|
|
395
|
+
# 可选:API URL(默认为 OpenAI 端点)
|
|
396
|
+
export LLM_API_URL="https://api.openai.com/v1"
|
|
397
|
+
|
|
398
|
+
# 可选:默认模型名称
|
|
399
|
+
export LLM_MODEL="gpt-4"
|
|
400
|
+
|
|
401
|
+
# 可选:请求超时时间(秒,默认 60)
|
|
402
|
+
export LLM_TIMEOUT=60
|
|
403
|
+
|
|
404
|
+
# 可选:SSL 证书验证(默认 true)
|
|
405
|
+
export LLM_VERIFY_SSL=true
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
#### 2. 命令行参数
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
# 逐次指定模型
|
|
412
|
+
profile format resume.txt --model gpt-4
|
|
413
|
+
profile eval resume.txt -m claude-3-sonnet
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
#### 3. llmdog 配置文件
|
|
417
|
+
|
|
418
|
+
llmdog 支持 YAML 配置文件,详见 [llmdog 文档](https://pypi.org/project/llmdog/)。
|
|
419
|
+
|
|
420
|
+
#### 支持的 LLM 提供商
|
|
421
|
+
|
|
422
|
+
任何兼容 OpenAI Chat Completions 格式的 API 端点均可使用:
|
|
423
|
+
- OpenAI (GPT-4, GPT-3.5)
|
|
424
|
+
- Anthropic Claude(通过兼容层)
|
|
425
|
+
- Azure OpenAI
|
|
426
|
+
- 本地部署的兼容模型(如 Ollama、LM Studio)
|
|
427
|
+
- 其他兼容提供商
|
|
428
|
+
|
|
429
|
+
### 自定义 Prompt 模板
|
|
430
|
+
|
|
431
|
+
#### 方式一:使用 init 命令初始化后修改
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
# 1. 初始化本地 prompt 模板
|
|
435
|
+
profile init
|
|
436
|
+
|
|
437
|
+
# 2. 编辑生成的模板文件
|
|
438
|
+
# 修改 profile-prompts/format_prompt.md 等文件
|
|
439
|
+
|
|
440
|
+
# 3. 后续执行会自动使用本地模板
|
|
441
|
+
profile format resume.txt
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
**Prompt 优先级(从高到低):**
|
|
445
|
+
1. 显式指定:`--prompt` 或 `--prompt-file` 参数
|
|
446
|
+
2. 本地文件:`profile-prompts/{action}_prompt.md`
|
|
447
|
+
3. 内置默认:包内 `profile_claw/prompts/` 目录
|
|
448
|
+
|
|
449
|
+
#### 方式二:命令行直接传入
|
|
450
|
+
|
|
451
|
+
```bash
|
|
452
|
+
# 直接传入 prompt 内容
|
|
453
|
+
profile format resume.txt --prompt "请将简历转为JSON:{content}"
|
|
454
|
+
|
|
455
|
+
# 传入 prompt 文件
|
|
456
|
+
profile format resume.txt --prompt-file my_custom_prompt.md
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
**注意:** prompt 模板必须包含 `{content}` 占位符,运行时会被替换为实际简历内容。
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
## 扩展性说明
|
|
464
|
+
|
|
465
|
+
### 项目架构
|
|
466
|
+
|
|
467
|
+
```
|
|
468
|
+
src/profile_claw/
|
|
469
|
+
├── __init__.py # 公共 API 导出
|
|
470
|
+
├── cli.py # Typer CLI 命令行界面
|
|
471
|
+
├── core.py # 核心处理逻辑
|
|
472
|
+
├── web.py # FastAPI Web 管理界面后端
|
|
473
|
+
├── templates/
|
|
474
|
+
│ └── index.html # Web 管理界面前端(Alpine.js + Tailwind CSS)
|
|
475
|
+
└── prompts/
|
|
476
|
+
├── __init__.py
|
|
477
|
+
├── format_prompt.md # 内置格式化 prompt
|
|
478
|
+
├── eval_prompt.md # 内置评估 prompt
|
|
479
|
+
├── email_prompt.md # 内置邮件生成 prompt
|
|
480
|
+
└── summary_prompt.md # 内置总结 prompt
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
**核心模块职责:**
|
|
484
|
+
- `core.py`:文件读写、prompt 解析、LLM 调用、JSON 清理、输出路径计算
|
|
485
|
+
- `cli.py`:命令行参数解析、命令注册、用户交互
|
|
486
|
+
- `web.py`:FastAPI 后端,prompt CRUD 和 LLM 配置管理 API
|
|
487
|
+
- `templates/`:Web 管理界面 HTML 页面
|
|
488
|
+
- `prompts/`:内置 prompt 模板,与代码逻辑分离
|
|
489
|
+
|
|
490
|
+
### Web API 接口
|
|
491
|
+
|
|
492
|
+
启动 Web 服务后,可通过以下 API 进行编程管理:
|
|
493
|
+
|
|
494
|
+
| 方法 | 路径 | 说明 |
|
|
495
|
+
|------|------|------|
|
|
496
|
+
| `GET` | `/api/prompts` | 列出所有 prompt 模板(内置 + 本地) |
|
|
497
|
+
| `GET` | `/api/prompts/builtin/{action}` | 获取内置 prompt |
|
|
498
|
+
| `GET` | `/api/prompts/local/{filename}` | 获取本地 prompt |
|
|
499
|
+
| `POST` | `/api/prompts/local` | 创建本地 prompt |
|
|
500
|
+
| `PUT` | `/api/prompts/local/{filename}` | 更新本地 prompt |
|
|
501
|
+
| `DELETE` | `/api/prompts/local/{filename}` | 删除本地 prompt |
|
|
502
|
+
| `POST` | `/api/prompts/local/{filename}/reset` | 从内置模板重置 |
|
|
503
|
+
| `GET` | `/api/config/llm` | 获取 LLM 配置 |
|
|
504
|
+
| `PUT` | `/api/config/llm` | 更新 LLM 配置 |
|
|
505
|
+
| `DELETE` | `/api/config/llm` | 清除 LLM 配置 |
|
|
506
|
+
|
|
507
|
+
**请求示例:**
|
|
508
|
+
|
|
509
|
+
```bash
|
|
510
|
+
# 获取所有 prompt
|
|
511
|
+
curl http://127.0.0.1:7070/api/prompts
|
|
512
|
+
|
|
513
|
+
# 创建本地 prompt
|
|
514
|
+
curl -X POST http://127.0.0.1:7070/api/prompts/local \
|
|
515
|
+
-H 'Content-Type: application/json' \
|
|
516
|
+
-d '{"name": "translate", "filename": "translate_prompt.md", "content": "翻译以下简历:{content}"}'
|
|
517
|
+
|
|
518
|
+
# 更新 LLM 配置
|
|
519
|
+
curl -X PUT http://127.0.0.1:7070/api/config/llm \
|
|
520
|
+
-H 'Content-Type: application/json' \
|
|
521
|
+
-d '{"api_key": "sk-...", "api_url": "https://api.openai.com/v1", "model": "gpt-4", "timeout": 60, "verify_ssl": true}'
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### 添加新的处理功能
|
|
525
|
+
|
|
526
|
+
以添加"翻译(translate)"功能为例:
|
|
527
|
+
|
|
528
|
+
1. **创建 prompt 模板**
|
|
529
|
+
|
|
530
|
+
在 `src/profile_claw/prompts/` 目录创建 `translate_prompt.md`:
|
|
531
|
+
|
|
532
|
+
```markdown
|
|
533
|
+
# 简历翻译
|
|
534
|
+
|
|
535
|
+
请将以下简历翻译成英文,保持专业术语的准确性。
|
|
536
|
+
|
|
537
|
+
## 简历内容
|
|
538
|
+
|
|
539
|
+
{content}
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
2. **注册到 PROMPT_FILES**
|
|
543
|
+
|
|
544
|
+
编辑 `src/profile_claw/core.py`:
|
|
545
|
+
|
|
546
|
+
```python
|
|
547
|
+
PROMPT_FILES = {
|
|
548
|
+
"format": "format_prompt.md",
|
|
549
|
+
"eval": "eval_prompt.md",
|
|
550
|
+
"email": "email_prompt.md",
|
|
551
|
+
"summary": "summary_prompt.md",
|
|
552
|
+
"translate": "translate_prompt.md", # 新增
|
|
553
|
+
}
|
|
554
|
+
ACTIONS = {"format", "eval", "email", "summary", "translate"} # 新增
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
3. **添加 API 函数**
|
|
558
|
+
|
|
559
|
+
在 `src/profile_claw/core.py` 中添加:
|
|
560
|
+
|
|
561
|
+
```python
|
|
562
|
+
def translate_resume(
|
|
563
|
+
input_path: str | Path,
|
|
564
|
+
output_dir: str | Path | None = None,
|
|
565
|
+
prompt: str | None = None,
|
|
566
|
+
prompt_file: str | Path | None = None,
|
|
567
|
+
model: str | None = None,
|
|
568
|
+
) -> list[Path]:
|
|
569
|
+
"""翻译简历,返回输出文件路径列表。"""
|
|
570
|
+
return process_resume("translate", input_path, output_dir, prompt, prompt_file, model)
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
4. **添加 CLI 命令**
|
|
574
|
+
|
|
575
|
+
在 `src/profile_claw/cli.py` 中添加:
|
|
576
|
+
|
|
577
|
+
```python
|
|
578
|
+
from profile_claw.core import translate_resume # 导入新函数
|
|
579
|
+
|
|
580
|
+
@app.command()
|
|
581
|
+
def translate(
|
|
582
|
+
input_path: Path = typer.Argument(..., help="输入文件或目录路径"),
|
|
583
|
+
output: Optional[Path] = typer.Option(None, "--output", "-o", help="输出目录"),
|
|
584
|
+
prompt: Optional[str] = typer.Option(None, "--prompt", "-p", help="自定义 prompt 内容"),
|
|
585
|
+
prompt_file: Optional[Path] = typer.Option(None, "--prompt-file", "-P", help="自定义 prompt 文件路径"),
|
|
586
|
+
model: Optional[str] = typer.Option(None, "--model", "-m", help="指定 LLM 模型"),
|
|
587
|
+
) -> None:
|
|
588
|
+
"""翻译简历:将简历翻译成目标语言"""
|
|
589
|
+
_process_action("translate", input_path, output, prompt, prompt_file, model)
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
5. **导出新函数**
|
|
593
|
+
|
|
594
|
+
在 `src/profile_claw/__init__.py` 中添加导出:
|
|
595
|
+
|
|
596
|
+
```python
|
|
597
|
+
from profile_claw.core import translate_resume
|
|
598
|
+
|
|
599
|
+
__all__ = [
|
|
600
|
+
# ... 其他导出
|
|
601
|
+
"translate_resume",
|
|
602
|
+
]
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
### 修改现有 prompt 模板
|
|
606
|
+
|
|
607
|
+
**方式一:修改内置模板(需要重新安装包)**
|
|
608
|
+
|
|
609
|
+
直接编辑 `src/profile_claw/prompts/` 目录下的 `.md` 文件,然后重新安装:
|
|
610
|
+
|
|
611
|
+
```bash
|
|
612
|
+
pip install -e .
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
**方式二:使用本地模板(推荐)**
|
|
616
|
+
|
|
617
|
+
```bash
|
|
618
|
+
# 1. 初始化本地模板
|
|
619
|
+
profile init
|
|
620
|
+
|
|
621
|
+
# 2. 修改本地模板
|
|
622
|
+
# 编辑 profile-prompts/format_prompt.md
|
|
623
|
+
|
|
624
|
+
# 3. 后续执行自动使用本地模板
|
|
625
|
+
profile format resume.txt
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
---
|
|
629
|
+
|
|
630
|
+
## 贡献指南与许可证信息
|
|
631
|
+
|
|
632
|
+
### 贡献指南
|
|
633
|
+
|
|
634
|
+
欢迎贡献代码、报告问题或提出改进建议!
|
|
635
|
+
|
|
636
|
+
1. **Fork 项目** 并创建功能分支
|
|
637
|
+
2. **编写代码** 遵循项目代码风格
|
|
638
|
+
3. **添加测试** 确保新功能有相应测试覆盖
|
|
639
|
+
4. **提交 PR** 描述清楚改动内容和原因
|
|
640
|
+
|
|
641
|
+
**开发环境设置:**
|
|
642
|
+
|
|
643
|
+
```bash
|
|
644
|
+
# 克隆项目
|
|
645
|
+
git clone <repo-url>
|
|
646
|
+
cd profile-claw
|
|
647
|
+
|
|
648
|
+
# 创建虚拟环境
|
|
649
|
+
python -m venv venv
|
|
650
|
+
source venv/bin/activate
|
|
651
|
+
|
|
652
|
+
# 开发模式安装
|
|
653
|
+
pip install -e .
|
|
654
|
+
|
|
655
|
+
# 运行测试(如有)
|
|
656
|
+
pytest
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
### 许可证
|
|
660
|
+
|
|
661
|
+
本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件。
|
|
662
|
+
|
|
663
|
+
---
|
|
664
|
+
|
|
665
|
+
## 常见问题
|
|
666
|
+
|
|
667
|
+
**Q: LLM 调用失败怎么办?**
|
|
668
|
+
|
|
669
|
+
检查 `LLM_API_KEY` 环境变量是否正确设置,以及 API URL 是否可访问。
|
|
670
|
+
|
|
671
|
+
```bash
|
|
672
|
+
echo $LLM_API_KEY
|
|
673
|
+
curl $LLM_API_URL/models -H "Authorization: Bearer $LLM_API_KEY"
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
**Q: 如何查看当前使用的 prompt?**
|
|
677
|
+
|
|
678
|
+
使用 `init` 命令导出内置 prompt 到本地查看:
|
|
679
|
+
|
|
680
|
+
```bash
|
|
681
|
+
profile init
|
|
682
|
+
cat profile-prompts/format_prompt.md
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
**Q: 支持哪些文件格式?**
|
|
686
|
+
|
|
687
|
+
输入支持:`.txt`、`.json`、`.md`、`.markdown`
|
|
688
|
+
输出格式:JSON(2 空格缩进,中文不转义)
|