fix(openai): prompt engineering and transcript model

This commit is contained in:
amirhosein mazaheri
2026-10-11 17:28:22 +03:30
parent 21a0ea076a
commit f14166a89f
35 changed files with 12882 additions and 46 deletions
+24
View File
@@ -0,0 +1,24 @@
import fs from 'node:fs';
import assert from 'node:assert/strict';
const source = fs.readFileSync(new URL('../../examples/voice-transcripts.js', import.meta.url), 'utf8');
const {VoiceTranscripts} = await import('data:text/javascript;base64,' + Buffer.from(source).toString('base64'));
const display = new VoiceTranscripts();
const event = (turn_ref, role, text, status='partial') => ({type:'transcript',turn_ref,role,text,status});
assert.equal(display.apply(event('t1','user','نه ')).text, 'نه ');
assert.equal(display.apply(event('t1','user','نه ')).text, 'نه نه ');
display.apply(event('t2','user','بعدی'));
assert.equal(display.apply(event('t1','user','نه نه، فردا','completed')).text,'نه نه، فردا');
assert.equal(display.rows.get('t2:user').text,'بعدی');
assert.equal(display.apply(event('t1','user','نه نه، فردا','completed')).text,'نه نه، فردا');
assert.throws(()=>display.apply(event('t1','user','late')),/AFTER_COMPLETION/);
display.apply(event('t3','assistant','پاسخ'));
assert.equal(display.apply({type:'turn_interrupted',turn_ref:'t3'}).status,'interrupted');
assert.equal(display.apply(event('t3','assistant','late','completed')).text,'پاسخ');
display.apply(event('t3','user','اصل','completed'));
assert.equal(display.rows.get('t3:user').status,'completed');
display.apply({type:'turn_interrupted',turn_ref:'t4'});
assert.equal(display.apply(event('t4','assistant','late','completed')).text,'');
assert.throws(()=>display.apply({...event('t5','user','x'),text:7}),/INVALID/);
display.reset(); assert.equal(display.rows.size,0);
for(let n=0;n<512;n++) display.apply(event('t'+n,'user','x'));
assert.throws(()=>display.apply(event('overflow','user','x')),/CAPACITY/);