@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +7 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turbojev/runtime-llamacpp-wasm",
3
- "version": "0.29.0",
3
+ "version": "0.29.1",
4
4
  "description": "Browser-side llama.cpp WASM decision runtime for TurboJev",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
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) => `${labels[i]}. ${candidate.description || candidate.key}`).join('\n');
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: 'Make the requested decision from the supplied state. Follow the output format exactly.' },
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(' | ')}`;