diff --git a/README.md b/README.md index 4d2fe08..fa2b798 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ Do not connect this bot to public servers with coding enabled. This project allo - [Minecraft Java Edition](https://www.minecraft.net/en-us/store/minecraft-java-bedrock-edition-pc) (up to v1.21.1, recommend v1.21.1) - [Node.js Installed](https://nodejs.org/) (at least v18) -- One of these: [OpenAI API Key](https://openai.com/blog/openai-api) | [Gemini API Key](https://aistudio.google.com/app/apikey) | [Anthropic API Key](https://docs.anthropic.com/claude/docs/getting-access-to-claude) | [Replicate API Key](https://replicate.com/) | [Hugging Face API Key](https://huggingface.co/) | [Groq API Key](https://console.groq.com/keys) | [Ollama Installed](https://ollama.com/download). | [Mistral API Key](https://docs.mistral.ai/getting-started/models/models_overview/) | [Qwen API Key [Intl.]](https://www.alibabacloud.com/help/en/model-studio/developer-reference/get-api-key)/[[cn]](https://help.aliyun.com/zh/model-studio/getting-started/first-api-call-to-qwen?) | [Novita AI API Key](https://novita.ai/settings?utm_source=github_mindcraft&utm_medium=github_readme&utm_campaign=link#key-management) | +- One of these: [OpenAI API Key](https://openai.com/blog/openai-api) | [Gemini API Key](https://aistudio.google.com/app/apikey) | [Anthropic API Key](https://docs.anthropic.com/claude/docs/getting-access-to-claude) | [Replicate API Key](https://replicate.com/) | [Hugging Face API Key](https://huggingface.co/) | [Groq API Key](https://console.groq.com/keys) | [Ollama Installed](https://ollama.com/download). | [Mistral API Key](https://docs.mistral.ai/getting-started/models/models_overview/) | [Qwen API Key [Intl.]](https://www.alibabacloud.com/help/en/model-studio/developer-reference/get-api-key)/[[cn]](https://help.aliyun.com/zh/model-studio/getting-started/first-api-call-to-qwen?) | [Novita AI API Key](https://novita.ai/settings?utm_source=github_mindcraft&utm_medium=github_readme&utm_campaign=link#key-management) | [Cerebras API Key](https://cloud.cerebras.ai) + ## Install and Run @@ -64,6 +65,7 @@ You can configure the agent's name, model, and prompts in their profile like `an | `glhf.chat` | `GHLF_API_KEY` | `glhf/hf:meta-llama/Llama-3.1-405B-Instruct` | [docs](https://glhf.chat/user-settings/api) | | `hyperbolic` | `HYPERBOLIC_API_KEY` | `hyperbolic/deepseek-ai/DeepSeek-V3` | [docs](https://docs.hyperbolic.xyz/docs/getting-started) | | `vllm` | n/a | `vllm/llama3` | n/a | +| `cerebras` | `CEREBRAS_API_KEY` | `cerebras/llama-3.3-70b` | [docs](https://inference-docs.cerebras.ai/introduction) | If you use Ollama, to install the models used by default (generation and embedding), execute the following terminal command: `ollama pull llama3.1 && ollama pull nomic-embed-text` diff --git a/keys.example.json b/keys.example.json index 99286c5..52204ae 100644 --- a/keys.example.json +++ b/keys.example.json @@ -13,5 +13,6 @@ "GHLF_API_KEY": "", "HYPERBOLIC_API_KEY": "", "NOVITA_API_KEY": "", - "OPENROUTER_API_KEY": "" + "OPENROUTER_API_KEY": "", + "CEREBRAS_API_KEY": "" } diff --git a/package.json b/package.json index 5fb95d7..106a75c 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "type": "module", "dependencies": { "@anthropic-ai/sdk": "^0.17.1", + "@cerebras/cerebras_cloud_sdk": "^1.46.0", "@google/generative-ai": "^0.2.1", "@huggingface/inference": "^2.8.1", "@mistralai/mistralai": "^1.1.0", diff --git a/profiles/claude.json b/profiles/claude.json index d4ce4cc..27f610d 100644 --- a/profiles/claude.json +++ b/profiles/claude.json @@ -1,7 +1,7 @@ { "name": "claude", - "model": "claude-3-5-sonnet-latest", + "model": "claude-4-sonnet-latest", "embedding": "openai" } \ No newline at end of file diff --git a/profiles/claude_thinker.json b/profiles/claude_thinker.json index fdddb59..64e3fb4 100644 --- a/profiles/claude_thinker.json +++ b/profiles/claude_thinker.json @@ -2,7 +2,7 @@ "name": "claude_thinker", "model": { - "model": "claude-3-7-sonnet-latest", + "model": "claude-4-sonnet-latest", "params": { "thinking": { "type": "enabled", diff --git a/profiles/gemini.json b/profiles/gemini.json index 8a91387..0e388c7 100644 --- a/profiles/gemini.json +++ b/profiles/gemini.json @@ -1,7 +1,7 @@ { "name": "gemini", - "model": "gemini-2.0-flash", + "model": "gemini-2.5-flash", "cooldown": 5000 } diff --git a/profiles/grok.json b/profiles/grok.json index eeb3a38..eda1aaa 100644 --- a/profiles/grok.json +++ b/profiles/grok.json @@ -1,7 +1,7 @@ { "name": "Grok", - "model": "grok-beta", + "model": "grok-3-mini-latest", "embedding": "openai" } \ No newline at end of file diff --git a/src/models/cerebras.js b/src/models/cerebras.js new file mode 100644 index 0000000..be902a6 --- /dev/null +++ b/src/models/cerebras.js @@ -0,0 +1,61 @@ +import CerebrasSDK from '@cerebras/cerebras_cloud_sdk'; +import { strictFormat } from '../utils/text.js'; +import { getKey } from '../utils/keys.js'; + +export class Cerebras { + static prefix = 'cerebras'; + constructor(model_name, url, params) { + this.model_name = model_name; + this.url = url; + this.params = params; + + // Initialize client with API key + this.client = new CerebrasSDK({ apiKey: getKey('CEREBRAS_API_KEY') }); + } + + async sendRequest(turns, systemMessage, stop_seq = '***') { + // Format messages array + const messages = strictFormat(turns); + messages.unshift({ role: 'system', content: systemMessage }); + + const pack = { + model: this.model_name || 'gpt-oss-120b', + messages, + stream: false, + ...(this.params || {}), + }; + + let res; + try { + const completion = await this.client.chat.completions.create(pack); + // OpenAI-compatible shape + res = completion.choices?.[0]?.message?.content || ''; + } catch (err) { + console.error('Cerebras API error:', err); + res = 'My brain disconnected, try again.'; + } + return res; + } + + async sendVisionRequest(messages, systemMessage, imageBuffer) { + const imageMessages = [...messages]; + imageMessages.push({ + role: "user", + content: [ + { type: "text", text: systemMessage }, + { + type: "image_url", + image_url: { + url: `data:image/jpeg;base64,${imageBuffer.toString('base64')}` + } + } + ] + }); + + return this.sendRequest(imageMessages, systemMessage); + } + + async embed(text) { + throw new Error('Embeddings are not supported by Cerebras.'); + } +} diff --git a/src/models/gemini.js b/src/models/gemini.js index 75a20e0..ba24072 100644 --- a/src/models/gemini.js +++ b/src/models/gemini.js @@ -37,7 +37,7 @@ export class Gemini { async sendRequest(turns, systemMessage) { let model; const modelConfig = { - model: this.model_name || "gemini-1.5-flash", + model: this.model_name || "gemini-2.5-flash", // systemInstruction does not work bc google is trash }; if (this.url) { diff --git a/src/models/grok.js b/src/models/grok.js index 0753f10..40c63ce 100644 --- a/src/models/grok.js +++ b/src/models/grok.js @@ -3,7 +3,7 @@ import { getKey } from '../utils/keys.js'; // xAI doesn't supply a SDK for their models, but fully supports OpenAI and Anthropic SDKs export class Grok { - static prefix = 'grok'; + static prefix = 'xai'; constructor(model_name, url, params) { this.model_name = model_name; this.url = url; @@ -20,13 +20,12 @@ export class Grok { this.openai = new OpenAIApi(config); } - async sendRequest(turns, systemMessage, stop_seq='***') { + async sendRequest(turns, systemMessage) { let messages = [{'role': 'system', 'content': systemMessage}].concat(turns); const pack = { - model: this.model_name || "grok-beta", + model: this.model_name || "grok-3-mini-latest", messages, - stop: [stop_seq], ...(this.params || {}) }; @@ -43,7 +42,7 @@ export class Grok { catch (err) { if ((err.message == 'Context length exceeded' || err.code == 'context_length_exceeded') && turns.length > 1) { console.log('Context length exceeded, trying again with shorter context.'); - return await this.sendRequest(turns.slice(1), systemMessage, stop_seq); + return await this.sendRequest(turns.slice(1), systemMessage); } else if (err.message.includes('The model expects a single `text` element per message.')) { console.log(err); res = 'Vision is only supported by certain models.'; diff --git a/src/models/groq.js b/src/models/groq.js index 9da88c7..85a913e 100644 --- a/src/models/groq.js +++ b/src/models/groq.js @@ -50,7 +50,7 @@ export class GroqCloudAPI { let completion = await this.groq.chat.completions.create({ "messages": messages, - "model": this.model_name || "llama-3.3-70b-versatile", + "model": this.model_name || "qwen/qwen3-32b", "stream": false, "stop": stop_seq, ...(this.params || {}) diff --git a/src/models/novita.js b/src/models/novita.js index 46140f0..18e1fc4 100644 --- a/src/models/novita.js +++ b/src/models/novita.js @@ -26,7 +26,7 @@ export class Novita { messages = strictFormat(messages); const pack = { - model: this.model_name || "meta-llama/llama-3.1-70b-instruct", + model: this.model_name || "meta-llama/llama-4-scout-17b-16e-instruct", messages, stop: [stop_seq], ...(this.params || {})