@turbojev/runtime-llamacpp-wasm 0.29.0 → 0.29.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/package.json +1 -1
- package/src/index.js +7 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -79,9 +79,14 @@ export async function createRuntime() {
|
|
|
79
79
|
const labels = Array.from({ length: candidates.length }, (_, i) => String.fromCharCode(65 + i));
|
|
80
80
|
const isBestMatch = String(task.intent).toLowerCase() === 'bestmatch';
|
|
81
81
|
const criterion = task.instruction || (isBestMatch ? 'Choose the option that best matches the state.' : 'Choose the correct option.');
|
|
82
|
-
const optionsText = candidates.map((candidate, i) =>
|
|
82
|
+
const optionsText = candidates.map((candidate, i) => {
|
|
83
|
+
const meaning = candidate.description && candidate.description !== candidate.key
|
|
84
|
+
? `${candidate.key}: ${candidate.description}`
|
|
85
|
+
: candidate.description || candidate.key;
|
|
86
|
+
return `${labels[i]}. ${meaning}`;
|
|
87
|
+
}).join('\n');
|
|
83
88
|
const messages = [
|
|
84
|
-
{ role: 'system', content: '
|
|
89
|
+
{ role: 'system', content: 'Apply the supplied criterion to the supplied evidence. Choose exactly one listed option. Respond only with its listed letter, with no explanation or reasoning.' },
|
|
85
90
|
{ role: 'user', content: `State:\n${typeof batch.state === 'string' ? batch.state : JSON.stringify(batch.state)}\n\nQuestion:\n${criterion}\n\nAllowed options:\n${optionsText}\n\nReply with exactly one option letter: ${labels.join(', ')}.` },
|
|
86
91
|
];
|
|
87
92
|
const grammar = `root ::= ${labels.map(label => `"${label}"`).join(' | ')}`;
|