init: AI日报 pipeline 完整代码 + 技能文档 + 运行记录
This commit is contained in:
29
skill/references/llm-config-auto-follow.md
Normal file
29
skill/references/llm-config-auto-follow.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# AI Daily Pipeline — LLM Config Auto-Follow (2026-05-30)
|
||||
|
||||
## Problem
|
||||
The daily report script had hardcoded `XIAOMI_API_KEY` / `XIAOMI_BASE_URL` env vars. When the user switches Hermes' main model provider, the script would still use the old provider unless manually updated.
|
||||
|
||||
## Solution: `resolve_llm_config(env)`
|
||||
Added to `ai_daily_blog_pipeline.py` (replaces hardcoded reads in `llm_call()`):
|
||||
|
||||
```python
|
||||
def resolve_llm_config(env: dict):
|
||||
"""Read Hermes config to get the active provider's API key, base_url, and model."""
|
||||
# 1. Read ~/.hermes/config.yaml → model.provider, model.base_url, model.default
|
||||
# 2. Read ~/.hermes/auth.json → credential_pool[provider].source (e.g. "env:XIAOMI_API_KEY")
|
||||
# 3. Resolve env var name → actual key from .env
|
||||
# 4. Fallback to LLM_API_KEY / XIAOMI_API_KEY if auth.json lookup fails
|
||||
return api_key, base_url, model_name
|
||||
```
|
||||
|
||||
## Config Sources (priority order)
|
||||
1. `~/.hermes/config.yaml` → `model.provider`, `model.base_url`, `model.default`
|
||||
2. `~/.hermes/auth.json` → `credential_pool[provider][0].source` (format: `env:VAR_NAME`)
|
||||
3. `~/.hermes/.env` → actual key value
|
||||
4. Legacy fallback: `LLM_API_KEY` / `XIAOMI_API_KEY` / `LLM_BASE_URL` / `LLM_MODEL`
|
||||
|
||||
## Usage
|
||||
When user runs `hermes config set model.provider=minimax`, the daily report script automatically uses MiniMax's API key and endpoint on the next run. No script changes needed.
|
||||
|
||||
## Pitfall
|
||||
The script needs `import yaml` — ensure `PyYAML` is installed. It's available in the Hermes venv but may not be in system Python.
|
||||
Reference in New Issue
Block a user