From 8381299676bc4134eafad1b940bf22afcd8db46a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?TheHat=E2=84=A2?=
<236301863+masterpatrickpl-coder@users.noreply.github.com>
Date: Tue, 14 Apr 2026 14:54:49 +0800
Subject: [PATCH 1/2] Big Change
typo?
---
src/models/glhf.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/models/glhf.js b/src/models/glhf.js
index b237c8d74..5256a33af 100644
--- a/src/models/glhf.js
+++ b/src/models/glhf.js
@@ -5,7 +5,7 @@ export class GLHF {
static prefix = 'glhf';
constructor(model_name, url) {
this.model_name = model_name;
- const apiKey = getKey('GHLF_API_KEY');
+ const apiKey = getKey('GLHF_API_KEY');
if (!apiKey) {
throw new Error('API key not found. Please check keys.json and ensure GHLF_API_KEY is defined.');
}
From 4f07e90d5189ef8f6ec9d55131d665d6d3b66ecc Mon Sep 17 00:00:00 2001
From: riqvip <95001376+riqvip@users.noreply.github.com>
Date: Wed, 15 Apr 2026 11:38:41 -0700
Subject: [PATCH 2/2] Remove GLHF
---
README.md | 1 -
keys.example.json | 1 -
src/models/glhf.js | 71 ----------------------------------------------
3 files changed, 73 deletions(-)
delete mode 100644 src/models/glhf.js
diff --git a/README.md b/README.md
index bcdceef70..4e7f84401 100644
--- a/README.md
+++ b/README.md
@@ -71,7 +71,6 @@ You can configure the agent's name, model, and prompts in their profile like `an
| `huggingface` | `HUGGINGFACE_API_KEY` | [docs](https://huggingface.co/models) |
| `novita` | `NOVITA_API_KEY` | [docs](https://novita.ai/model-api/product/llm-api?utm_source=github_mindcraft&utm_medium=github_readme&utm_campaign=link) |
| `openrouter` | `OPENROUTER_API_KEY` | [docs](https://openrouter.ai/models) |
-| `glhf` | `GHLF_API_KEY` | [docs](https://glhf.chat/user-settings/api) |
| `hyperbolic` | `HYPERBOLIC_API_KEY` | [docs](https://docs.hyperbolic.xyz/docs/getting-started) |
| `vllm` | n/a | n/a |
| `cerebras` | `CEREBRAS_API_KEY` | [docs](https://inference-docs.cerebras.ai/introduction) |
diff --git a/keys.example.json b/keys.example.json
index fe6812888..bcdfd9442 100644
--- a/keys.example.json
+++ b/keys.example.json
@@ -10,7 +10,6 @@
"XAI_API_KEY": "",
"MISTRAL_API_KEY": "",
"DEEPSEEK_API_KEY": "",
- "GHLF_API_KEY": "",
"HYPERBOLIC_API_KEY": "",
"NOVITA_API_KEY": "",
"OPENROUTER_API_KEY": "",
diff --git a/src/models/glhf.js b/src/models/glhf.js
deleted file mode 100644
index 5256a33af..000000000
--- a/src/models/glhf.js
+++ /dev/null
@@ -1,71 +0,0 @@
-import OpenAIApi from 'openai';
-import { getKey } from '../utils/keys.js';
-
-export class GLHF {
- static prefix = 'glhf';
- constructor(model_name, url) {
- this.model_name = model_name;
- const apiKey = getKey('GLHF_API_KEY');
- if (!apiKey) {
- throw new Error('API key not found. Please check keys.json and ensure GHLF_API_KEY is defined.');
- }
- this.openai = new OpenAIApi({
- apiKey,
- baseURL: url || "https://glhf.chat/api/openai/v1"
- });
- }
-
- async sendRequest(turns, systemMessage, stop_seq = '***') {
- // Construct the message array for the API request.
- let messages = [{ role: 'system', content: systemMessage }].concat(turns);
- const pack = {
- model: this.model_name || "hf:meta-llama/Llama-3.1-405B-Instruct",
- messages,
- stop: [stop_seq]
- };
-
- const maxAttempts = 5;
- let attempt = 0;
- let finalRes = null;
-
- while (attempt < maxAttempts) {
- attempt++;
- console.log(`Awaiting glhf.chat API response... (attempt: ${attempt})`);
- try {
- let completion = await this.openai.chat.completions.create(pack);
- if (completion.choices[0].finish_reason === 'length') {
- throw new Error('Context length exceeded');
- }
- let res = completion.choices[0].message.content;
- // If there's an open tag without a corresponding , retry.
- if (res.includes("") && !res.includes("")) {
- console.warn("Partial block detected. Re-generating...");
- continue;
- }
- // If there's a closing tag but no opening , prepend one.
- if (res.includes("") && !res.includes("")) {
- res = "" + res;
- }
- finalRes = res.replace(/<\|separator\|>/g, '*no response*');
- break; // Valid response obtained.
- } 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);
- } else {
- console.error(err);
- finalRes = 'My brain disconnected, try again.';
- break;
- }
- }
- }
- if (finalRes === null) {
- finalRes = "I thought too hard, sorry, try again";
- }
- return finalRes;
- }
-
- async embed(text) {
- throw new Error('Embeddings are not supported by glhf.');
- }
-}