Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ STEP.md

# config
ec_config.h

# codex
.codex
47 changes: 38 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,50 @@ Build-time configuration is layered:
- [`components/embed_claw/ec_config_internal.h`](components/embed_claw/ec_config_internal.h) provides repo defaults and empty secret placeholders.
- Create local [`main/ec_config.h`](main/ec_config.h) for project-specific overrides. Define only the macros you want to override. The build injects this header into `embed_claw`, so sensitive values do not need to live in the shared component tree.

Create `main/ec_config.h` if needed, then set at least:
Create `main/ec_config.h` if needed. The default preset is `Qwen`:

```c
#define EC_USE_QWEN 1
#define EC_USE_DEEPSEEK 0
#define EC_USE_DOUBAO 0
#define EC_USE_KIMI 0
#define EC_USE_HUNYUAN 0
#define EC_SECRET_SEARCH_KEY "YOUR_TAVILY_API_KEY"
#define EC_LLM_API_KEY "YOUR_DASHSCOPE_API_KEY"
#define EC_LLM_MODEL "qwen-plus"
#define EC_SECRET_FEISHU_APP_ID "YOUR_FEISHU_APP_ID"
#define EC_SECRET_FEISHU_APP_SECRET "YOUR_FEISHU_APP_SECRET"
```

Default LLM URL (DashScope OpenAI-compatible):
Under the default preset, the effective LLM settings are:

```c
#define EC_LLM_API_URL "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions"
#define EC_LLM_PROVIDER_NAME "openai"
#define EC_LLM_API_URL "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions"
#define EC_LLM_MODEL "qwen-plus"
```

If you skip Tavily or Feishu for now, you only need the Qwen-related keys.
Built-in OpenAI-compatible LLM presets now include:

- `Qwen`: DashScope + `qwen-plus`
- `DeepSeek`: `https://api.deepseek.com/v1/chat/completions` + `deepseek-chat`
- `Doubao`: `https://operator.las.cn-beijing.volces.com/api/v1/chat/completions` + `doubao-seed-1-6-251015`
- `KiMi`: `https://api.moonshot.cn/v1/chat/completions` + `kimi-k2.5`
- `Hunyuan`: `https://api.hunyuan.cloud.tencent.com/v1/chat/completions` + `hunyuan-turbos-latest`

If you want to switch to DeepSeek, use:

```c
#define EC_USE_QWEN 0
#define EC_USE_DEEPSEEK 1
#define EC_LLM_API_KEY "YOUR_DEEPSEEK_API_KEY"
```

Notes:

- Explicit `EC_LLM_PROVIDER_NAME / EC_LLM_API_URL / EC_LLM_MODEL` overrides take precedence over preset-derived defaults.
- Only one `EC_USE_*` LLM preset can be `1` at a time.
- The Doubao preset defaults to the Volcengine Beijing OpenAI-compatible endpoint; override `EC_LLM_API_URL` or `EC_DOUBAO_LLM_API_URL` if your region or endpoint differs.
- If you skip Tavily or Feishu for now, you only need the keys for the active LLM preset.

Optional channel toggles:

Expand Down Expand Up @@ -597,9 +624,11 @@ esp_err_t ec_channel_demo(void)

Currently used:

- `EC_USE_QWEN=1`
- Other built-in OpenAI-compatible presets: `EC_USE_DEEPSEEK / EC_USE_DOUBAO / EC_USE_KIMI / EC_USE_HUNYUAN`
- `EC_LLM_PROVIDER_NAME` (default: `openai`)
- DashScope OpenAI-compatible API
- **qwen-plus**
- Qwen preset defaults to DashScope OpenAI-compatible + **qwen-plus**
- The other presets reuse the same OpenAI-compatible provider

To add another provider:

Expand All @@ -610,7 +639,7 @@ To add another provider:
5. Add one branch in `ec_llm_init_default()` (`components/embed_claw/llm/ec_llm.c`) to map provider name to getter
6. Set `EC_LLM_PROVIDER_NAME` in `main/ec_config.h` (and set matching URL/model)

