diff --git a/.env.example b/.env.example index 34dc4a0..31c2f70 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,14 @@ -# 必填 +# 必填: 两个 provider 二选一(默认 DeepSeek) +# 方案 A: DeepSeek(默认) DEEPSEEK_API_KEY=sk-xxxxxxxxxxxxxxxx # 可选: 自定义 API 地址(中转用) # DEEPSEEK_BASE_URL=https://api.deepseek.com +# 方案 B: OrcaRouter(OpenAI 兼容 AI 网关,设置后自动接管全部 LLM 调用) +# ORCAROUTER_API_KEY=sk-orca-xxxxxxxxxxxxxxxx +# ORCAROUTER_BASE_URL=https://api.orcarouter.ai/v1 +# ORCAROUTER_MODEL=orcarouter/auto + # 可选: 飞书机器人(国内首选) FEISHU_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxx FEISHU_SECRET=xxxxxxxxxxxxxxxx diff --git a/CLAUDE.md b/CLAUDE.md index e3109c7..7ac40cb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -23,6 +23,7 @@ ## 密钥 - DeepSeek `DEEPSEEK_API_KEY`(命名 AIuse):本地在项目根 `.env`(gitignored),GitHub 侧在 repo secret;两处已同步更新。密钥值不放本文件。 +- OrcaRouter `ORCAROUTER_API_KEY`(可选):设置后自动接管全部 LLM 调用(base `https://api.orcarouter.ai/v1`,默认模型 `orcarouter/auto`),与 DeepSeek 二选一;GitHub 侧同样走 repo secret。 - 飞书 `FEISHU_WEBHOOK_URL` / `FEISHU_SECRET`:仅在 GitHub repo secret。 - `XHS_COOKIE`(小红书):仅本地 `.env`,微调发布脚本用。 diff --git a/src/config.py b/src/config.py index 6172f65..faeda14 100644 --- a/src/config.py +++ b/src/config.py @@ -33,10 +33,23 @@ def env_str(key: str, default: str = "") -> str: # China has no DST, fixed offset avoids the tzdata dependency on Windows BEIJING_TZ = timezone(timedelta(hours=8), name="Asia/Shanghai") -# --- LLM --- -LLM_API_KEY = env_str("DEEPSEEK_API_KEY") -LLM_BASE_URL = env_str("DEEPSEEK_BASE_URL", "https://api.deepseek.com") -LLM_MODEL = env_str("LLM_MODEL", "deepseek-chat") +# --- LLM provider --- +# Two named providers share the same OpenAI-compatible wiring. DeepSeek is the +# default; setting ORCAROUTER_API_KEY opts the whole pipeline into OrcaRouter +# (an OpenAI-compatible AI gateway) without touching process.py, which only +# reads the resolved LLM_* values below. +ORCAROUTER_API_KEY = env_str("ORCAROUTER_API_KEY") +ORCAROUTER_BASE_URL = env_str("ORCAROUTER_BASE_URL", "https://api.orcarouter.ai/v1") +ORCAROUTER_MODEL = env_str("ORCAROUTER_MODEL", "orcarouter/auto") + +if ORCAROUTER_API_KEY: + LLM_API_KEY = ORCAROUTER_API_KEY + LLM_BASE_URL = ORCAROUTER_BASE_URL + LLM_MODEL = ORCAROUTER_MODEL +else: + LLM_API_KEY = env_str("DEEPSEEK_API_KEY") + LLM_BASE_URL = env_str("DEEPSEEK_BASE_URL", "https://api.deepseek.com") + LLM_MODEL = env_str("LLM_MODEL", "deepseek-chat") # --- Content Sources --- SOURCES = { diff --git a/src/main.py b/src/main.py index 88960e5..d8e8c53 100644 --- a/src/main.py +++ b/src/main.py @@ -9,7 +9,9 @@ python src/main.py --publish-only # only publish (needs digest.md + social_posts.json) Environment variables required: - DEEPSEEK_API_KEY - DeepSeek API key + DEEPSEEK_API_KEY - DeepSeek API key (default provider) + ORCAROUTER_API_KEY - OrcaRouter API key; when set, it takes over all + LLM calls instead of DeepSeek (OpenAI-compatible gateway) DEEPSEEK_BASE_URL - (optional) custom endpoint FEISHU_WEBHOOK_URL - (optional) Feishu bot webhook FEISHU_SECRET - (optional) Feishu bot sign secret