mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
feat: share the tool catalog with voice
This commit is contained in:
1 parent
0953ebb026
commit
1a03e7483d
19 files changed
+288
-15
No files matched your search
@@ -31,6 +31,7 @@ import {
|
||||
readStoredVoiceLimits,
|
||||
writeStoredVoiceTier,
|
||||
writeStoredVoiceLimits,
|
||||
withToolCatalog,
|
||||
} from './gevRealtime.js';
|
||||
import { createVoiceCostTracker } from './voiceCost.js';
|
||||
|
||||
@@ -3681,3 +3682,43 @@ test('a genuinely different refused call still gets its own output', async () =>
|
||||
const testPlaceSearch = () => createStandalonePlaceSearch({ resolveApiKey: () => globalThis.window?.__GOOGLE_MAPS_API_KEY__ });
|
||||
function createGevActionRunner(options) { return createActionRunner({ placeSearch: testPlaceSearch(), ...options }); }
|
||||
function controlRadio(viewer, manager, args, options) { return runControlRadio(viewer, manager, args, { placeSearch: testPlaceSearch(), ...options }); }
|
||||
|
||||
test('voice runs app actions itself and other tools through the catalog', async () => {
|
||||
const actions = [];
|
||||
const runner = async (name, args) => {
|
||||
actions.push([name, args]);
|
||||
return { ok: true, action: name };
|
||||
};
|
||||
const calls = [];
|
||||
let loads = 0;
|
||||
const catalog = {
|
||||
get: (name) => (name === 'get_wind' ? { name } : undefined),
|
||||
async call(name, args, options) {
|
||||
calls.push([name, args, options.signal]);
|
||||
return { summary: 'Calm.', data: { calm: true } };
|
||||
},
|
||||
};
|
||||
const run = withToolCatalog(runner, async () => {
|
||||
loads += 1;
|
||||
return catalog;
|
||||
});
|
||||
const signal = new AbortController().signal;
|
||||
assert.deepEqual(await run('zoom_to_globe', {}), {
|
||||
ok: true,
|
||||
action: 'zoom_to_globe',
|
||||
});
|
||||
assert.equal(loads, 0);
|
||||
assert.deepEqual(
|
||||
await run('get_wind', { location: { place: 'Oslo' } }, { signal }),
|
||||
{ ok: true, tool: 'get_wind', summary: 'Calm.', data: { calm: true } },
|
||||
);
|
||||
assert.deepEqual(calls, [
|
||||
['get_wind', { location: { place: 'Oslo' } }, signal],
|
||||
]);
|
||||
await run('not_a_tool', {});
|
||||
assert.deepEqual(
|
||||
actions.map(([name]) => name),
|
||||
['zoom_to_globe', 'not_a_tool'],
|
||||
);
|
||||
assert.equal(withToolCatalog(runner, undefined), runner);
|
||||
});
|
||||
Reference in new issue
Block a user