netheriteai-code 0.3.3 → 0.3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "netheriteai-code",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "NetheriteAI:Code by hurdacu. High-performance coding assistant.",
5
5
  "author": "hurdacu",
6
6
  "type": "module",
package/src/cli.js CHANGED
@@ -11,7 +11,7 @@ import { printTable, resolveWorkspaceRoot } from "./utils.js";
11
11
 
12
12
  const execFileAsync = promisify(execFile);
13
13
 
14
- const VERSION = "0.3.3";
14
+ const VERSION = "0.3.4";
15
15
 
16
16
  async function handleAutoUpdate() {
17
17
  try {
package/src/ollama.js CHANGED
@@ -7,23 +7,33 @@ const PREFERRED_DEFAULT_MODELS = [
7
7
  "glm-5:cloud",
8
8
  ];
9
9
 
10
- async function request(pathname, body, signal) {
11
- try {
12
- const response = await fetch(`${BASE_URL}${pathname}`, {
13
- method: "POST",
14
- headers: { "content-type": "application/json" },
15
- body: JSON.stringify(body),
16
- signal,
17
- });
10
+ async function request(pathname, body, signal, retries = 3) {
11
+ for (let i = 0; i < retries; i++) {
12
+ try {
13
+ const response = await fetch(`${BASE_URL}${pathname}`, {
14
+ method: "POST",
15
+ headers: { "content-type": "application/json" },
16
+ body: JSON.stringify(body),
17
+ signal,
18
+ });
19
+
20
+ if (response.ok) return response;
21
+
22
+ // If 500 error, wait and retry
23
+ if (response.status === 500 && i < retries - 1) {
24
+ await new Promise(r => setTimeout(r, 1000));
25
+ continue;
26
+ }
18
27
 
19
- if (!response.ok) {
28
+ throw new Error("Server down");
29
+ } catch (err) {
30
+ if (err.name === "AbortError") throw err;
31
+ if (i < retries - 1) {
32
+ await new Promise(r => setTimeout(r, 1000));
33
+ continue;
34
+ }
20
35
  throw new Error("Server down");
21
36
  }
22
-
23
- return response;
24
- } catch (err) {
25
- if (err.name === "AbortError") throw err;
26
- throw new Error("Server down");
27
37
  }
28
38
  }
29
39