The current runtime path is OpenAI-compatible providers (OpenAI, DeepSeek, Moonshot, Qwen, etc.). Other provider families are not wired yet.
The current runtime path is OpenAI-compatible providers (OpenAI, DeepSeek, Moonshot/KiMi, Qwen, Doubao, Hunyuan, etc.). Other provider families are not wired yet.

## Possible next steps

Expand All @@ -624,7 +653,7 @@ For open-source distribution, repo defaults keep secret fields empty. Put real k

Before running, set:

- DashScope / Qwen API key
- API key for the active LLM preset
- `EC_LLM_PROVIDER_NAME` (default is `openai`)
- Tavily API key
- Feishu App ID and App Secret
Expand Down
47 changes: 38 additions & 9 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,50 @@ EmbedClaw 使用 SPIFFS 保存人格、用户信息、会话与记忆:
- [`components/embed_claw/ec_config_internal.h`](components/embed_claw/ec_config_internal.h) 提供仓库内默认值和空白密钥占位。
- 如需放项目自己的参数或敏感信息,请新建本地 [`main/ec_config.h`](main/ec_config.h),只定义你要覆盖的宏。构建系统会把这个头自动注入 `embed_claw`,因此不必把密钥写回共享组件目录。

如不存在可先创建 `main/ec_config.h`,你至少需要填写
如不存在可先创建 `main/ec_config.h`。默认预设是 `Qwen`

```c
#define EC_USE_QWEN 1
#define EC_USE_DEEPSEEK 0
#define EC_USE_DOUBAO 0
#define EC_USE_KIMI 0
#define EC_USE_HUNYUAN 0
#define EC_SECRET_SEARCH_KEY "YOUR_TAVILY_API_KEY"
#define EC_LLM_API_KEY "YOUR_DASHSCOPE_API_KEY"
#define EC_LLM_MODEL "qwen-plus"
#define EC_SECRET_FEISHU_APP_ID "YOUR_FEISHU_APP_ID"
#define EC_SECRET_FEISHU_APP_SECRET "YOUR_FEISHU_APP_SECRET"
```

默认的 LLM 地址已经指向 DashScope OpenAI-Compatible 接口
在默认预设下,LLM 会自动落到

```c
#define EC_LLM_API_URL "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions"
#define EC_LLM_PROVIDER_NAME "openai"
#define EC_LLM_API_URL "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions"
#define EC_LLM_MODEL "qwen-plus"
```

如果你暂时不用 Tavily 或飞书,可以只配置 Qwen 所需参数。
当前内置的 OpenAI-Compatible LLM 预设有:

- `Qwen`:DashScope + `qwen-plus`
- `DeepSeek`:`https://api.deepseek.com/v1/chat/completions` + `deepseek-chat`
- `Doubao`:`https://operator.las.cn-beijing.volces.com/api/v1/chat/completions` + `doubao-seed-1-6-251015`
- `KiMi`:`https://api.moonshot.cn/v1/chat/completions` + `kimi-k2.5`
- `Hunyuan`:`https://api.hunyuan.cloud.tencent.com/v1/chat/completions` + `hunyuan-turbos-latest`

如果你想切到 DeepSeek,可在本地配置里改成:

```c
#define EC_USE_QWEN 0
#define EC_USE_DEEPSEEK 1
#define EC_LLM_API_KEY "YOUR_DEEPSEEK_API_KEY"
```

说明:

- 显式定义的 `EC_LLM_PROVIDER_NAME / EC_LLM_API_URL / EC_LLM_MODEL` 优先级高于预设宏。
- 同一时刻只能有一个 `EC_USE_*` LLM 预设为 `1`。
- Doubao 预设默认使用火山引擎北京区 OpenAI-Compatible endpoint;如果你的地域或接入点不同,请显式覆盖 `EC_LLM_API_URL` 或 `EC_DOUBAO_LLM_API_URL`。
- 如果你暂时不用 Tavily 或飞书,可以只配置当前 LLM 预设所需参数。

