openvibers/openvibe.bot Commits
With two or more machines whose models your AI may use, "Use these models in OpenVibe.Chat" chooses any of them (machine=any) (#197)
Changes
@@@ -750,6 +750,8 @@ function renderMachinesPage({ machines = [], pairing = null }) {const kinds = browser && whole ? `${d.max} at once, or twice as many browser desks` : browser ? `${d.max * 2} browser desks at once` : `${d.max} at once`;return `Desks for your agents: ${kinds}${d.keeps ? ', sign-ins kept' : ''}`;};++ // The person's machines whose models their AI may use: with two or more, Chat's link chooses any of them.++ const modelMachines = machines.filter((x) => { const c = x.ai_models && computerOf(x); return !!(c && c.ai && c.ai.models.length); }).length;const computerRow = (m) => {const c = computerOf(m);if (!c) return '';@@@ -760,7 +762,8 @@ function renderMachinesPage({ machines = [], pairing = null }) {+ `<form method="post" action="/machines/${esc(m.id)}/ai-models"><input type="hidden" name="on" value="${m.ai_models ? '0' : '1'}">`+ `<button type="submit" class="button quiet" aria-pressed="${m.ai_models ? 'true' : 'false'}">${m.ai_models ? 'Stop my AI using this computer\'s models' : 'Let my AI use this computer\'s models'}</button></form>`// Turned on: OpenVibe.Chat's "Your AI key" comes filled in with this computer and its first model (saved only there).-- + (m.ai_models && c.ai.models.length ? `<a class="button quiet" href="https://openvibe.chat/settings?own=node&machine=${encodeURIComponent(m.id)}&model=${encodeURIComponent(c.ai.models[0])}#oc-ai-key">Use these models in OpenVibe.Chat</a>` : '')++ // With several such machines, any of them (contracts 0.221.0): the fastest that is on answers.++ + (m.ai_models && c.ai.models.length ? `<a class="button quiet" href="https://openvibe.chat/settings?own=node&machine=${modelMachines > 1 ? 'any' : encodeURIComponent(m.id)}&model=${encodeURIComponent(c.ai.models[0])}#oc-ai-key">Use these models in OpenVibe.Chat</a>` : '')+ '</div>' : '';// A machine that offers only its models (the ai plugin, no computer plugin): just them.if (!c.on) return `<div class="machine-computer">${aiRow}</div>`;@@@ -454,6 +454,12 @@ const { boot, check, done } = require('./helpers/app');}assert.ok(ownCard.includes('qwen2.5-1.5b-instruct'), 'the card shows its models');assert.ok(ownCard.includes('about 15 tokens a second'), 'and how fast they answer there');++ // Two machines whose models the owner's AI may use (gpu, switched on below, and this one once on): any of them.++ await t.call('POST', `/api/v1/machines/${own.deviceId}/ai-models`, { user: alex, body: { on: true } });++ await t.call('POST', `/api/v1/machines/${gpu.deviceId}/ai-models`, { user: alex, body: { on: true } });++ const both = await (await fetch(`${t.base}/machines`, { headers: cookie(alex) })).text();++ assert.ok(both.includes('settings?own=node&machine=any&model='), 'with two, the link chooses any of them');++ await t.call('POST', `/api/v1/machines/${own.deviceId}/ai-models`, { user: alex, body: { on: false } });own.c.close();// The machines page: its models and the switch.const html = await (await fetch(`${t.base}/machines`, { headers: cookie(alex) })).text();
@@ -750,6 +750,8 @@ function renderMachinesPage({ machines = [], pairing = null }) {
@@ -750,6 +750,8 @@ function renderMachinesPage({ machines = [], pairing = null }) {
const kinds = browser && whole ? `${d.max} at once, or twice as many browser desks` : browser ? `${d.max * 2} browser desks at once` : `${d.max} at once`;
const kinds = browser && whole ? `${d.max} at once, or twice as many browser desks` : browser ? `${d.max * 2} browser desks at once` : `${d.max} at once`;
return `Desks for your agents: ${kinds}${d.keeps ? ', sign-ins kept' : ''}`;
return `Desks for your agents: ${kinds}${d.keeps ? ', sign-ins kept' : ''}`;
};
};
+ // The person's machines whose models their AI may use: with two or more, Chat's link chooses any of them.
+ const modelMachines = machines.filter((x) => { const c = x.ai_models && computerOf(x); return !!(c && c.ai && c.ai.models.length); }).length;
const computerRow = (m) => {
const computerRow = (m) => {
const c = computerOf(m);
const c = computerOf(m);
if (!c) return '';
if (!c) return '';
@@ -760,7 +762,8 @@ function renderMachinesPage({ machines = [], pairing = null }) {
@@ -760,7 +762,8 @@ function renderMachinesPage({ machines = [], pairing = null }) {
+ `<form method="post" action="/machines/${esc(m.id)}/ai-models"><input type="hidden" name="on" value="${m.ai_models ? '0' : '1'}">`
+ `<form method="post" action="/machines/${esc(m.id)}/ai-models"><input type="hidden" name="on" value="${m.ai_models ? '0' : '1'}">`
+ `<button type="submit" class="button quiet" aria-pressed="${m.ai_models ? 'true' : 'false'}">${m.ai_models ? 'Stop my AI using this computer\'s models' : 'Let my AI use this computer\'s models'}</button></form>`
+ `<button type="submit" class="button quiet" aria-pressed="${m.ai_models ? 'true' : 'false'}">${m.ai_models ? 'Stop my AI using this computer\'s models' : 'Let my AI use this computer\'s models'}</button></form>`
// Turned on: OpenVibe.Chat's "Your AI key" comes filled in with this computer and its first model (saved only there).
// Turned on: OpenVibe.Chat's "Your AI key" comes filled in with this computer and its first model (saved only there).
- + (m.ai_models && c.ai.models.length ? `<a class="button quiet" href="https://openvibe.chat/settings?own=node&machine=${encodeURIComponent(m.id)}&model=${encodeURIComponent(c.ai.models[0])}#oc-ai-key">Use these models in OpenVibe.Chat</a>` : '')
+ // With several such machines, any of them (contracts 0.221.0): the fastest that is on answers.
+ + (m.ai_models && c.ai.models.length ? `<a class="button quiet" href="https://openvibe.chat/settings?own=node&machine=${modelMachines > 1 ? 'any' : encodeURIComponent(m.id)}&model=${encodeURIComponent(c.ai.models[0])}#oc-ai-key">Use these models in OpenVibe.Chat</a>` : '')
+ '</div>' : '';
+ '</div>' : '';
// A machine that offers only its models (the ai plugin, no computer plugin): just them.
// A machine that offers only its models (the ai plugin, no computer plugin): just them.
if (!c.on) return `<div class="machine-computer">${aiRow}</div>`;
if (!c.on) return `<div class="machine-computer">${aiRow}</div>`;
@@ -454,6 +454,12 @@ const { boot, check, done } = require('./helpers/app');
@@ -454,6 +454,12 @@ const { boot, check, done } = require('./helpers/app');
}
}
assert.ok(ownCard.includes('qwen2.5-1.5b-instruct'), 'the card shows its models');
assert.ok(ownCard.includes('qwen2.5-1.5b-instruct'), 'the card shows its models');
assert.ok(ownCard.includes('about 15 tokens a second'), 'and how fast they answer there');
assert.ok(ownCard.includes('about 15 tokens a second'), 'and how fast they answer there');
+ // Two machines whose models the owner's AI may use (gpu, switched on below, and this one once on): any of them.
+ await t.call('POST', `/api/v1/machines/${own.deviceId}/ai-models`, { user: alex, body: { on: true } });
+ await t.call('POST', `/api/v1/machines/${gpu.deviceId}/ai-models`, { user: alex, body: { on: true } });
+ const both = await (await fetch(`${t.base}/machines`, { headers: cookie(alex) })).text();
+ assert.ok(both.includes('settings?own=node&machine=any&model='), 'with two, the link chooses any of them');
+ await t.call('POST', `/api/v1/machines/${own.deviceId}/ai-models`, { user: alex, body: { on: false } });
own.c.close();
own.c.close();
// The machines page: its models and the switch.
// The machines page: its models and the switch.
const html = await (await fetch(`${t.base}/machines`, { headers: cookie(alex) })).text();
const html = await (await fetch(`${t.base}/machines`, { headers: cookie(alex) })).text();