clavarium 0.2.273-next.1 → 0.2.274-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/boxes.mjs +13 -6
- package/server/talk.mjs +1 -1
- package/server/voice.mjs +4 -2
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.274-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.274-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/boxes.mjs
CHANGED
|
@@ -134,7 +134,9 @@ export function sentencesOf(text) {
|
|
|
134
134
|
|
|
135
135
|
/* The words said while an answer is awaited (« Hmm… », « ça prend plus de temps ») -- off (01-11: heard all
|
|
136
136
|
the time while the box misheard, they made it worse; back once the sound path is sound). */
|
|
137
|
-
|
|
137
|
+
/* 03-11: on again, but only the sentence made for THIS request (never a stock phrase), and only when the agent has
|
|
138
|
+
said nothing within THINKING_AFTER_MS. */
|
|
139
|
+
export const WAITING_WORDS = true;
|
|
138
140
|
/* WHAT THE BOX MEASURED, its sentence ended (firmware 0.1.38): how long, when a voice was heard, the bar it
|
|
139
141
|
used -- beside the message, with what reached this side. */
|
|
140
142
|
export function endOf(ep, reason = '') {
|
|
@@ -151,7 +153,7 @@ export function endOf(ep, reason = '') {
|
|
|
151
153
|
return parts.join(' · ');
|
|
152
154
|
}
|
|
153
155
|
/* 02-11: the light turning says it is at work; a word only when it really takes long. */
|
|
154
|
-
export const THINKING_AFTER_MS =
|
|
156
|
+
export const THINKING_AFTER_MS = 5_000;
|
|
155
157
|
export const LONGER_AFTER_MS = 12_000;
|
|
156
158
|
export const THINKING = ['Hmm…', 'Voyons…', 'Hmm, voyons voir…'];
|
|
157
159
|
/* WHY A BOX LISTENED, in a few words beside the message (01-11): what woke it (and the wake word's score), and
|
|
@@ -524,7 +526,7 @@ export class Boxes {
|
|
|
524
526
|
/* Made at once, used if the answer is still not there: a reaction to THIS sentence, in its language. */
|
|
525
527
|
let made = null;
|
|
526
528
|
this.#react(text).then((t) => { made = t; }).catch(() => {});
|
|
527
|
-
link.thinkingA = setTimeout(() => {
|
|
529
|
+
link.thinkingA = setTimeout(() => { if (made) void say(made); }, THINKING_AFTER_MS);
|
|
528
530
|
/* One word of waiting, not two (02-11: « je regarde, un instant » again and again). */
|
|
529
531
|
link.thinkingA.unref?.();
|
|
530
532
|
}
|
|
@@ -535,10 +537,13 @@ export class Boxes {
|
|
|
535
537
|
const plain = forSpeech(text);
|
|
536
538
|
/* 02-11: not even « Je regarde, un instant » in its place -- said each time the agent wrote what it does, it
|
|
537
539
|
came back again and again. A long or technical one is not said at all. */
|
|
538
|
-
|
|
540
|
+
/* Sent to a box on purpose (03-11: "dis au plus tôt ce que tu vas faire"): said as it is written. */
|
|
541
|
+
const aimed = doing && Array.isArray(to) && to.length > 0;
|
|
542
|
+
const words = doing && !aimed && (plain.length > 70 || /[\d:;/()[\]→=_]/.test(plain)) ? '' : plain;
|
|
539
543
|
if (!words) return;
|
|
540
544
|
let boxes;
|
|
541
|
-
if (
|
|
545
|
+
if (aimed) boxes = [...this.#links.values()].filter((l) => l.box().conversation === conversation && to.includes(l.box().id));
|
|
546
|
+
else if (doing) {
|
|
542
547
|
/* "I'm looking in the calendar": once per sentence heard, on the box that heard it, within two minutes. */
|
|
543
548
|
/* 02-11: what it really does, in its words (« je regarde dans ton agenda »); never a stock phrase. */
|
|
544
549
|
boxes = [...this.#links.values()].filter((l) => l.box().conversation === conversation && l.heardAt && !l.doingSaid && this.#now() - l.heardAt < DOING_WITHIN_MS);
|
|
@@ -570,7 +575,9 @@ export class Boxes {
|
|
|
570
575
|
let pcm;
|
|
571
576
|
try { pcm = await next; } catch (error) { this.#log(`voice box: no voice for the answer (${error.message})`); l.send({ t: 'cue', name: 'error' }); break; }
|
|
572
577
|
if (i + 1 < parts.length) { next = this.#speak(parts[i + 1]); next.catch(() => {}); }
|
|
573
|
-
|
|
578
|
+
/* Listened after only when what it says calls for an answer (03-11: "en fonction de la réponse"): the
|
|
579
|
+
agent says so by asking (parley ask), not the box by guessing. */
|
|
580
|
+
l.play(pcm, i + 1 === parts.length && (question || chatting) ? 'listen' : null);
|
|
574
581
|
}
|
|
575
582
|
}
|
|
576
583
|
}
|
package/server/talk.mjs
CHANGED
|
@@ -294,7 +294,7 @@ export class Talk {
|
|
|
294
294
|
/* What the tool says or asks: a voice box of this conversation may read it aloud (boxes.mjs). */
|
|
295
295
|
if (event.type === 'agent-said' || event.type === 'agent-asked') this.#spoke(name, event.message?.text ?? '', Array.isArray(event.message?.to) ? event.message.to : null, { asked: event.type === 'agent-asked' });
|
|
296
296
|
/* What it is doing: said by a box that was just spoken to, so nobody waits in silence. */
|
|
297
|
-
if (event.type === 'agent-doing') this.#spoke(name, event.message?.text ?? '', null, { doing: true });
|
|
297
|
+
if (event.type === 'agent-doing') this.#spoke(name, event.message?.text ?? '', Array.isArray(event.message?.to) ? event.message.to : null, { doing: true });
|
|
298
298
|
const words = texts(this.#lastLang, this.settings().own);
|
|
299
299
|
if (event.type === 'agent-asked') this.#alert({ title: fill(words['alert-asks'], { name }), body: event.message.text ?? '', url: `/?c=${name}` });
|
|
300
300
|
if (event.type === 'agent-status' && event.message.state === 'waiting') this.#alert({ title: fill(words['alert-waits'], { name }), body: event.message.text ?? '', url: `/?c=${name}` });
|
package/server/voice.mjs
CHANGED
|
@@ -229,8 +229,10 @@ export async function quickReaction(config, said, fetcher = fetch) {
|
|
|
229
229
|
try {
|
|
230
230
|
const r = await fetcher(`${base}/chat/completions`, {
|
|
231
231
|
method: 'POST', redirect: 'error', headers: { 'content-type': 'application/json', authorization: `Bearer ${config.key}` }, signal: AbortSignal.timeout(3000),
|
|
232
|
-
body: JSON.stringify({ model: REACTION_MODEL, temperature: 0.8, max_tokens:
|
|
233
|
-
|
|
232
|
+
body: JSON.stringify({ model: REACTION_MODEL, temperature: 0.8, max_tokens: 40, messages: [
|
|
233
|
+
/* 03-11: what it is going to do, in context, with a little life ("je fouille dans tes mails, je reviens vers
|
|
234
|
+
toi"), never the same stock phrase. */
|
|
235
|
+
{ role: 'system', content: 'Someone just spoke to a voice assistant, which needs some time to answer. Write ONE short spoken sentence (4 to 14 words) in the SAME language as what they said, saying what the assistant is now going to do for THIS request, warm and a little playful, never the same wording twice: e.g. "Je fouille dans tes mails, je reviens vers toi.", "Je jette un œil à ton agenda de demain.", "Let me dig through your files for that.". Never answer the question itself, never invent a result, never promise a time. No quotes, no emoji. Answer with the sentence only.' },
|
|
234
236
|
{ role: 'user', content: String(said).slice(0, 600) }] }),
|
|
235
237
|
});
|
|
236
238
|
if (!r.ok) return null;
|