open-agents-ai 0.103.76 → 0.103.77
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/dist/index.js +48 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30667,13 +30667,43 @@ async function fetchOllamaModels(baseUrl) {
|
|
|
30667
30667
|
}
|
|
30668
30668
|
const data = await resp.json();
|
|
30669
30669
|
const models = data.models ?? [];
|
|
30670
|
-
|
|
30670
|
+
const result = models.map((m) => ({
|
|
30671
30671
|
name: m.name,
|
|
30672
30672
|
size: formatBytes(m.size),
|
|
30673
30673
|
sizeBytes: m.size,
|
|
30674
30674
|
modified: formatRelativeTime(m.modified_at),
|
|
30675
|
-
parameterSize: m.details?.parameter_size
|
|
30675
|
+
parameterSize: m.details?.parameter_size,
|
|
30676
|
+
contextLength: void 0
|
|
30676
30677
|
})).sort((a, b) => b.sizeBytes - a.sizeBytes);
|
|
30678
|
+
const normalized = normalizeBaseUrl(baseUrl);
|
|
30679
|
+
const showResults = await Promise.allSettled(result.map((m) => fetch(`${normalized}/api/show`, {
|
|
30680
|
+
method: "POST",
|
|
30681
|
+
headers: { "Content-Type": "application/json" },
|
|
30682
|
+
body: JSON.stringify({ name: m.name }),
|
|
30683
|
+
signal: AbortSignal.timeout(5e3)
|
|
30684
|
+
}).then((r) => r.ok ? r.json() : null)));
|
|
30685
|
+
for (let i = 0; i < result.length; i++) {
|
|
30686
|
+
const sr = showResults[i];
|
|
30687
|
+
if (sr?.status !== "fulfilled" || !sr.value)
|
|
30688
|
+
continue;
|
|
30689
|
+
const show = sr.value;
|
|
30690
|
+
if (show.parameters) {
|
|
30691
|
+
const match = show.parameters.match(/num_ctx\s+(\d+)/);
|
|
30692
|
+
if (match) {
|
|
30693
|
+
result[i].contextLength = parseInt(match[1], 10);
|
|
30694
|
+
continue;
|
|
30695
|
+
}
|
|
30696
|
+
}
|
|
30697
|
+
if (show.model_info) {
|
|
30698
|
+
for (const [key, value] of Object.entries(show.model_info)) {
|
|
30699
|
+
if (key.endsWith(".context_length") && typeof value === "number") {
|
|
30700
|
+
result[i].contextLength = value;
|
|
30701
|
+
break;
|
|
30702
|
+
}
|
|
30703
|
+
}
|
|
30704
|
+
}
|
|
30705
|
+
}
|
|
30706
|
+
return result;
|
|
30677
30707
|
}
|
|
30678
30708
|
async function fetchOpenAIModels(baseUrl, apiKey) {
|
|
30679
30709
|
const normalized = normalizeBaseUrl(baseUrl);
|
|
@@ -30693,10 +30723,11 @@ async function fetchOpenAIModels(baseUrl, apiKey) {
|
|
|
30693
30723
|
const models = data.data ?? [];
|
|
30694
30724
|
return models.map((m) => ({
|
|
30695
30725
|
name: m.id,
|
|
30696
|
-
size:
|
|
30726
|
+
size: "",
|
|
30697
30727
|
sizeBytes: 0,
|
|
30698
30728
|
modified: m.created ? formatRelativeTime(new Date(m.created * 1e3).toISOString()) : "",
|
|
30699
|
-
parameterSize: m.owned_by ?? void 0
|
|
30729
|
+
parameterSize: m.owned_by ?? void 0,
|
|
30730
|
+
contextLength: m.context_length ?? m.max_model_len ?? void 0
|
|
30700
30731
|
})).sort((a, b) => a.name.localeCompare(b.name));
|
|
30701
30732
|
}
|
|
30702
30733
|
async function fetchPeerModels(peerId, authKey) {
|
|
@@ -31036,6 +31067,13 @@ function formatBytes(bytes) {
|
|
|
31036
31067
|
}
|
|
31037
31068
|
return `${size.toFixed(1)} ${units[i] ?? "B"}`;
|
|
31038
31069
|
}
|
|
31070
|
+
function formatContextLength(tokens) {
|
|
31071
|
+
if (tokens >= 1e6)
|
|
31072
|
+
return `${(tokens / 1e6).toFixed(1)}M ctx`;
|
|
31073
|
+
if (tokens >= 1024)
|
|
31074
|
+
return `${Math.round(tokens / 1024)}K ctx`;
|
|
31075
|
+
return `${tokens} ctx`;
|
|
31076
|
+
}
|
|
31039
31077
|
function formatRelativeTime(iso) {
|
|
31040
31078
|
const now = Date.now();
|
|
31041
31079
|
const then = new Date(iso).getTime();
|
|
@@ -35161,15 +35199,18 @@ async function showModelPicker(ctx, local = false) {
|
|
|
35161
35199
|
const items = [];
|
|
35162
35200
|
const history = loadUsageHistory("model", ctx.repoRoot);
|
|
35163
35201
|
const liveModelNames = new Set(models.map((m) => m.name));
|
|
35202
|
+
const modelMap = new Map(models.map((m) => [m.name, m]));
|
|
35164
35203
|
if (history.length > 0) {
|
|
35165
35204
|
items.push({ key: "__header_recent__", label: c2.dim("\u2500\u2500 Recent \u2500\u2500"), detail: "" });
|
|
35166
35205
|
for (const h of history.slice(0, 8)) {
|
|
35167
35206
|
const uses = h.localUses > 0 ? `${h.useCount} uses (${h.localUses} local)` : `${h.useCount} uses`;
|
|
35168
35207
|
const available = liveModelNames.has(h.value) ? "" : c2.yellow(" [offline]");
|
|
35208
|
+
const meta = modelMap.get(h.value);
|
|
35209
|
+
const ctx2 = meta?.contextLength ? ` ${formatContextLength(meta.contextLength)}` : "";
|
|
35169
35210
|
items.push({
|
|
35170
35211
|
key: h.value,
|
|
35171
35212
|
label: h.value,
|
|
35172
|
-
detail: `${uses}${available}`
|
|
35213
|
+
detail: `${uses}${ctx2}${available}`
|
|
35173
35214
|
});
|
|
35174
35215
|
}
|
|
35175
35216
|
items.push({ key: "__header_available__", label: c2.dim("\u2500\u2500 Available \u2500\u2500"), detail: "" });
|
|
@@ -35178,10 +35219,11 @@ async function showModelPicker(ctx, local = false) {
|
|
|
35178
35219
|
for (const m of models) {
|
|
35179
35220
|
if (history.length > 0 && historyKeys.has(m.name))
|
|
35180
35221
|
continue;
|
|
35222
|
+
const ctx2 = m.contextLength ? formatContextLength(m.contextLength) : "";
|
|
35181
35223
|
items.push({
|
|
35182
35224
|
key: m.name,
|
|
35183
35225
|
label: m.name,
|
|
35184
|
-
detail: [m.parameterSize, m.size, m.modified].filter(Boolean).join(" ")
|
|
35226
|
+
detail: [m.parameterSize, ctx2, m.size, m.modified].filter(Boolean).join(" ")
|
|
35185
35227
|
});
|
|
35186
35228
|
}
|
|
35187
35229
|
const result = await tuiSelect({
|
package/package.json
CHANGED