Improve voice turns, local commands and Spotify controls
This commit is contained in:
@@ -40,6 +40,9 @@ test('settings and bounded history survive a restart', t => {
|
||||
assert.equal(reopened.getSettings().sttModel, 'scribe_v2_realtime');
|
||||
assert.equal(reopened.getHistory().length, 50);
|
||||
assert.equal(reopened.getHistory()[0].user, '5');
|
||||
reopened.recordDevice({ active: true, item: { uri: 'spotify:track:test', name: 'Track' }, status: 'paused' });
|
||||
reopened.recordDevice({ connected: false });
|
||||
assert.equal(openStore(directory).getDevice().lastPlayback.item.name, 'Track');
|
||||
reopened.clearHistory();
|
||||
assert.deepEqual(openStore(directory).getHistory(), []);
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ const settings = { systemPrompt: 'test', llmModel: 'test' };
|
||||
|
||||
test('assembles fragmented calls before executing and streams text', async () => {
|
||||
requests.length = 0;
|
||||
responder = n => n === 1 ? [event({ tool_calls: [{ index: 0, id: 'call_1', type: 'function', function: { name: 'spotify_play', arguments: '{"query":"' } }] }), event({ tool_calls: [{ index: 0, function: { arguments: 'Queen"}' } }] }, 'tool_calls')] : [event({ content: 'Готово' }, 'stop')];
|
||||
responder = n => n === 1 ? [event({ content: 'Сейчас включу.', tool_calls: [{ index: 0, id: 'call_1', type: 'function', function: { name: 'spotify_play', arguments: '{"query":"' } }] }), event({ tool_calls: [{ index: 0, function: { arguments: 'Queen"}' } }] }, 'tool_calls')] : [event({ content: 'Готово' }, 'stop')];
|
||||
const calls = [], text = [];
|
||||
const answer = await streamAnswer(settings, [], 'play', new AbortController().signal, part => text.push(part), async (name, args) => { calls.push([name, args]); return { ok: true }; });
|
||||
assert.equal(answer, 'Готово'); assert.deepEqual(text, ['Готово']);
|
||||
@@ -31,6 +31,18 @@ test('assembles fragmented calls before executing and streams text', async () =>
|
||||
assert.equal(requests[1].messages.at(-1).tool_call_id, 'call_1');
|
||||
});
|
||||
|
||||
test('confirms Spotify play once without reading the volume or an old track', async () => {
|
||||
requests.length = 0;
|
||||
responder = () => [event({ content: 'Громкость 40.', tool_calls: [{ index: 0, id: 'play', function: { name: 'spotify_play', arguments: '{"query":"Aphex Twin"}' } }] }, 'tool_calls')];
|
||||
const text = [];
|
||||
const answer = await streamAnswer(settings, [], 'включи музыку', AbortSignal.timeout(2000), part => text.push(part), async () => ({
|
||||
accepted: true, status: 'pending', selection: { name: 'Aphex Twin' }, item: { name: 'Old track' }, volume: 40,
|
||||
}));
|
||||
assert.equal(answer, 'Включаю «Aphex Twin».');
|
||||
assert.deepEqual(text, [answer]);
|
||||
assert.equal(requests.length, 1);
|
||||
});
|
||||
|
||||
test('does not execute incomplete tool calls', async () => {
|
||||
requests.length = 0;
|
||||
responder = () => [event({ tool_calls: [{ index: 0, id: 'x', function: { name: 'spotify_control', arguments: '{"action":"next"}' } }] }, 'length')];
|
||||
|
||||
Reference in New Issue
Block a user