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)

OP OpenVibers committed 17 days ago · 4b9605beaa · 2 files, +10 −1

Changes

ddiff --git a/server/web/render.js b/server/web/render.js
iindex 3445db9..cca3acc 100644
---- a/server/web/render.js
++++ b/server/web/render.js
@@@ -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&amp;machine=${encodeURIComponent(m.id)}&amp;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&amp;machine=${modelMachines > 1 ? 'any' : encodeURIComponent(m.id)}&amp;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>`;
ddiff --git a/test/machine-computer.test.js b/test/machine-computer.test.js
iindex 0236a72..e462e4d 100644
---- a/test/machine-computer.test.js
++++ b/test/machine-computer.test.js
@@@ -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&amp;machine=any&amp;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();