@goodandready/dsh-ollama-cloud-provider 0.1.17 → 0.1.19
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/CHANGELOG.md +24 -0
- package/README.md +20 -4
- package/README.ru.md +4 -4
- package/README.zh.md +4 -4
- package/lib/client.js +141 -2
- package/lib/index.d.ts +39 -1
- package/lib/index.js +308 -30
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.19 — 2026-11-05
|
|
4
|
+
|
|
5
|
+
- Added configurable native generation defaults: temperature, top_k, top_p,
|
|
6
|
+
min_p, seed, repeat_penalty, repeat_last_n, num_ctx, keep_alive and stop.
|
|
7
|
+
Request options override config; Ollama-only fields are not sent to the
|
|
8
|
+
OpenAI transport. Added settings fields for all values.
|
|
9
|
+
- Normalized thinking ladders: boolean switches become off/high, level lists
|
|
10
|
+
are ordered and deduplicated, and known families get a default effort
|
|
11
|
+
(GLM-5.x/Kimi K3 max, Kimi K2/DeepSeek V4/MiniMax M3 high, GPT-OSS medium,
|
|
12
|
+
Nemotron low) only when that level is offered.
|
|
13
|
+
- Added generation/reasoning tests; 112/112 tests.
|
|
14
|
+
|
|
15
|
+
## 0.1.18 — 2026-11-05
|
|
16
|
+
|
|
17
|
+
- Added local/self-hosted Ollama mode: an explicit empty `apiKeyEnv` means no
|
|
18
|
+
authentication. Native and OpenAI requests omit `Authorization`, the key pool
|
|
19
|
+
returns a synthetic empty credential, and usage/balance requests are skipped.
|
|
20
|
+
- `/api/show` probing enriches local model discovery with context window,
|
|
21
|
+
vision, tools and thinking capabilities; successful probes are cached for five
|
|
22
|
+
minutes and cleared with the catalog cache or explicitly.
|
|
23
|
+
- Catalog discovery now falls back to `/api/tags` ids when `/v1/models` is
|
|
24
|
+
empty and adopts `/api/show` metadata for local endpoints.
|
|
25
|
+
- Added local-mode, probe-cache and no-auth tests; 109/109 tests.
|
|
26
|
+
|
|
3
27
|
## 0.1.17 — 2026-11-05
|
|
4
28
|
|
|
5
29
|
- Added Ollama web capabilities behind `ctx.web`: a search provider and a fetch
|
package/README.md
CHANGED
|
@@ -52,6 +52,22 @@ Select it in the profile:
|
|
|
52
52
|
fetchProvider: ollama-cloud
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
## Local Ollama
|
|
56
|
+
|
|
57
|
+
Set `apiKeyEnv` to an empty string and point `apiBase` at the local or
|
|
58
|
+
self-hosted Ollama server. No `Authorization` header is sent, and cloud
|
|
59
|
+
usage/balance reads are skipped.
|
|
60
|
+
|
|
61
|
+
```yaml
|
|
62
|
+
- id: llm-ollama-cloud
|
|
63
|
+
config:
|
|
64
|
+
apiKeyEnv: ''
|
|
65
|
+
apiBase: http://127.0.0.1:11434
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Local model discovery uses `/api/tags` and enriches each model through
|
|
69
|
+
`/api/show`; successful capability probes are cached for five minutes.
|
|
70
|
+
|
|
55
71
|
## Architecture
|
|
56
72
|
|
|
57
73
|
```mermaid
|
|
@@ -121,17 +137,17 @@ npm pack
|
|
|
121
137
|
Install the published package:
|
|
122
138
|
|
|
123
139
|
```bash
|
|
124
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
140
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.19
|
|
125
141
|
# DSH Desktop:
|
|
126
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
142
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.19
|
|
127
143
|
```
|
|
128
144
|
|
|
129
145
|
Or install the packed tarball into a profile:
|
|
130
146
|
|
|
131
147
|
```bash
|
|
132
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
148
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.19.tgz
|
|
133
149
|
# DSH Desktop:
|
|
134
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
150
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.19.tgz
|
|
135
151
|
```
|
|
136
152
|
|
|
137
153
|
Restart dsh (or DSH Desktop), then pick **Ollama Cloud** in the model picker.
|
package/README.ru.md
CHANGED
|
@@ -103,17 +103,17 @@ npm pack
|
|
|
103
103
|
Установка опубликованного пакета из npm:
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
106
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.19
|
|
107
107
|
# DSH Desktop:
|
|
108
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
108
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.19
|
|
109
109
|
```
|
|
110
110
|
|
|
111
111
|
Либо установка из упакованного tarball:
|
|
112
112
|
|
|
113
113
|
```bash
|
|
114
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
114
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.19.tgz
|
|
115
115
|
# DSH Desktop:
|
|
116
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
116
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.19.tgz
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
После установки перезапустите dsh (или DSH Desktop) и выберите **Ollama Cloud** в списке моделей.
|
package/README.zh.md
CHANGED
|
@@ -102,17 +102,17 @@ npm pack
|
|
|
102
102
|
从 npm 安装已发布版本:
|
|
103
103
|
|
|
104
104
|
```bash
|
|
105
|
-
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
105
|
+
dsh plugin --profile web add @goodandready/dsh-ollama-cloud-provider@0.1.19
|
|
106
106
|
# DSH 桌面端:
|
|
107
|
-
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.
|
|
107
|
+
dsh plugin --profile desktop add @goodandready/dsh-ollama-cloud-provider@0.1.19
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
或通过打包文件安装:
|
|
111
111
|
|
|
112
112
|
```bash
|
|
113
|
-
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
113
|
+
dsh plugin --profile web add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.19.tgz
|
|
114
114
|
# DSH 桌面端:
|
|
115
|
-
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.
|
|
115
|
+
dsh plugin --profile desktop add /absolute/path/to/goodandready-dsh-ollama-cloud-provider-0.1.19.tgz
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
安装完成后重启 dsh 或 DSH 桌面端,在模型列表中选择 **Ollama Cloud** 即可。
|
package/lib/client.js
CHANGED
|
@@ -122,6 +122,20 @@ window.__ModuleLoader__.load({
|
|
|
122
122
|
streamIdleTimeoutMs: "Stream idle timeout (ms)",
|
|
123
123
|
maxOutputTokens: "Output limit (0 = provider default)",
|
|
124
124
|
contextWindow: "Context window override",
|
|
125
|
+
generation: "Generation defaults",
|
|
126
|
+
generationHint: "Native Ollama defaults. Empty fields are not sent; request options still win.",
|
|
127
|
+
temperature: "Temperature",
|
|
128
|
+
topK: "Top K",
|
|
129
|
+
topP: "Top P",
|
|
130
|
+
minP: "Min P",
|
|
131
|
+
seed: "Seed",
|
|
132
|
+
repeatPenalty: "Repeat penalty",
|
|
133
|
+
repeatLastN: "Repeat last N",
|
|
134
|
+
numCtx: "num_ctx",
|
|
135
|
+
keepAlive: "Keep alive",
|
|
136
|
+
keepAliveHint: "Ollama keep_alive, for example 5m or -1.",
|
|
137
|
+
stop: "Stop sequences",
|
|
138
|
+
stopHint: "Comma-separated; sent as the native stop list.",
|
|
125
139
|
sidebar: "Sidebar",
|
|
126
140
|
serviceStatus: "Service status",
|
|
127
141
|
serviceStatusHint: "Checks the public Ollama Cloud tag endpoint without using your key or quota.",
|
|
@@ -295,6 +309,20 @@ window.__ModuleLoader__.load({
|
|
|
295
309
|
streamIdleTimeoutMs: "流空闲超时(毫秒)",
|
|
296
310
|
maxOutputTokens: "输出上限(0 = 提供方默认)",
|
|
297
311
|
contextWindow: "上下文窗口覆盖",
|
|
312
|
+
generation: "生成默认值",
|
|
313
|
+
generationHint: "Ollama 原生默认值;空字段不发送,请求参数优先。",
|
|
314
|
+
temperature: "Temperature",
|
|
315
|
+
topK: "Top K",
|
|
316
|
+
topP: "Top P",
|
|
317
|
+
minP: "Min P",
|
|
318
|
+
seed: "Seed",
|
|
319
|
+
repeatPenalty: "Repeat penalty",
|
|
320
|
+
repeatLastN: "Repeat last N",
|
|
321
|
+
numCtx: "num_ctx",
|
|
322
|
+
keepAlive: "Keep alive",
|
|
323
|
+
keepAliveHint: "Ollama keep_alive,例如 5m 或 -1。",
|
|
324
|
+
stop: "Stop sequences",
|
|
325
|
+
stopHint: "逗号分隔,作为原生 stop 列表发送。",
|
|
298
326
|
sidebar: "侧边栏",
|
|
299
327
|
serviceStatus: "服务状态",
|
|
300
328
|
serviceStatusHint: "检查 Ollama Cloud 公共 tag 端点,不使用密钥或额度。",
|
|
@@ -1486,6 +1514,9 @@ window.__ModuleLoader__.load({
|
|
|
1486
1514
|
});
|
|
1487
1515
|
}
|
|
1488
1516
|
// src/client/settings-draft.ts
|
|
1517
|
+
function textOf(value) {
|
|
1518
|
+
return value === null || value === void 0 ? "" : String(value);
|
|
1519
|
+
}
|
|
1489
1520
|
function draftOf(state) {
|
|
1490
1521
|
const allIds = state.models.map((model) => model.id);
|
|
1491
1522
|
return {
|
|
@@ -1497,8 +1528,18 @@ window.__ModuleLoader__.load({
|
|
|
1497
1528
|
transport: state.config.transport,
|
|
1498
1529
|
requestTimeoutMs: String(state.config.requestTimeoutMs),
|
|
1499
1530
|
streamIdleTimeoutMs: String(state.config.streamIdleTimeoutMs),
|
|
1500
|
-
maxOutputTokens:
|
|
1501
|
-
contextWindow:
|
|
1531
|
+
maxOutputTokens: textOf(state.config.maxOutputTokens),
|
|
1532
|
+
contextWindow: textOf(state.config.contextWindow),
|
|
1533
|
+
temperature: textOf(state.config.temperature),
|
|
1534
|
+
topK: textOf(state.config.topK),
|
|
1535
|
+
topP: textOf(state.config.topP),
|
|
1536
|
+
minP: textOf(state.config.minP),
|
|
1537
|
+
seed: textOf(state.config.seed),
|
|
1538
|
+
repeatPenalty: textOf(state.config.repeatPenalty),
|
|
1539
|
+
repeatLastN: textOf(state.config.repeatLastN),
|
|
1540
|
+
numCtx: textOf(state.config.numCtx),
|
|
1541
|
+
keepAlive: state.config.keepAlive ?? "",
|
|
1542
|
+
stop: (state.config.stop ?? []).join(", "),
|
|
1502
1543
|
showSidebarQuota: state.config.showSidebarQuota,
|
|
1503
1544
|
planLabel: state.config.planLabel,
|
|
1504
1545
|
activeAccount: state.config.activeAccount,
|
|
@@ -1518,6 +1559,16 @@ window.__ModuleLoader__.load({
|
|
|
1518
1559
|
if (!Number.isInteger(value) || value < 0) throw new Error(`Invalid number: ${text}`);
|
|
1519
1560
|
return value;
|
|
1520
1561
|
}
|
|
1562
|
+
function boundedNumber(text, min, max, integer) {
|
|
1563
|
+
const trimmed = text.trim();
|
|
1564
|
+
if (trimmed === "") return null;
|
|
1565
|
+
const value = Number(trimmed);
|
|
1566
|
+
if (!Number.isFinite(value) || value < min || value > max || integer && !Number.isInteger(value)) throw new Error(`Invalid number: ${text}`);
|
|
1567
|
+
return value;
|
|
1568
|
+
}
|
|
1569
|
+
function stopList(text) {
|
|
1570
|
+
return text.split(/[\n,]/).map((entry) => entry.trim()).filter((entry) => entry !== "");
|
|
1571
|
+
}
|
|
1521
1572
|
function patchOf(draft) {
|
|
1522
1573
|
return {
|
|
1523
1574
|
apiKeyEnv: draft.apiKeyEnv.trim(),
|
|
@@ -1530,6 +1581,16 @@ window.__ModuleLoader__.load({
|
|
|
1530
1581
|
streamIdleTimeoutMs: numberOrNull(draft.streamIdleTimeoutMs) ?? 3e5,
|
|
1531
1582
|
maxOutputTokens: numberOrNull(draft.maxOutputTokens),
|
|
1532
1583
|
contextWindow: numberOrNull(draft.contextWindow),
|
|
1584
|
+
temperature: boundedNumber(draft.temperature, 0, 2, false),
|
|
1585
|
+
topK: boundedNumber(draft.topK, 1, 1e6, true),
|
|
1586
|
+
topP: boundedNumber(draft.topP, 0, 1, false),
|
|
1587
|
+
minP: boundedNumber(draft.minP, 0, 1, false),
|
|
1588
|
+
seed: boundedNumber(draft.seed, 0, 4294967295, true),
|
|
1589
|
+
repeatPenalty: boundedNumber(draft.repeatPenalty, 0, 2, false),
|
|
1590
|
+
repeatLastN: boundedNumber(draft.repeatLastN, -1, 1e6, true),
|
|
1591
|
+
numCtx: boundedNumber(draft.numCtx, 1, 1e7, true),
|
|
1592
|
+
keepAlive: draft.keepAlive.trim(),
|
|
1593
|
+
stop: stopList(draft.stop),
|
|
1533
1594
|
showSidebarQuota: draft.showSidebarQuota,
|
|
1534
1595
|
planLabel: draft.planLabel.trim(),
|
|
1535
1596
|
activeAccount: draft.activeAccount.trim(),
|
|
@@ -2508,6 +2569,84 @@ window.__ModuleLoader__.load({
|
|
|
2508
2569
|
})
|
|
2509
2570
|
]
|
|
2510
2571
|
}),
|
|
2572
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2573
|
+
className: "ocl-card",
|
|
2574
|
+
children: [
|
|
2575
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
2576
|
+
className: "ocl-card-title",
|
|
2577
|
+
children: t("generation")
|
|
2578
|
+
}),
|
|
2579
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
2580
|
+
className: "ocl-hint",
|
|
2581
|
+
children: t("generationHint")
|
|
2582
|
+
}),
|
|
2583
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2584
|
+
className: "ocl-grid",
|
|
2585
|
+
children: [
|
|
2586
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2587
|
+
label: t("temperature"),
|
|
2588
|
+
type: "number",
|
|
2589
|
+
value: draft.temperature,
|
|
2590
|
+
onChange: (value) => update({ temperature: value })
|
|
2591
|
+
}),
|
|
2592
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2593
|
+
label: t("topK"),
|
|
2594
|
+
type: "number",
|
|
2595
|
+
value: draft.topK,
|
|
2596
|
+
onChange: (value) => update({ topK: value })
|
|
2597
|
+
}),
|
|
2598
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2599
|
+
label: t("topP"),
|
|
2600
|
+
type: "number",
|
|
2601
|
+
value: draft.topP,
|
|
2602
|
+
onChange: (value) => update({ topP: value })
|
|
2603
|
+
}),
|
|
2604
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2605
|
+
label: t("minP"),
|
|
2606
|
+
type: "number",
|
|
2607
|
+
value: draft.minP,
|
|
2608
|
+
onChange: (value) => update({ minP: value })
|
|
2609
|
+
}),
|
|
2610
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2611
|
+
label: t("seed"),
|
|
2612
|
+
type: "number",
|
|
2613
|
+
value: draft.seed,
|
|
2614
|
+
onChange: (value) => update({ seed: value })
|
|
2615
|
+
}),
|
|
2616
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2617
|
+
label: t("repeatPenalty"),
|
|
2618
|
+
type: "number",
|
|
2619
|
+
value: draft.repeatPenalty,
|
|
2620
|
+
onChange: (value) => update({ repeatPenalty: value })
|
|
2621
|
+
}),
|
|
2622
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2623
|
+
label: t("repeatLastN"),
|
|
2624
|
+
type: "number",
|
|
2625
|
+
value: draft.repeatLastN,
|
|
2626
|
+
onChange: (value) => update({ repeatLastN: value })
|
|
2627
|
+
}),
|
|
2628
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2629
|
+
label: t("numCtx"),
|
|
2630
|
+
type: "number",
|
|
2631
|
+
value: draft.numCtx,
|
|
2632
|
+
onChange: (value) => update({ numCtx: value })
|
|
2633
|
+
}),
|
|
2634
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2635
|
+
label: t("keepAlive"),
|
|
2636
|
+
hint: t("keepAliveHint"),
|
|
2637
|
+
value: draft.keepAlive,
|
|
2638
|
+
onChange: (value) => update({ keepAlive: value })
|
|
2639
|
+
}),
|
|
2640
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
2641
|
+
label: t("stop"),
|
|
2642
|
+
hint: t("stopHint"),
|
|
2643
|
+
value: draft.stop,
|
|
2644
|
+
onChange: (value) => update({ stop: value })
|
|
2645
|
+
})
|
|
2646
|
+
]
|
|
2647
|
+
})
|
|
2648
|
+
]
|
|
2649
|
+
}),
|
|
2511
2650
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
2512
2651
|
className: "ocl-card",
|
|
2513
2652
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
package/lib/index.d.ts
CHANGED
|
@@ -58,6 +58,17 @@ interface Config {
|
|
|
58
58
|
contextWindowOverrides?: Record<string, number>;
|
|
59
59
|
/** Per-turn output cap; `0` omits `num_predict`/`max_tokens`. */
|
|
60
60
|
maxOutputTokens?: number;
|
|
61
|
+
/** Optional Ollama native generation defaults. */
|
|
62
|
+
temperature?: number;
|
|
63
|
+
topK?: number;
|
|
64
|
+
topP?: number;
|
|
65
|
+
minP?: number;
|
|
66
|
+
seed?: number;
|
|
67
|
+
repeatPenalty?: number;
|
|
68
|
+
repeatLastN?: number;
|
|
69
|
+
numCtx?: number;
|
|
70
|
+
keepAlive?: string;
|
|
71
|
+
stop?: string[];
|
|
61
72
|
/** Extra accounts for rotation. */
|
|
62
73
|
accounts?: AccountConfig[];
|
|
63
74
|
/** Preferred account per model glob; others remain fallbacks. */
|
|
@@ -94,6 +105,16 @@ interface ResolvedConfig {
|
|
|
94
105
|
contextWindow?: number;
|
|
95
106
|
contextWindowOverrides: Readonly<Record<string, number>>;
|
|
96
107
|
maxOutputTokens?: number;
|
|
108
|
+
temperature?: number;
|
|
109
|
+
topK?: number;
|
|
110
|
+
topP?: number;
|
|
111
|
+
minP?: number;
|
|
112
|
+
seed?: number;
|
|
113
|
+
repeatPenalty?: number;
|
|
114
|
+
repeatLastN?: number;
|
|
115
|
+
numCtx?: number;
|
|
116
|
+
keepAlive?: string;
|
|
117
|
+
stop?: readonly string[];
|
|
97
118
|
accounts: readonly AccountConfig[];
|
|
98
119
|
modelAccountRules: readonly ModelAccountRule[];
|
|
99
120
|
stickySession: boolean;
|
|
@@ -439,6 +460,23 @@ interface EffectiveModel extends OllamaCloudModelMeta {
|
|
|
439
460
|
}
|
|
440
461
|
declare function effectiveModel(id: string, config: ResolvedConfig): EffectiveModel;
|
|
441
462
|
declare function describeModel(meta: EffectiveModel, config: ResolvedConfig): string;
|
|
463
|
+
interface ModelProbe {
|
|
464
|
+
readonly contextWindow?: number;
|
|
465
|
+
readonly input: readonly ('text' | 'image')[];
|
|
466
|
+
readonly reasoning: readonly string[];
|
|
467
|
+
readonly reasoningToggle: boolean;
|
|
468
|
+
readonly tools: boolean;
|
|
469
|
+
readonly available: boolean;
|
|
470
|
+
}
|
|
471
|
+
/** Probe one local model via `/api/show`, caching successful answers for five minutes. */
|
|
472
|
+
declare function probeModel(config: ResolvedConfig, model: string, fetchImpl?: typeof fetch): Promise<ModelProbe | undefined>;
|
|
473
|
+
/** Clear all probe entries, or only entries for one endpoint. */
|
|
474
|
+
declare function clearModelProbeCache(baseURL?: string): void;
|
|
475
|
+
declare function modelProbeCacheInfo(): Array<{
|
|
476
|
+
baseURL: string;
|
|
477
|
+
model: string;
|
|
478
|
+
at: number;
|
|
479
|
+
}>;
|
|
442
480
|
declare const name = "llm-ollama-cloud";
|
|
443
481
|
declare const inject: string[];
|
|
444
482
|
/**
|
|
@@ -447,5 +485,5 @@ declare const inject: string[];
|
|
|
447
485
|
* without a restart.
|
|
448
486
|
*/
|
|
449
487
|
declare function apply(ctx: Context, config: Config): void;
|
|
450
|
-
export { type CommandDeps, Config, type Config as OllamaCloudConfig, OllamaCloudAdapter, type OllamaCloudAdapterDeps, PROVIDER, type ResolvedConfig, type ResolvedKey, type RouteDeps, type TransportId, type UsageReport, type UsageResult, type UsageWindow, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, createKeyPool, createKeyResolver, createUsageReader, describeModel, effectiveModel, inject, name, normalizeBalance, normalizeUsage, resolveConfig };
|
|
488
|
+
export { type CommandDeps, Config, type Config as OllamaCloudConfig, OllamaCloudAdapter, type OllamaCloudAdapterDeps, PROVIDER, type ResolvedConfig, type ResolvedKey, type RouteDeps, type TransportId, type UsageReport, type UsageResult, type UsageWindow, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, clearModelProbeCache, createKeyPool, createKeyResolver, createUsageReader, describeModel, effectiveModel, inject, modelProbeCacheInfo, name, normalizeBalance, normalizeUsage, probeModel, resolveConfig };
|
|
451
489
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -50,7 +50,7 @@ const DEFAULT_API_BASE = "https://ollama.com";
|
|
|
50
50
|
const DEFAULT_OPENAI_BASE = "https://ollama.com/v1";
|
|
51
51
|
const DEFAULT_USAGE_URL = "https://ollama.com/api/usage";
|
|
52
52
|
const DEFAULT_BALANCE_URL = "https://ollama.com/api/balance";
|
|
53
|
-
const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.
|
|
53
|
+
const DEFAULT_USER_AGENT = "dsh-ollama-cloud-provider/0.1.19";
|
|
54
54
|
const DEFAULT_CONTEXT_WINDOW = 131072;
|
|
55
55
|
const DEFAULT_MAX_TOKENS = 32768;
|
|
56
56
|
const DEFAULT_GENERATE_MAX_TOKENS = 131072;
|
|
@@ -76,6 +76,16 @@ const Config = z.object({
|
|
|
76
76
|
contextWindow: markVolatile(z.number().min(1).max(1e7).step(1)),
|
|
77
77
|
contextWindowOverrides: markVolatile(z.dict(z.number().min(1).max(1e7).step(1)).default({})),
|
|
78
78
|
maxOutputTokens: markVolatile(z.number().min(0).max(1e7).step(1)),
|
|
79
|
+
temperature: markVolatile(z.number().min(0).max(2)),
|
|
80
|
+
topK: markVolatile(z.number().min(1).max(1e6).step(1)),
|
|
81
|
+
topP: markVolatile(z.number().min(0).max(1)),
|
|
82
|
+
minP: markVolatile(z.number().min(0).max(1)),
|
|
83
|
+
seed: markVolatile(z.number().min(0).max(4294967295).step(1)),
|
|
84
|
+
repeatPenalty: markVolatile(z.number().min(0).max(2)),
|
|
85
|
+
repeatLastN: markVolatile(z.number().min(-1).max(1e6).step(1)),
|
|
86
|
+
numCtx: markVolatile(z.number().min(1).max(1e7).step(1)),
|
|
87
|
+
keepAlive: markVolatile(z.string()),
|
|
88
|
+
stop: markVolatile(z.array(z.string())),
|
|
79
89
|
accounts: markVolatile(z.array(z.object({
|
|
80
90
|
label: z.string(),
|
|
81
91
|
apiKeyEnv: z.string().role("credential-ref"),
|
|
@@ -109,6 +119,18 @@ function unwrapVolatileConfig(config) {
|
|
|
109
119
|
function positiveInt(value, fallback) {
|
|
110
120
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.trunc(value) : fallback;
|
|
111
121
|
}
|
|
122
|
+
function numberInRange(value, min, max) {
|
|
123
|
+
return typeof value === "number" && Number.isFinite(value) && value >= min && value <= max ? value : void 0;
|
|
124
|
+
}
|
|
125
|
+
function integerInRange(value, min, max) {
|
|
126
|
+
if (typeof value !== "number" || !Number.isInteger(value) || value < min || value > max) return void 0;
|
|
127
|
+
return value;
|
|
128
|
+
}
|
|
129
|
+
function nonEmptyStrings(value) {
|
|
130
|
+
if (!Array.isArray(value)) return void 0;
|
|
131
|
+
const out = value.filter((entry) => typeof entry === "string" && entry.trim() !== "");
|
|
132
|
+
return out.length === 0 ? void 0 : out;
|
|
133
|
+
}
|
|
112
134
|
function recordOf(value) {
|
|
113
135
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
114
136
|
}
|
|
@@ -158,8 +180,17 @@ function ruleList(value) {
|
|
|
158
180
|
function resolveConfig(config) {
|
|
159
181
|
const apiKey = typeof config.apiKey === "string" && config.apiKey.trim() !== "" ? config.apiKey.trim() : void 0;
|
|
160
182
|
const visibleModels = Array.isArray(config.visibleModels) ? config.visibleModels.filter((id) => typeof id === "string" && id !== "") : [];
|
|
183
|
+
const temperature = numberInRange(config.temperature, 0, 2);
|
|
184
|
+
const topK = integerInRange(config.topK, 1, 1e6);
|
|
185
|
+
const topP = numberInRange(config.topP, 0, 1);
|
|
186
|
+
const minP = numberInRange(config.minP, 0, 1);
|
|
187
|
+
const seed = integerInRange(config.seed, 0, 4294967295);
|
|
188
|
+
const repeatPenalty = numberInRange(config.repeatPenalty, 0, 2);
|
|
189
|
+
const repeatLastN = integerInRange(config.repeatLastN, -1, 1e6);
|
|
190
|
+
const numCtx = integerInRange(config.numCtx, 1, 1e7);
|
|
191
|
+
const stop = nonEmptyStrings(config.stop);
|
|
161
192
|
return {
|
|
162
|
-
apiKeyEnv: typeof config.apiKeyEnv === "string"
|
|
193
|
+
apiKeyEnv: typeof config.apiKeyEnv === "string" ? config.apiKeyEnv.trim() : DEFAULT_API_KEY_ENV,
|
|
163
194
|
...apiKey === void 0 ? {} : { apiKey },
|
|
164
195
|
apiBase: typeof config.apiBase === "string" && config.apiBase !== "" ? config.apiBase : DEFAULT_API_BASE,
|
|
165
196
|
openAiBase: typeof config.openAiBase === "string" && config.openAiBase !== "" ? config.openAiBase : DEFAULT_OPENAI_BASE,
|
|
@@ -176,6 +207,16 @@ function resolveConfig(config) {
|
|
|
176
207
|
...typeof config.contextWindow === "number" && Number.isInteger(config.contextWindow) && config.contextWindow > 0 ? { contextWindow: config.contextWindow } : {},
|
|
177
208
|
contextWindowOverrides: numberRecord(config.contextWindowOverrides),
|
|
178
209
|
...typeof config.maxOutputTokens === "number" && Number.isInteger(config.maxOutputTokens) && config.maxOutputTokens >= 0 ? { maxOutputTokens: config.maxOutputTokens } : {},
|
|
210
|
+
...temperature === void 0 ? {} : { temperature },
|
|
211
|
+
...topK === void 0 ? {} : { topK },
|
|
212
|
+
...topP === void 0 ? {} : { topP },
|
|
213
|
+
...minP === void 0 ? {} : { minP },
|
|
214
|
+
...seed === void 0 ? {} : { seed },
|
|
215
|
+
...repeatPenalty === void 0 ? {} : { repeatPenalty },
|
|
216
|
+
...repeatLastN === void 0 ? {} : { repeatLastN },
|
|
217
|
+
...numCtx === void 0 ? {} : { numCtx },
|
|
218
|
+
...typeof config.keepAlive === "string" && config.keepAlive.trim() !== "" ? { keepAlive: config.keepAlive.trim() } : {},
|
|
219
|
+
...stop === void 0 ? {} : { stop },
|
|
179
220
|
accounts: Array.isArray(config.accounts) ? config.accounts : [],
|
|
180
221
|
modelAccountRules: ruleList(config.modelAccountRules),
|
|
181
222
|
stickySession: config.stickySession !== false,
|
|
@@ -682,6 +723,113 @@ const GENERATED_MODELS = {
|
|
|
682
723
|
}
|
|
683
724
|
}
|
|
684
725
|
};
|
|
726
|
+
// src/routing.ts
|
|
727
|
+
function trim(url) {
|
|
728
|
+
return url.replace(/\/+$/, "");
|
|
729
|
+
}
|
|
730
|
+
function rootFor(config) {
|
|
731
|
+
return trim(config.apiBase);
|
|
732
|
+
}
|
|
733
|
+
function modelsUrlFor(config) {
|
|
734
|
+
return `${rootFor(config)}/v1/models`;
|
|
735
|
+
}
|
|
736
|
+
function tagsUrlFor(config) {
|
|
737
|
+
return `${rootFor(config)}/api/tags`;
|
|
738
|
+
}
|
|
739
|
+
/** Endpoint for one model and one wire protocol. */
|
|
740
|
+
function endpointFor(transport, config) {
|
|
741
|
+
return transport === "openai-chat" ? `${trim(config.openAiBase)}/chat/completions` : `${rootFor(config)}/api/chat`;
|
|
742
|
+
}
|
|
743
|
+
// src/model-probe.ts
|
|
744
|
+
const PROBE_TTL_MS = 3e5;
|
|
745
|
+
const cache$2 = /* @__PURE__ */ new Map();
|
|
746
|
+
function keyOf(config, model) {
|
|
747
|
+
return `${rootFor(config)}|${model}`;
|
|
748
|
+
}
|
|
749
|
+
function isLocalEndpoint(config) {
|
|
750
|
+
if (config.apiKeyEnv === "") return true;
|
|
751
|
+
try {
|
|
752
|
+
const host = new URL(config.apiBase).hostname;
|
|
753
|
+
return host === "127.0.0.1" || host === "localhost" || host === "::1" || host === "[::1]";
|
|
754
|
+
} catch {
|
|
755
|
+
return false;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
function contextOf(info) {
|
|
759
|
+
let best;
|
|
760
|
+
for (const [key, value] of Object.entries(info)) {
|
|
761
|
+
if (!key.endsWith(".context_length")) continue;
|
|
762
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) continue;
|
|
763
|
+
best = best === void 0 ? value : Math.max(best, value);
|
|
764
|
+
}
|
|
765
|
+
return best === void 0 ? void 0 : Math.trunc(best);
|
|
766
|
+
}
|
|
767
|
+
function probeOf(body) {
|
|
768
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) return void 0;
|
|
769
|
+
const record = body;
|
|
770
|
+
const info = typeof record.model_info === "object" && record.model_info !== null ? record.model_info : {};
|
|
771
|
+
const capabilities = Array.isArray(record.capabilities) ? record.capabilities.filter((entry) => typeof entry === "string") : [];
|
|
772
|
+
const thinking = capabilities.includes("thinking");
|
|
773
|
+
const vision = capabilities.includes("vision");
|
|
774
|
+
const contextWindow = contextOf(info);
|
|
775
|
+
const input = vision ? ["text", "image"] : ["text"];
|
|
776
|
+
return {
|
|
777
|
+
...contextWindow === void 0 ? {} : { contextWindow },
|
|
778
|
+
input,
|
|
779
|
+
reasoning: thinking ? ["off", "high"] : [],
|
|
780
|
+
reasoningToggle: thinking,
|
|
781
|
+
tools: capabilities.includes("tools"),
|
|
782
|
+
available: true
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
/** Probe one local model via `/api/show`, caching successful answers for five minutes. */
|
|
786
|
+
async function probeModel(config, model, fetchImpl = fetch) {
|
|
787
|
+
if (!isLocalEndpoint(config)) return void 0;
|
|
788
|
+
const key = keyOf(config, model);
|
|
789
|
+
const hit = cache$2.get(key);
|
|
790
|
+
if (hit !== void 0 && Date.now() - hit.at < PROBE_TTL_MS) return hit.value;
|
|
791
|
+
try {
|
|
792
|
+
const response = await fetchImpl(`${rootFor(config)}/api/show`, {
|
|
793
|
+
method: "POST",
|
|
794
|
+
headers: {
|
|
795
|
+
accept: "application/json",
|
|
796
|
+
"content-type": "application/json",
|
|
797
|
+
"user-agent": config.userAgent
|
|
798
|
+
},
|
|
799
|
+
body: JSON.stringify({ model }),
|
|
800
|
+
signal: AbortSignal.timeout(1e4)
|
|
801
|
+
});
|
|
802
|
+
if (!response.ok) return void 0;
|
|
803
|
+
const value = probeOf(await response.json());
|
|
804
|
+
if (value === void 0) return void 0;
|
|
805
|
+
cache$2.set(key, {
|
|
806
|
+
at: Date.now(),
|
|
807
|
+
value
|
|
808
|
+
});
|
|
809
|
+
return value;
|
|
810
|
+
} catch {
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
/** Clear all probe entries, or only entries for one endpoint. */
|
|
815
|
+
function clearModelProbeCache(baseURL) {
|
|
816
|
+
if (baseURL === void 0) {
|
|
817
|
+
cache$2.clear();
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
const prefix = `${baseURL.replace(/\/+$/, "")}|`;
|
|
821
|
+
for (const key of cache$2.keys()) if (key.startsWith(prefix)) cache$2.delete(key);
|
|
822
|
+
}
|
|
823
|
+
function modelProbeCacheInfo() {
|
|
824
|
+
return [...cache$2.entries()].map(([key, entry]) => {
|
|
825
|
+
const separator = key.indexOf("|");
|
|
826
|
+
return {
|
|
827
|
+
baseURL: key.slice(0, separator),
|
|
828
|
+
model: key.slice(separator + 1),
|
|
829
|
+
at: entry.at
|
|
830
|
+
};
|
|
831
|
+
});
|
|
832
|
+
}
|
|
685
833
|
// src/pricing.ts
|
|
686
834
|
/** `gpt-oss:120b` → `gpt-oss`; used as the second lookup key. */
|
|
687
835
|
function baseIdOf(id) {
|
|
@@ -756,22 +904,73 @@ function formatUsd(value) {
|
|
|
756
904
|
if (Math.abs(value) >= .01) return `$${value.toFixed(3)}`;
|
|
757
905
|
return `$${value.toFixed(4)}`;
|
|
758
906
|
}
|
|
759
|
-
// src/
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
907
|
+
// src/reasoning.ts
|
|
908
|
+
const EFFORT_ORDER = [
|
|
909
|
+
"off",
|
|
910
|
+
"minimal",
|
|
911
|
+
"low",
|
|
912
|
+
"medium",
|
|
913
|
+
"high",
|
|
914
|
+
"xhigh",
|
|
915
|
+
"max"
|
|
916
|
+
];
|
|
917
|
+
const FAMILY_DEFAULTS = [
|
|
918
|
+
{
|
|
919
|
+
prefix: "glm-5.3",
|
|
920
|
+
effort: "max"
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
prefix: "glm-5.2",
|
|
924
|
+
effort: "max"
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
prefix: "kimi-k3",
|
|
928
|
+
effort: "max"
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
prefix: "kimi-k2",
|
|
932
|
+
effort: "high"
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
prefix: "deepseek-v4",
|
|
936
|
+
effort: "high"
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
prefix: "minimax-m3",
|
|
940
|
+
effort: "high"
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
prefix: "gpt-oss",
|
|
944
|
+
effort: "medium"
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
prefix: "nemotron",
|
|
948
|
+
effort: "low"
|
|
949
|
+
}
|
|
950
|
+
];
|
|
951
|
+
function normalizeEfforts(levels) {
|
|
952
|
+
const seen = /* @__PURE__ */ new Set();
|
|
953
|
+
for (const level of levels) {
|
|
954
|
+
const clean = level.trim().toLowerCase();
|
|
955
|
+
if (clean !== "") seen.add(clean);
|
|
956
|
+
}
|
|
957
|
+
const ordered = EFFORT_ORDER.filter((level) => seen.has(level));
|
|
958
|
+
const extra = [...seen].filter((level) => !EFFORT_ORDER.includes(level)).sort();
|
|
959
|
+
return [...ordered, ...extra];
|
|
960
|
+
}
|
|
961
|
+
function defaultEffortFor(id, levels) {
|
|
962
|
+
const family = id.split(":")[0]?.toLowerCase() ?? "";
|
|
963
|
+
for (const entry of FAMILY_DEFAULTS) if (family.startsWith(entry.prefix) && levels.includes(entry.effort)) return entry.effort;
|
|
964
|
+
}
|
|
965
|
+
/** Normalize boolean switches and level ladders, then apply the known family default. */
|
|
966
|
+
function normalizeThinking(id, levels, toggle, fallback) {
|
|
967
|
+
const reasoning = normalizeEfforts(levels);
|
|
968
|
+
if (reasoning.length === 0 && toggle) reasoning.push("off", "high");
|
|
969
|
+
const candidate = fallback !== void 0 && reasoning.includes(fallback) ? fallback : defaultEffortFor(id, reasoning) ?? (toggle && reasoning.includes("high") ? "high" : void 0);
|
|
970
|
+
return {
|
|
971
|
+
reasoning,
|
|
972
|
+
...candidate === void 0 ? {} : { defaultReasoning: candidate }
|
|
973
|
+
};
|
|
775
974
|
}
|
|
776
975
|
// src/catalog.ts
|
|
777
976
|
const CATALOG_TTL_MS = 6e5;
|
|
@@ -836,6 +1035,7 @@ function metaFromLive(entry, caps) {
|
|
|
836
1035
|
const toggle = (caps?.has("thinking") === true || levels.length > 0) && levels.length === 0;
|
|
837
1036
|
const modalities = strings(entry.input_modalities);
|
|
838
1037
|
const image = modalities.includes("image") || base?.input.includes("image") === true && modalities.length === 0;
|
|
1038
|
+
const normalized = normalizeThinking(id, levels.length > 0 ? levels : base?.reasoning ?? [], toggle || base?.reasoningToggle === true, str$1(entry.default_reasoning_level) ?? base?.defaultReasoning);
|
|
839
1039
|
return {
|
|
840
1040
|
id,
|
|
841
1041
|
name: str$1(entry.display_name) ?? id,
|
|
@@ -843,12 +1043,36 @@ function metaFromLive(entry, caps) {
|
|
|
843
1043
|
contextWindow: num$1(entry.context_window) ?? num$1(entry.max_context_window) ?? base?.contextWindow ?? 131072,
|
|
844
1044
|
maxTokens: base?.maxTokens ?? 32768,
|
|
845
1045
|
input: image ? ["text", "image"] : ["text"],
|
|
846
|
-
reasoning:
|
|
847
|
-
reasoningToggle: toggle || base?.reasoningToggle === true
|
|
1046
|
+
reasoning: normalized.reasoning,
|
|
1047
|
+
reasoningToggle: toggle || base?.reasoningToggle === true,
|
|
848
1048
|
tools: caps?.has("tools") === true || base?.tools === true || base === void 0,
|
|
849
1049
|
free: base?.free === true,
|
|
850
1050
|
available: entry.supported_in_api !== false && entry.visibility !== "hide",
|
|
851
|
-
...
|
|
1051
|
+
...normalized.defaultReasoning === void 0 ? {} : { defaultReasoning: normalized.defaultReasoning },
|
|
1052
|
+
cost: base?.cost ?? {
|
|
1053
|
+
input: 0,
|
|
1054
|
+
output: 0,
|
|
1055
|
+
cacheRead: 0
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
function metaFromProbe(id, probe) {
|
|
1060
|
+
if (probe === void 0) return void 0;
|
|
1061
|
+
const base = GENERATED_MODELS[id];
|
|
1062
|
+
const normalized = normalizeThinking(id, probe.reasoning.length > 0 ? probe.reasoning : base?.reasoning ?? [], probe.reasoningToggle || base?.reasoningToggle === true, base?.defaultReasoning);
|
|
1063
|
+
return {
|
|
1064
|
+
id,
|
|
1065
|
+
name: base?.name ?? id,
|
|
1066
|
+
transport: base?.transport ?? "native",
|
|
1067
|
+
contextWindow: probe.contextWindow ?? base?.contextWindow ?? 131072,
|
|
1068
|
+
maxTokens: base?.maxTokens ?? 32768,
|
|
1069
|
+
input: [...probe.input],
|
|
1070
|
+
reasoning: normalized.reasoning,
|
|
1071
|
+
reasoningToggle: probe.reasoningToggle || base?.reasoningToggle === true,
|
|
1072
|
+
tools: probe.tools || base?.tools === true,
|
|
1073
|
+
free: base?.free === true,
|
|
1074
|
+
available: probe.available,
|
|
1075
|
+
...normalized.defaultReasoning === void 0 ? {} : { defaultReasoning: normalized.defaultReasoning },
|
|
852
1076
|
cost: base?.cost ?? {
|
|
853
1077
|
input: 0,
|
|
854
1078
|
output: 0,
|
|
@@ -856,6 +1080,13 @@ function metaFromLive(entry, caps) {
|
|
|
856
1080
|
}
|
|
857
1081
|
};
|
|
858
1082
|
}
|
|
1083
|
+
async function adoptProbes(config, ids, base, fetchImpl) {
|
|
1084
|
+
const probes = await Promise.all(ids.slice(0, 64).map(async (id) => ({
|
|
1085
|
+
id,
|
|
1086
|
+
meta: metaFromProbe(id, await probeModel(config, id, fetchImpl))
|
|
1087
|
+
})));
|
|
1088
|
+
for (const { id, meta } of probes) if (meta !== void 0) liveMeta.set(liveKey(base, id), meta);
|
|
1089
|
+
}
|
|
859
1090
|
/** Replace the in-memory live metadata for one API base with one successful response. */
|
|
860
1091
|
function adoptLive(models, tags, base) {
|
|
861
1092
|
const caps = capabilitiesByModel(tags);
|
|
@@ -923,13 +1154,16 @@ async function refreshNow(config, fetchImpl, key, keepOnFailure, epoch) {
|
|
|
923
1154
|
}
|
|
924
1155
|
}
|
|
925
1156
|
const fromData = Array.isArray(payload.data) ? payload.data.map((entry) => str$1(entry.id)).filter((id) => id !== void 0) : [];
|
|
926
|
-
|
|
1157
|
+
const fromTags = ((tagsResult.status === "fulfilled" ? tagsResult.value : void 0)?.models ?? []).map((entry) => str$1(entry.name) ?? str$1(entry.model)).filter((id) => id !== void 0);
|
|
1158
|
+
const ids = fromData.length > 0 ? fromData : fromTags;
|
|
1159
|
+
if (ids.length > 0) {
|
|
927
1160
|
for (const liveKey of liveMeta.keys()) if (liveKey.startsWith(`${key}|`)) liveMeta.delete(liveKey);
|
|
1161
|
+
if (isLocalEndpoint(config)) await adoptProbes(config, ids, key, fetchImpl);
|
|
928
1162
|
cache$1.set(key, {
|
|
929
1163
|
at: Date.now(),
|
|
930
|
-
ids
|
|
1164
|
+
ids
|
|
931
1165
|
});
|
|
932
|
-
return
|
|
1166
|
+
return ids;
|
|
933
1167
|
}
|
|
934
1168
|
}
|
|
935
1169
|
if (keepOnFailure) {
|
|
@@ -955,6 +1189,7 @@ function clearCatalogCache() {
|
|
|
955
1189
|
cache$1.clear();
|
|
956
1190
|
inflight.clear();
|
|
957
1191
|
liveMeta.clear();
|
|
1192
|
+
clearModelProbeCache();
|
|
958
1193
|
}
|
|
959
1194
|
function baseMeta(id, base) {
|
|
960
1195
|
const meta = liveMeta.get(liveKey(base, id)) ?? GENERATED_MODELS[id];
|
|
@@ -1392,10 +1627,19 @@ function buildNativeBody(options, model, config, images) {
|
|
|
1392
1627
|
const tools = buildTools(options.tools);
|
|
1393
1628
|
const maxTokens = options.maxTokens ?? effectiveMaxTokens(model, config);
|
|
1394
1629
|
const think = nativeThink(options.reasoningEffort === void 0 ? void 0 : String(options.reasoningEffort), model);
|
|
1630
|
+
const temperature = options.temperature ?? config.temperature;
|
|
1631
|
+
const stop = options.stop ?? config.stop;
|
|
1395
1632
|
const nativeOptions = {
|
|
1396
|
-
...
|
|
1633
|
+
...temperature === void 0 ? {} : { temperature },
|
|
1634
|
+
...config.topK === void 0 ? {} : { top_k: config.topK },
|
|
1635
|
+
...config.topP === void 0 ? {} : { top_p: config.topP },
|
|
1636
|
+
...config.minP === void 0 ? {} : { min_p: config.minP },
|
|
1637
|
+
...config.seed === void 0 ? {} : { seed: config.seed },
|
|
1638
|
+
...config.repeatPenalty === void 0 ? {} : { repeat_penalty: config.repeatPenalty },
|
|
1639
|
+
...config.repeatLastN === void 0 ? {} : { repeat_last_n: config.repeatLastN },
|
|
1640
|
+
...config.numCtx === void 0 ? {} : { num_ctx: config.numCtx },
|
|
1397
1641
|
...maxTokens === void 0 || maxTokens <= 0 ? {} : { num_predict: maxTokens },
|
|
1398
|
-
...
|
|
1642
|
+
...stop === void 0 || stop.length === 0 ? {} : { stop }
|
|
1399
1643
|
};
|
|
1400
1644
|
return {
|
|
1401
1645
|
model: options.model,
|
|
@@ -1403,6 +1647,7 @@ function buildNativeBody(options, model, config, images) {
|
|
|
1403
1647
|
stream: true,
|
|
1404
1648
|
...tools === void 0 ? {} : { tools },
|
|
1405
1649
|
...think === void 0 ? {} : { think },
|
|
1650
|
+
...config.keepAlive === void 0 ? {} : { keep_alive: config.keepAlive },
|
|
1406
1651
|
...Object.keys(nativeOptions).length === 0 ? {} : { options: nativeOptions }
|
|
1407
1652
|
};
|
|
1408
1653
|
}
|
|
@@ -1493,6 +1738,8 @@ function buildChatBody(options, model, config, images) {
|
|
|
1493
1738
|
const maxTokens = options.maxTokens ?? effectiveMaxTokens(model, config);
|
|
1494
1739
|
const effort = options.reasoningEffort === void 0 ? void 0 : String(options.reasoningEffort);
|
|
1495
1740
|
const reasoning = effort === void 0 || effort === "" ? void 0 : effort === "off" ? "none" : effort;
|
|
1741
|
+
const temperature = options.temperature ?? config.temperature;
|
|
1742
|
+
const stop = options.stop ?? config.stop;
|
|
1496
1743
|
return {
|
|
1497
1744
|
model: options.model,
|
|
1498
1745
|
messages: buildChatMessages(options, images),
|
|
@@ -1502,10 +1749,12 @@ function buildChatBody(options, model, config, images) {
|
|
|
1502
1749
|
tools,
|
|
1503
1750
|
tool_choice: "auto"
|
|
1504
1751
|
},
|
|
1505
|
-
...
|
|
1752
|
+
...temperature === void 0 ? {} : { temperature },
|
|
1753
|
+
...config.topP === void 0 ? {} : { top_p: config.topP },
|
|
1754
|
+
...config.seed === void 0 ? {} : { seed: config.seed },
|
|
1506
1755
|
...maxTokens === void 0 || maxTokens <= 0 ? {} : { max_tokens: maxTokens },
|
|
1507
1756
|
...reasoning === void 0 ? {} : { reasoning_effort: reasoning },
|
|
1508
|
-
...
|
|
1757
|
+
...stop === void 0 || stop.length === 0 ? {} : { stop }
|
|
1509
1758
|
};
|
|
1510
1759
|
}
|
|
1511
1760
|
// src/provider-ids.ts
|
|
@@ -2581,7 +2830,7 @@ var OllamaCloudAdapter = class extends LlmAdapter {
|
|
|
2581
2830
|
async send(url, key, model, body, config, signal) {
|
|
2582
2831
|
const headers = {
|
|
2583
2832
|
...attributionHeaders(),
|
|
2584
|
-
authorization: `Bearer ${key}
|
|
2833
|
+
...key === "" ? {} : { authorization: `Bearer ${key}` },
|
|
2585
2834
|
"content-type": "application/json",
|
|
2586
2835
|
accept: model.transport === "openai-chat" ? "text/event-stream" : "application/x-ndjson",
|
|
2587
2836
|
"user-agent": config.userAgent
|
|
@@ -3047,6 +3296,12 @@ async function resolveSlot(ctx, slot) {
|
|
|
3047
3296
|
function createKeyPool(ctx, config) {
|
|
3048
3297
|
const all = async () => {
|
|
3049
3298
|
const current = config();
|
|
3299
|
+
const hasConfiguredKey = current.apiKey !== void 0 || current.accounts.some((account) => typeof account.apiKey === "string" && account.apiKey.trim() !== "" || typeof account.apiKeyEnv === "string" && account.apiKeyEnv.trim() !== "");
|
|
3300
|
+
if (current.apiKeyEnv === "" && !hasConfiguredKey) return [{
|
|
3301
|
+
key: "",
|
|
3302
|
+
source: "none",
|
|
3303
|
+
label: "default"
|
|
3304
|
+
}];
|
|
3050
3305
|
const pinned = current.activeAccount.trim();
|
|
3051
3306
|
const slots = slotsOf(current);
|
|
3052
3307
|
if (pinned !== "") {
|
|
@@ -3693,6 +3948,16 @@ function publicConfig(config) {
|
|
|
3693
3948
|
contextWindow: config.contextWindow ?? null,
|
|
3694
3949
|
contextWindowOverrides: config.contextWindowOverrides,
|
|
3695
3950
|
maxOutputTokens: config.maxOutputTokens ?? null,
|
|
3951
|
+
temperature: config.temperature ?? null,
|
|
3952
|
+
topK: config.topK ?? null,
|
|
3953
|
+
topP: config.topP ?? null,
|
|
3954
|
+
minP: config.minP ?? null,
|
|
3955
|
+
seed: config.seed ?? null,
|
|
3956
|
+
repeatPenalty: config.repeatPenalty ?? null,
|
|
3957
|
+
repeatLastN: config.repeatLastN ?? null,
|
|
3958
|
+
numCtx: config.numCtx ?? null,
|
|
3959
|
+
keepAlive: config.keepAlive ?? "",
|
|
3960
|
+
stop: config.stop ?? [],
|
|
3696
3961
|
accounts: config.accounts.map((account) => ({
|
|
3697
3962
|
label: typeof account.label === "string" ? account.label : "",
|
|
3698
3963
|
apiKeyEnv: typeof account.apiKeyEnv === "string" ? account.apiKeyEnv : ""
|
|
@@ -3999,6 +4264,7 @@ function configOps(patch) {
|
|
|
3999
4264
|
};
|
|
4000
4265
|
if ("apiKeyEnv" in patch) {
|
|
4001
4266
|
if (patch.apiKeyEnv === null || patch.apiKeyEnv === void 0) set("apiKeyEnv", void 0);
|
|
4267
|
+
else if (typeof patch.apiKeyEnv === "string" && patch.apiKeyEnv.trim() === "") set("apiKeyEnv", "");
|
|
4002
4268
|
else {
|
|
4003
4269
|
const ref = normalizeCredentialRef(patch.apiKeyEnv);
|
|
4004
4270
|
if (ref === void 0) throw new Error("invalid credential reference");
|
|
@@ -4020,6 +4286,16 @@ function configOps(patch) {
|
|
|
4020
4286
|
if ("contextWindow" in patch) set("contextWindow", patch.contextWindow);
|
|
4021
4287
|
if ("contextWindowOverrides" in patch) set("contextWindowOverrides", cleanNumberRecord(patch.contextWindowOverrides));
|
|
4022
4288
|
if ("maxOutputTokens" in patch) set("maxOutputTokens", patch.maxOutputTokens);
|
|
4289
|
+
if ("temperature" in patch) set("temperature", patch.temperature);
|
|
4290
|
+
if ("topK" in patch) set("topK", patch.topK);
|
|
4291
|
+
if ("topP" in patch) set("topP", patch.topP);
|
|
4292
|
+
if ("minP" in patch) set("minP", patch.minP);
|
|
4293
|
+
if ("seed" in patch) set("seed", patch.seed);
|
|
4294
|
+
if ("repeatPenalty" in patch) set("repeatPenalty", patch.repeatPenalty);
|
|
4295
|
+
if ("repeatLastN" in patch) set("repeatLastN", patch.repeatLastN);
|
|
4296
|
+
if ("numCtx" in patch) set("numCtx", patch.numCtx);
|
|
4297
|
+
if ("keepAlive" in patch) set("keepAlive", patch.keepAlive);
|
|
4298
|
+
if ("stop" in patch) set("stop", cleanStringArray(patch.stop));
|
|
4023
4299
|
if ("accounts" in patch) {
|
|
4024
4300
|
const accounts = cleanAccounts(patch.accounts);
|
|
4025
4301
|
for (const account of accounts) if (account.apiKeyEnv !== "" && !isCredentialRef(account.apiKeyEnv)) throw new Error("invalid credential reference");
|
|
@@ -4771,6 +5047,7 @@ function createUsageReader(config, resolveKey, fetchImpl = fetch) {
|
|
|
4771
5047
|
});
|
|
4772
5048
|
};
|
|
4773
5049
|
const readBalance = async (key) => {
|
|
5050
|
+
if (key === "") return void 0;
|
|
4774
5051
|
const current = config();
|
|
4775
5052
|
try {
|
|
4776
5053
|
const response = await request(current.balanceUrl, key);
|
|
@@ -4781,6 +5058,7 @@ function createUsageReader(config, resolveKey, fetchImpl = fetch) {
|
|
|
4781
5058
|
}
|
|
4782
5059
|
};
|
|
4783
5060
|
const readUsage = async (key, range, epoch) => {
|
|
5061
|
+
if (key === "") return void 0;
|
|
4784
5062
|
const current = config();
|
|
4785
5063
|
const cacheKey = `${fingerprint(key)}:${range}`;
|
|
4786
5064
|
const hit = cached(cacheKey);
|
|
@@ -5101,6 +5379,6 @@ function apply(ctx, config) {
|
|
|
5101
5379
|
}), "dsh-ollama-cloud-provider: plugin updater");
|
|
5102
5380
|
});
|
|
5103
5381
|
}
|
|
5104
|
-
export { Config, OllamaCloudAdapter, PROVIDER, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, createKeyPool, createKeyResolver, createUsageReader, describeModel, effectiveModel, inject, name, normalizeBalance, normalizeUsage, resolveConfig };
|
|
5382
|
+
export { Config, OllamaCloudAdapter, PROVIDER, apply, applyCommands, applyRoutes, classifyResponseError, clearCatalogCache, clearModelProbeCache, createKeyPool, createKeyResolver, createUsageReader, describeModel, effectiveModel, inject, modelProbeCacheInfo, name, normalizeBalance, normalizeUsage, probeModel, resolveConfig };
|
|
5105
5383
|
|
|
5106
5384
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-ollama-cloud-provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "Ollama Cloud LLM provider plugin for DeepSeek Harness (dsh).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"build": "tsdown",
|
|
74
74
|
"prepare": "tsdown 1>&2",
|
|
75
75
|
"typecheck": "tsc --noEmit",
|
|
76
|
-
"test": "node --import tsx --test tests/core.test.ts tests/usage.test.ts tests/adapter.test.ts tests/routes.test.ts tests/native.test.ts tests/openai-chat.test.ts tests/commands.test.ts tests/tui-settings.test.ts tests/analytics.test.ts tests/apply.test.ts tests/account-rules.test.ts tests/request-log.test.ts tests/image-budget.test.ts tests/tool-schema.test.ts tests/tools.test.ts tests/plugin-updater.test.ts tests/compat.test.ts tests/status.test.ts tests/settings-draft.test.ts tests/update-state.test.ts tests/ui-render.test.tsx tests/update-card-view.test.tsx tests/web.test.ts tests/mock-ollama.test.ts",
|
|
76
|
+
"test": "node --import tsx --test tests/core.test.ts tests/usage.test.ts tests/adapter.test.ts tests/routes.test.ts tests/native.test.ts tests/openai-chat.test.ts tests/commands.test.ts tests/tui-settings.test.ts tests/analytics.test.ts tests/apply.test.ts tests/account-rules.test.ts tests/request-log.test.ts tests/image-budget.test.ts tests/tool-schema.test.ts tests/tools.test.ts tests/plugin-updater.test.ts tests/compat.test.ts tests/status.test.ts tests/settings-draft.test.ts tests/update-state.test.ts tests/ui-render.test.tsx tests/update-card-view.test.tsx tests/web.test.ts tests/mock-ollama.test.ts tests/local.test.ts tests/reasoning.test.ts",
|
|
77
77
|
"check": "npm run typecheck && npm test && npm run build",
|
|
78
78
|
"release": "npm run check && npm pack",
|
|
79
79
|
"sync:models": "node scripts/sync-models.mjs"
|