wolverine-ai 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/brain/embedder.js +23 -9
- package/src/core/ai-client.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wolverine-ai",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Self-healing Node.js server framework powered by AI. Catches crashes, diagnoses errors, generates fixes, verifies, and restarts — automatically.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
package/src/brain/embedder.js
CHANGED
|
@@ -43,14 +43,21 @@ async function embed(text) {
|
|
|
43
43
|
|
|
44
44
|
const model = getEmbeddingModel();
|
|
45
45
|
const provider = detectProvider(model);
|
|
46
|
-
// wolverine-embedding-1 routes through billing proxy, others go direct
|
|
47
46
|
const client = provider === "wolverine" ? getClient("wolverine") : getClient("openai");
|
|
48
47
|
|
|
49
48
|
const startMs = Date.now();
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
input: text
|
|
53
|
-
})
|
|
49
|
+
let response;
|
|
50
|
+
try {
|
|
51
|
+
response = await client.embeddings.create({ model, input: text });
|
|
52
|
+
} catch (err) {
|
|
53
|
+
// If wolverine proxy is down (startup, crash loop), fall back to OpenAI direct
|
|
54
|
+
if (provider === "wolverine" && /ECONNREFUSED|ECONNRESET|ETIMEDOUT|fetch failed|Connection error/i.test(err.message || "")) {
|
|
55
|
+
const directClient = getClient("openai");
|
|
56
|
+
response = await directClient.embeddings.create({ model: "text-embedding-3-small", input: text });
|
|
57
|
+
} else {
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
54
61
|
|
|
55
62
|
const embedding = response.data[0].embedding;
|
|
56
63
|
_trackEmbedding(model, response.usage, Date.now() - startMs, true);
|
|
@@ -87,10 +94,17 @@ async function embedBatch(texts) {
|
|
|
87
94
|
const client = provider === "wolverine" ? getClient("wolverine") : getClient("openai");
|
|
88
95
|
|
|
89
96
|
const startMs = Date.now();
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
input: uncached
|
|
93
|
-
})
|
|
97
|
+
let response;
|
|
98
|
+
try {
|
|
99
|
+
response = await client.embeddings.create({ model, input: uncached });
|
|
100
|
+
} catch (err) {
|
|
101
|
+
if (provider === "wolverine" && /ECONNREFUSED|ECONNRESET|ETIMEDOUT|fetch failed|Connection error/i.test(err.message || "")) {
|
|
102
|
+
const directClient = getClient("openai");
|
|
103
|
+
response = await directClient.embeddings.create({ model: "text-embedding-3-small", input: uncached });
|
|
104
|
+
} else {
|
|
105
|
+
throw err;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
94
108
|
_trackEmbedding(model, response.usage, Date.now() - startMs, true);
|
|
95
109
|
|
|
96
110
|
// Sort by index to maintain order
|
package/src/core/ai-client.js
CHANGED
|
@@ -232,7 +232,7 @@ async function aiCall({ model, systemPrompt, userPrompt, maxTokens = 2048, tools
|
|
|
232
232
|
result = await _chatCall(_getWolverineClient(), { model, systemPrompt, userPrompt, maxTokens, tools, toolChoice });
|
|
233
233
|
} catch (proxyErr) {
|
|
234
234
|
// If billing proxy is down (server crashing), fall back to direct GPU
|
|
235
|
-
const isConnErr = /ECONNREFUSED|ECONNRESET|ETIMEDOUT|fetch failed/i.test(proxyErr.message || "");
|
|
235
|
+
const isConnErr = /ECONNREFUSED|ECONNRESET|ETIMEDOUT|fetch failed|Connection error/i.test(proxyErr.message || "");
|
|
236
236
|
const directClient = _getWolverineDirectClient();
|
|
237
237
|
if (isConnErr && directClient) {
|
|
238
238
|
console.log(chalk.yellow(" ⚠️ Billing proxy down — using direct GPU (unbilled)"));
|
|
@@ -269,7 +269,7 @@ async function aiCallWithHistory({ model, messages, tools, maxTokens = 4096, cat
|
|
|
269
269
|
try {
|
|
270
270
|
result = await _chatCallWithHistory(_getWolverineClient(), { model, messages, tools, maxTokens });
|
|
271
271
|
} catch (proxyErr) {
|
|
272
|
-
const isConnErr = /ECONNREFUSED|ECONNRESET|ETIMEDOUT|fetch failed/i.test(proxyErr.message || "");
|
|
272
|
+
const isConnErr = /ECONNREFUSED|ECONNRESET|ETIMEDOUT|fetch failed|Connection error/i.test(proxyErr.message || "");
|
|
273
273
|
const directClient = _getWolverineDirectClient();
|
|
274
274
|
if (isConnErr && directClient) {
|
|
275
275
|
console.log(chalk.yellow(" ⚠️ Billing proxy down — using direct GPU (unbilled)"));
|