Skip to content

Commit 6992012

Browse files
committed
Merge PR #333: Add Cerebras provider
2 parents de4ef9a + 5772b92 commit 6992012

File tree

7 files changed

+49
-2
lines changed

7 files changed

+49
-2
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# ANTHROPIC_API_KEY=sk-ant-xxx
66
# OPENAI_API_KEY=sk-xxx
77
# GEMINI_API_KEY=xxx
8+
# CEREBRAS_API_KEY=xxx
89

910
# ── Chat Channel ──────────────────────────
1011
# TELEGRAM_BOT_TOKEN=123456:ABC...

README.ja.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,22 @@ HEARTBEAT_OK 応答 ユーザーが直接結果を受け取る
621621
- `PICOCLAW_HEARTBEAT_ENABLED=false` で無効化
622622
- `PICOCLAW_HEARTBEAT_INTERVAL=60` で間隔変更
623623

624+
### プロバイダー
625+
626+
> [!NOTE]
627+
> Groq は Whisper による無料の音声文字起こしを提供しています。設定すると、Telegram の音声メッセージが自動的に文字起こしされます。
628+
629+
| プロバイダー | 用途 | API キー取得先 |
630+
| --- | --- | --- |
631+
| `gemini` | LLM(Gemini 直接) | [aistudio.google.com](https://aistudio.google.com) |
632+
| `zhipu` | LLM(Zhipu 直接) | [bigmodel.cn](https://bigmodel.cn) |
633+
| `openrouter`(要テスト) | LLM(推奨、全モデルにアクセス可能) | [openrouter.ai](https://openrouter.ai) |
634+
| `anthropic`(要テスト) | LLM(Claude 直接) | [console.anthropic.com](https://console.anthropic.com) |
635+
| `openai`(要テスト) | LLM(GPT 直接) | [platform.openai.com](https://platform.openai.com) |
636+
| `deepseek`(要テスト) | LLM(DeepSeek 直接) | [platform.deepseek.com](https://platform.deepseek.com) |
637+
| `groq` | LLM + **音声文字起こし**(Whisper) | [console.groq.com](https://console.groq.com) |
638+
| `cerebras` | LLM(Cerebras 直接) | [cerebras.ai](https://cerebras.ai) |
639+
624640
### 基本設定
625641

626642
1. **設定ファイルの作成:**
@@ -774,3 +790,4 @@ Web 検索を有効にするには:
774790
| **Qwen** | 無料枠あり | 通義千問 (Qwen) |
775791
| **Brave Search** | 月 2000 クエリ | Web 検索機能 |
776792
| **Groq** | 無料枠あり | 高速推論(Llama, Mixtral) |
793+
| **Cerebras** | 無料枠あり | 高速推論(Llama, Qwen など) |

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ The subagent has access to tools (message, web_search, etc.) and can communicate
679679
| `deepseek(To be tested)` | LLM (DeepSeek direct) | [platform.deepseek.com](https://platform.deepseek.com) |
680680
| `qwen` | LLM (Qwen direct) | [dashscope.console.aliyun.com](https://dashscope.console.aliyun.com) |
681681
| `groq` | LLM + **Voice transcription** (Whisper) | [console.groq.com](https://console.groq.com) |
682+
| `cerebras` | LLM (Cerebras direct) | [cerebras.ai](https://cerebras.ai) |
682683

683684
<details>
684685
<summary><b>Zhipu</b></summary>
@@ -874,3 +875,4 @@ This happens when another instance of the bot is running. Make sure only one `pi
874875
| **Zhipu** | 200K tokens/month | Best for Chinese users |
875876
| **Brave Search** | 2000 queries/month | Web search functionality |
876877
| **Groq** | Free tier available | Fast inference (Llama, Mixtral) |
878+
| **Cerebras** | Free tier available | Fast inference (Llama, Qwen, etc.) |

README.zh.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ Agent 读取 HEARTBEAT.md
556556
| `deepseek(待测试)` | LLM (DeepSeek 直连) | [platform.deepseek.com](https://platform.deepseek.com) |
557557
| `qwen` | LLM (通义千问) | [dashscope.console.aliyun.com](https://dashscope.console.aliyun.com) |
558558
| `groq` | LLM + **语音转录** (Whisper) | [console.groq.com](https://console.groq.com) |
559+
| `cerebras` | LLM (Cerebras 直连) | [cerebras.ai](https://cerebras.ai) |
559560

560561
<details>
561562
<summary><b>智谱 (Zhipu) 配置示例</b></summary>
@@ -742,4 +743,5 @@ Discord: [https://discord.gg/V4sAZ9XWpN](https://discord.gg/V4sAZ9XWpN)
742743
| **OpenRouter** | 200K tokens/月 | 多模型聚合 (Claude, GPT-4 等) |
743744
| **智谱 (Zhipu)** | 200K tokens/月 | 最适合中国用户 |
744745
| **Brave Search** | 2000 次查询/月 | 网络搜索功能 |
745-
| **Groq** | 提供免费层级 | 极速推理 (Llama, Mixtral) |
746+
| **Groq** | 提供免费层级 | 极速推理 (Llama, Mixtral) |
747+
| **Cerebras** | 提供免费层级 | 极速推理 (Llama, Qwen 等) |

config/config.example.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@
117117
"ollama": {
118118
"api_key": "",
119119
"api_base": "http://localhost:11434/v1"
120+
},
121+
"cerebras": {
122+
"api_key": "",
123+
"api_base": ""
120124
}
121125
},
122126
"tools": {

pkg/config/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ type ProvidersConfig struct {
179179
Moonshot ProviderConfig `json:"moonshot"`
180180
ShengSuanYun ProviderConfig `json:"shengsuanyun"`
181181
DeepSeek ProviderConfig `json:"deepseek"`
182+
Cerebras ProviderConfig `json:"cerebras"`
182183
GitHubCopilot ProviderConfig `json:"github_copilot"`
183184
Qwen ProviderConfig `json:"qwen"`
184185
}
@@ -318,6 +319,7 @@ func DefaultConfig() *Config {
318319
Nvidia: ProviderConfig{},
319320
Moonshot: ProviderConfig{},
320321
ShengSuanYun: ProviderConfig{},
322+
Cerebras: ProviderConfig{},
321323
},
322324
Gateway: GatewayConfig{
323325
Host: "0.0.0.0",
@@ -427,6 +429,9 @@ func (c *Config) GetAPIKey() string {
427429
if c.Providers.ShengSuanYun.APIKey != "" {
428430
return c.Providers.ShengSuanYun.APIKey
429431
}
432+
if c.Providers.Cerebras.APIKey != "" {
433+
return c.Providers.Cerebras.APIKey
434+
}
430435
return ""
431436
}
432437

pkg/providers/http_provider.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (p *HTTPProvider) Chat(ctx context.Context, messages []Message, tools []Too
5656
// Strip provider prefix from model name (e.g., moonshot/kimi-k2.5 -> kimi-k2.5, groq/openai/gpt-oss-120b -> openai/gpt-oss-120b, ollama/qwen2.5:14b -> qwen2.5:14b)
5757
if idx := strings.Index(model, "/"); idx != -1 {
5858
prefix := model[:idx]
59-
if prefix == "moonshot" || prefix == "nvidia" || prefix == "groq" || prefix == "ollama" || prefix == "qwen" {
59+
if prefix == "moonshot" || prefix == "nvidia" || prefix == "groq" || prefix == "ollama" || prefix == "qwen" || prefix == "cerebras" {
6060
model = model[idx+1:]
6161
}
6262
}
@@ -313,6 +313,14 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) {
313313
workspace = "."
314314
}
315315
return NewCodexCliProvider(workspace), nil
316+
case "cerebras":
317+
if cfg.Providers.Cerebras.APIKey != "" {
318+
apiKey = cfg.Providers.Cerebras.APIKey
319+
apiBase = cfg.Providers.Cerebras.APIBase
320+
if apiBase == "" {
321+
apiBase = "https://api.cerebras.ai/v1"
322+
}
323+
}
316324
case "deepseek":
317325
if cfg.Providers.DeepSeek.APIKey != "" {
318326
apiKey = cfg.Providers.DeepSeek.APIKey
@@ -425,6 +433,14 @@ func CreateProvider(cfg *config.Config) (LLMProvider, error) {
425433
if apiBase == "" {
426434
apiBase = "https://integrate.api.nvidia.com/v1"
427435
}
436+
case (strings.Contains(lowerModel, "cerebras") || strings.HasPrefix(model, "cerebras/")) && cfg.Providers.Cerebras.APIKey != "":
437+
apiKey = cfg.Providers.Cerebras.APIKey
438+
apiBase = cfg.Providers.Cerebras.APIBase
439+
proxy = cfg.Providers.Cerebras.Proxy
440+
if apiBase == "" {
441+
apiBase = "https://api.cerebras.ai/v1"
442+
}
443+
428444
case (strings.Contains(lowerModel, "ollama") || strings.HasPrefix(model, "ollama/")) && cfg.Providers.Ollama.APIKey != "":
429445
fmt.Println("Ollama provider selected based on model name prefix")
430446
apiKey = cfg.Providers.Ollama.APIKey

0 commit comments

Comments
 (0)