这个项目现在走的是最现实的首版方案:
固定区域截图 -> OCR -> 本地知识库检索 -> 国产模型生成建议回复 -> 可选粘贴到输入框
前面已经验证过,拼多多工作台主窗口对 UI Automation 基本不暴露聊天内容,所以这里优先走 OCR + 固定区域识别。
- 固定区域截图
RapidOCR识别中文聊天内容- 本地知识库
RAG检索 - 兼容 OpenAI 风格接口的国产模型调用
- 可选自动粘贴到客服输入框
- 区域拖拽选取工具
- 鼠标坐标实时查看工具
pip install -r requirements.txt先复制一份配置:
Copy-Item config.example.yaml config.local.yaml然后把 config.local.yaml 里的这些内容改成你的实际值:
capture.latest_customer_regioncapture.chat_context_regioncapture.input_regionmodel.base_urlmodel.modelmodel.api_key或环境变量名prompt.store_name
最方便的方式是拖拽选区:
python -m pdd_cs_assistant pick-region --name latest_customer_region
python -m pdd_cs_assistant pick-region --name chat_context_region
python -m pdd_cs_assistant pick-region --name input_region每次选完都会输出一段 JSON,并默认复制到剪贴板。
如果你想手工看坐标:
python -m pdd_cs_assistant show-mouse建议把拼多多工作台窗口固定在同一个位置,再去标定区域。
把你店铺自己的规则写进 knowledge_base:
- 发货规则
- 物流规则
- 退款/售后规则
- 优惠券和补偿边界
- 哪些场景必须转人工
现在目录里已经放了几份示例文档,你可以直接改。
如果你不想把 Key 写进配置文件,可以用环境变量:
$env:PDD_CS_API_KEY="你的_API_Key"然后在 config.local.yaml 里保留:
model:
api_key: ""
api_key_env: PDD_CS_API_KEY先确认 OCR 和检索是不是通的:
python -m pdd_cs_assistant run-once --config config.local.yaml --skip-model如果终端会挡住拼多多窗口,推荐这样跑:
python -m pdd_cs_assistant run-once --config config.local.yaml --skip-model --delay 5输入命令后,立刻切回拼多多客服窗口,程序会等 5 秒再截图。
运行后会在 runs/时间戳/ 下面生成:
latest_customer.pngchat_context.pngresult.json
先看截图有没有截对,再看 result.json 里的 OCR 文本有没有识别准。
python -m pdd_cs_assistant run-once --config config.local.yaml如果要自动把回复粘贴到输入框,但不自动发送:
python -m pdd_cs_assistant run-once --config config.local.yaml --paste如果你是从终端启动,建议加上延时:
python -m pdd_cs_assistant run-once --config config.local.yaml --delay 5如果你想让它持续盯着最新消息变化:
python -m pdd_cs_assistant watch --config config.local.yaml自动粘贴版本:
python -m pdd_cs_assistant watch --config config.local.yaml --paste注意:
- 默认不会自动发送消息
- 建议首版只用“生成建议回复”或“自动粘贴”,不要自动回车发送
- 固定区域方案依赖窗口位置稳定,窗口尺寸变了要重新标定
- 主入口: pdd_cs_assistant/cli.py
- 工作流: pdd_cs_assistant/workflow.py
- OCR 适配: pdd_cs_assistant/ocr_engine.py
- 检索模块: pdd_cs_assistant/rag.py
- 模型调用: pdd_cs_assistant/llm_client.py
- 示例配置: config.example.yaml
之前用于验证窗口可读性的脚本还在:
- probe_uia.py
探测结果说明当前拼多多工作台不适合继续深挖 UIA,所以本项目主路径已经切到 OCR + RAG。