init
This commit is contained in:
9
config/.api_cost.json
Normal file
9
config/.api_cost.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"daily": {
|
||||
"2026-02-26": 1.4850000000000005,
|
||||
"2026-02-27": 1.3200000000000007
|
||||
},
|
||||
"monthly": {
|
||||
"2026-02": 2.8050000000000015
|
||||
}
|
||||
}
|
||||
10
config/DESIGNER_ROSTER_API.md
Normal file
10
config/DESIGNER_ROSTER_API.md
Normal file
@@ -0,0 +1,10 @@
|
||||
# 设计师在线查询 API(本端接入)
|
||||
|
||||
- **地址**:`.env` 中 `DESIGNER_ROSTER_API`,如 `http://huichang.online:8001/online`
|
||||
- **方法**:GET
|
||||
- **返回**:`{online_users: ["lz", "ZuoWei"], ...}`,本端用 `online_users` 同步本地后派单
|
||||
|
||||
## 调用时机
|
||||
|
||||
- **转人工时**按需 GET 一次,不轮询
|
||||
- 无人在线时:回退到 `transfer_groups.json` 静态配置,并发送企微「谁在线啊」提醒
|
||||
33
config/DESIGNER_ROSTER_需求-给另一台AI.md
Normal file
33
config/DESIGNER_ROSTER_需求-给另一台AI.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# 设计师在线查询服务 - 需求(给另一台 AI)
|
||||
|
||||
## 你要做的
|
||||
|
||||
建库,从企微群解析「上线」「下线」消息并存储,提供 **GET 接口** 返回当前在线设计师名单。
|
||||
|
||||
## 接口
|
||||
|
||||
- **方法**:GET
|
||||
- **路径**:如 `/online`
|
||||
|
||||
## 返回格式(本端已适配)
|
||||
|
||||
```json
|
||||
{
|
||||
"online_count": 2,
|
||||
"online_users": ["lz", "ZuoWei"],
|
||||
"update_time": "2026-02-26 16:30:00"
|
||||
}
|
||||
```
|
||||
|
||||
| 字段 | 必填 | 说明 |
|
||||
|------|------|------|
|
||||
| online_users | 是 | 当前在线设计师名单,对应 init_designer_roster 的 wechat_user_id |
|
||||
|
||||
## 你这边的逻辑
|
||||
|
||||
1. 企微群消息 → 解析「上线」/「下线」→ 存库
|
||||
2. 接口从库查当前在线名单,按 `online_users` 返回
|
||||
|
||||
## 调用方
|
||||
|
||||
本端在**转人工时**按需 GET 一次,用 `online_users` 同步本地后派单。无人在线时发企微「谁在线啊」。
|
||||
36
config/README.md
Normal file
36
config/README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# 配置文件
|
||||
|
||||
## transfer_groups.json
|
||||
|
||||
店铺 → 转接分组映射(静态)。不同店铺(acc_id)对应不同客服分组。
|
||||
|
||||
```json
|
||||
{
|
||||
"default": "20252916034",
|
||||
"小威哥1216": "20252916034",
|
||||
"另一店铺": "12345678"
|
||||
}
|
||||
```
|
||||
|
||||
- **default**:未配置的店铺使用的默认分组 ID
|
||||
- **其他 key**:店铺 `acc_id`
|
||||
- **value**:该店铺转接时使用的分组 ID
|
||||
|
||||
---
|
||||
|
||||
## 设计师派单(SQLite,可选)
|
||||
|
||||
同一设计师在不同店铺对应不同 group_id,转人工时按需查询在线状态,从在线设计师中轮询派单。
|
||||
|
||||
**初始化数据**:
|
||||
```bash
|
||||
python scripts/init_designer_roster.py example # 写入示例
|
||||
python scripts/init_designer_roster.py list # 查看当前数据
|
||||
```
|
||||
|
||||
**数据库**:`db/designer_roster_db/roster.db`
|
||||
- `designers`:设计师(name, wechat_user_id)
|
||||
- `designer_shops`:设计师在某店铺的 group_id(同一人不同店铺不同分组)
|
||||
- `designer_online`:在线状态(转人工时按需查询外部 API 同步)
|
||||
|
||||
**接入**:`.env` 配置 `DESIGNER_ROSTER_API`(如 `http://xxx/online`),转人工时 GET 一次,用 `online_users` 同步。无人在线时发企微「谁在线啊」。
|
||||
1
config/__init__.py
Normal file
1
config/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
BIN
config/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
config/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
config/__pycache__/config.cpython-310.pyc
Normal file
BIN
config/__pycache__/config.cpython-310.pyc
Normal file
Binary file not shown.
49
config/config.py
Normal file
49
config/config.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
配置中心 - 统一管理路径、常量
|
||||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
# ========== 项目路径 ==========
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
LOG_DIR = ROOT / "logs"
|
||||
RESULTS_DIR = Path(os.getenv("RESULT_IMAGE_DIR", str(ROOT / "results")))
|
||||
CONFIG_DIR = ROOT / "config"
|
||||
CUSTOMER_DB_DIR = ROOT / "customer_db"
|
||||
|
||||
# ========== 轻简 ==========
|
||||
QINGJIAN_WS_URI = os.getenv("QINGJIAN_WS_URI", "ws://127.0.0.1:9528")
|
||||
|
||||
# ========== 企微 ==========
|
||||
WECHAT_WEBHOOK = os.getenv("WECHAT_WEBHOOK", "")
|
||||
|
||||
# ========== 日志 ==========
|
||||
LOG_MAX_BYTES = int(os.getenv("LOG_MAX_BYTES", "10")) * 1024 * 1024 # 默认 10MB
|
||||
LOG_BACKUP_COUNT = int(os.getenv("LOG_BACKUP_COUNT", "7"))
|
||||
|
||||
# ========== 图片队列 ==========
|
||||
IMAGE_QUEUE_MAX_CONCURRENT = int(os.getenv("IMAGE_QUEUE_MAX_CONCURRENT", "2"))
|
||||
IMAGE_QUEUE_MAX_SIZE = int(os.getenv("IMAGE_QUEUE_MAX_SIZE", "20"))
|
||||
|
||||
# ========== 健康检查 ==========
|
||||
HEALTH_CHECK_INTERVAL = int(os.getenv("HEALTH_CHECK_INTERVAL", "60")) # 秒
|
||||
HEALTH_CHECK_WECHAT_PING = os.getenv("HEALTH_CHECK_WECHAT_PING", "false").lower() in ("1", "true", "yes")
|
||||
HEALTH_CHECK_STARTUP_GRACE = int(os.getenv("HEALTH_CHECK_STARTUP_GRACE", "15"))
|
||||
HEALTH_CHECK_QINGJIAN_ALERTS_ENABLED = os.getenv("HEALTH_CHECK_QINGJIAN_ALERTS_ENABLED", "false").lower() in ("1", "true", "yes")
|
||||
|
||||
# ========== 功能开关 ==========
|
||||
IMAGE_MODULE_ENABLED = os.getenv("IMAGE_MODULE_ENABLED", "false").lower() in ("1", "true", "yes")
|
||||
|
||||
# ========== 防抖配置 ==========
|
||||
MESSAGE_DEBOUNCE_SECONDS = int(os.getenv("MESSAGE_DEBOUNCE_SECONDS", "8"))
|
||||
|
||||
# ========== AI 上下文加载 ==========
|
||||
CHAT_CONTEXT_LIMIT = int(os.getenv("CHAT_CONTEXT_LIMIT", "30"))
|
||||
CHAT_CONTEXT_TRUNCATE_LEN = int(os.getenv("CHAT_CONTEXT_TRUNCATE_LEN", "160"))
|
||||
|
||||
# ========== 报价底线 ==========
|
||||
MIN_PRICE_FLOOR = int(os.getenv("MIN_PRICE_FLOOR", "15"))
|
||||
27
config/shop_prompts.json
Normal file
27
config/shop_prompts.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"shops": {
|
||||
"tb2801080146": {
|
||||
"type": "gemini_api",
|
||||
"hint": "【店铺类型】Gemini API 账号。客户问账号/pro/续费/没pro时,按API客服回复:续费/充值/套餐说明。"
|
||||
},
|
||||
"小威哥1216": {
|
||||
"type": "find_image",
|
||||
"hint": "【店铺类型】找原图/修图。"
|
||||
}
|
||||
},
|
||||
"goods_keywords": {
|
||||
"gemini": "gemini_api",
|
||||
"pro": "gemini_api",
|
||||
"nano": "gemini_api",
|
||||
"api": "gemini_api",
|
||||
"找原图": "find_image",
|
||||
"修图": "find_image",
|
||||
"模糊图": "find_image",
|
||||
"清晰处理": "find_image"
|
||||
},
|
||||
"type_hints": {
|
||||
"gemini_api": "【店铺类型】Gemini API 账号。客户问账号/pro/续费/没pro时,按API客服回复:续费/充值/套餐说明,自然回复。",
|
||||
"find_image": "【店铺类型】找原图/修图。"
|
||||
},
|
||||
"_comment": "新增店铺:在 shops 加 acc_id。新增商品类型:在 goods_keywords 加关键词→类型。"
|
||||
}
|
||||
4
config/transfer_groups.json
Normal file
4
config/transfer_groups.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"default": "20252916034",
|
||||
"小威哥1216": "20252916034"
|
||||
}
|
||||
Reference in New Issue
Block a user