可选的 channel 开关示例:

Expand Down Expand Up @@ -628,9 +655,11 @@ esp_err_t ec_channel_demo(void)

当前默认实际启用的是:

- `EC_USE_QWEN=1`
- 其它内置 OpenAI-Compatible 预设:`EC_USE_DEEPSEEK / EC_USE_DOUBAO / EC_USE_KIMI / EC_USE_HUNYUAN`
- `EC_LLM_PROVIDER_NAME`(默认:`openai`)
- DashScope OpenAI-Compatible 接口
- `qwen-plus`
- Qwen 预设默认落到 DashScope OpenAI-Compatible + `qwen-plus`
- 其它预设同样复用这套 OpenAI-Compatible provider

但抽象层已经拆出来了,扩展新 Provider 的路径很清晰:

Expand All @@ -644,7 +673,7 @@ esp_err_t ec_channel_demo(void)
补充说明:

- 但现阶段真正跑通的是 OpenAI-Compatible 路径
- 所以如果你要接 OpenAI、DeepSeek、Moonshot、通义千问兼容接口,成本会最低
- 所以如果你要接 OpenAI、DeepSeek、Moonshot/KiMi、通义千问、豆包或混元的兼容接口,成本会最低

## 适合继续演进的方向

Expand All @@ -658,7 +687,7 @@ esp_err_t ec_channel_demo(void)

在正式运行前,请先填写:

- DashScope / Qwen API Key
- 当前预设对应的 LLM API Key
- `EC_LLM_PROVIDER_NAME`(默认是 `openai`)
- Tavily API Key
- Feishu App ID / Secret
Expand Down
10 changes: 4 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
## LLM integration

- [x] Qwen
- [ ] XiaoZhi
- [ ] DeepSeek
- [ ] Doubao (ByteDance)
- [ ] KiMi (Moonshot)
- [ ] Hunyuan (Tencent)
- [x] DeepSeek (OpenAI-compatible preset)
- [x] Doubao (ByteDance, OpenAI-compatible preset)
- [x] KiMi (Moonshot, OpenAI-compatible preset)
- [x] Hunyuan (Tencent, OpenAI-compatible preset)

## Tools integration

Expand Down Expand Up @@ -35,4 +34,3 @@
- [ ] Support more filesystems (beyond SPIFFS)
- [ ] SD card support
- [ ] Support ESP32C3

9 changes: 4 additions & 5 deletions TODO_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
## LLM对接

- [x] 对接qwen
- [ ] 对接小智
- [ ] 对接deepseek
- [ ] 对接豆包
- [ ] 对接KiMi
- [ ] 对接混元
- [x] 对接deepseek(OpenAI-Compatible 预设)
- [x] 对接豆包(OpenAI-Compatible 预设)
- [x] 对接KiMi(OpenAI-Compatible 预设)
- [x] 对接混元(OpenAI-Compatible 预设)

## Tools对接

Expand Down
99 changes: 96 additions & 3 deletions components/embed_claw/ec_config_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,113 @@ extern "C" {
/*
* [embed_claw/llm]
* 如何配置:
* - 覆盖 provider 名称、API 地址、密钥、模型和响应缓冲参数。
* - 可通过预设宏快速切换 Qwen / DeepSeek / Doubao / KiMi / Hunyuan,
* 也可直接覆盖 provider 名称、
* API 地址、密钥、模型和响应缓冲参数。
* 作用:
* - 影响 LLM provider 选择、接入目标、推理容量、内存占用和工具调用解析上限。
* 优先级:
* - 显式定义的 EC_LLM_PROVIDER_NAME / EC_LLM_API_URL / EC_LLM_MODEL
* 优先于预设宏推导值。
*/
#ifndef EC_USE_DEEPSEEK
#define EC_USE_DEEPSEEK 0
#endif

#ifndef EC_USE_DOUBAO
#define EC_USE_DOUBAO 0
#endif

#ifndef EC_USE_KIMI
#define EC_USE_KIMI 0
#endif

#ifndef EC_USE_HUNYUAN
#define EC_USE_HUNYUAN 0
#endif

#ifndef EC_USE_QWEN
#if EC_USE_DEEPSEEK || EC_USE_DOUBAO || EC_USE_KIMI || EC_USE_HUNYUAN
#define EC_USE_QWEN 0
#else
#define EC_USE_QWEN 1
#endif
#endif

#if (EC_USE_QWEN + EC_USE_DEEPSEEK + EC_USE_DOUBAO + EC_USE_KIMI + EC_USE_HUNYUAN) > 1
#error "Only one EC_USE_* LLM preset can be 1 at a time"
#endif

#ifndef EC_QWEN_LLM_API_URL
#define EC_QWEN_LLM_API_URL "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions"
#endif

#ifndef EC_QWEN_LLM_MODEL
#define EC_QWEN_LLM_MODEL "qwen-plus"
#endif

#ifndef EC_DEEPSEEK_LLM_API_URL
#define EC_DEEPSEEK_LLM_API_URL "https://api.deepseek.com/v1/chat/completions"
#endif

#ifndef EC_DEEPSEEK_LLM_MODEL
#define EC_DEEPSEEK_LLM_MODEL "deepseek-chat"
#endif

#ifndef EC_DOUBAO_LLM_API_URL
#define EC_DOUBAO_LLM_API_URL "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
#endif

#ifndef EC_DOUBAO_LLM_MODEL
#define EC_DOUBAO_LLM_MODEL "doubao-seed-2-0-pro-260215"
#endif

#ifndef EC_KIMI_LLM_API_URL
#define EC_KIMI_LLM_API_URL "https://api.moonshot.cn/v1/chat/completions"
#endif

#ifndef EC_KIMI_LLM_MODEL
#define EC_KIMI_LLM_MODEL "kimi-k2.5"
#endif

#ifndef EC_HUNYUAN_LLM_API_URL
#define EC_HUNYUAN_LLM_API_URL "https://api.hunyuan.cloud.tencent.com/v1/chat/completions"
#endif

#ifndef EC_HUNYUAN_LLM_MODEL
#define EC_HUNYUAN_LLM_MODEL "hunyuan-turbos-latest"
#endif

#ifndef EC_LLM_API_URL
#define EC_LLM_API_URL "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions"
#if EC_USE_DEEPSEEK
#define EC_LLM_API_URL EC_DEEPSEEK_LLM_API_URL
#elif EC_USE_DOUBAO
#define EC_LLM_API_URL EC_DOUBAO_LLM_API_URL
#elif EC_USE_KIMI
#define EC_LLM_API_URL EC_KIMI_LLM_API_URL
#elif EC_USE_HUNYUAN
#define EC_LLM_API_URL EC_HUNYUAN_LLM_API_URL
#else
#define EC_LLM_API_URL EC_QWEN_LLM_API_URL
#endif
#endif

#ifndef EC_LLM_API_KEY
#define EC_LLM_API_KEY ""
#endif

#ifndef EC_LLM_MODEL
#define EC_LLM_MODEL "qwen-plus"
#if EC_USE_DEEPSEEK
#define EC_LLM_MODEL EC_DEEPSEEK_LLM_MODEL
#elif EC_USE_DOUBAO
#define EC_LLM_MODEL EC_DOUBAO_LLM_MODEL
#elif EC_USE_KIMI
#define EC_LLM_MODEL EC_KIMI_LLM_MODEL
#elif EC_USE_HUNYUAN
#define EC_LLM_MODEL EC_HUNYUAN_LLM_MODEL
#else
#define EC_LLM_MODEL EC_QWEN_LLM_MODEL
#endif
#endif

#ifndef EC_LLM_PROVIDER_NAME
Expand Down
Loading