diff --git a/blobs/0x98af035f57711bbdcc3d181cc3537d31b579188966b1f46602f1206ee363fbb2 b/blobs/0x98af035f57711bbdcc3d181cc3537d31b579188966b1f46602f1206ee363fbb2 new file mode 100644 index 0000000..8ac9036 --- /dev/null +++ b/blobs/0x98af035f57711bbdcc3d181cc3537d31b579188966b1f46602f1206ee363fbb2 @@ -0,0 +1,84 @@ +diff --git a/core/providers/onnx.js b/core/providers/onnx.js +index 8ce9a368f093760b73151763a34400785b8e8e6a..030a641ebef382e947cfc1834a95383440eb0602 100644 +--- a/core/providers/onnx.js ++++ b/core/providers/onnx.js +@@ -52,18 +52,18 @@ export async function unload() { + generator = null; cargadoKey = null; + } + +-export async function chat(history, system, onToken = () => {}) { ++export async function chat(history, system, onToken = () => {}, signal = null) { + if (!generator) throw new Error('Modelo no cargado'); + // ACE-lite: eviction por relevancia. Presupuesto amplio (LFM2.5 aguanta + // contexto largo); el tope POR MENSAJE (context.js) evita que un README + // gigante dispare «Too many tokens requested». + const messages = [{ role: 'system', content: system }, ...(await packHistoryAsync(history, 5000))]; +- const streamer = new TextStreamer(generator.tokenizer, { ++ const streamer = new TextStreamer(generator.tokenizer, { signal, + skip_prompt: true, + skip_special_tokens: true, + callback_function: onToken, + }); +- const out = await generator(messages, { ++ const out = await generator(messages, { signal, + max_new_tokens: 1024, + do_sample: false, // determinista: los tool calls JSON lo agradecen + repetition_penalty: 1.1, +diff --git a/tests/acceptance/4/CRITERIA.json b/tests/acceptance/4/CRITERIA.json +new file mode 100644 +index 0000000000000000000000000000000000000000..3a97ed53aa613c00362b16b8dc06e2450176b508 +--- /dev/null ++++ b/tests/acceptance/4/CRITERIA.json +@@ -0,0 +1,18 @@ ++{ ++ "schema": "elffuss-t2t/criteria@2", ++ "issue": 4, ++ "criteria": [ ++ { ++ "index": 1, ++ "tests": [ ++ "tests/acceptance/4/criteria.test.js::criterion 1" ++ ] ++ }, ++ { ++ "index": 2, ++ "tests": [ ++ "tests/acceptance/4/criteria.test.js::criterion 2" ++ ] ++ } ++ ] ++} +diff --git a/tests/acceptance/4/criteria.test.js b/tests/acceptance/4/criteria.test.js +new file mode 100644 +index 0000000000000000000000000000000000000000..b98a05be0ba70bfb9e220bdbcc6e8bb7a66a8bae +--- /dev/null ++++ b/tests/acceptance/4/criteria.test.js +@@ -0,0 +1,28 @@ ++import { test } from 'node:test' ++import assert from 'node:assert/strict' ++import { readFileSync } from 'node:fs' ++import * as mod from '../../../core/providers/onnx.js' // the code under test: call it as mod.(...) ++const source = readFileSync(new URL('../../../core/providers/onnx.js', import.meta.url), 'utf8') // the text of core/providers/onnx.js, for a criterion about how the file is written ++ ++test('criterion 1', () => { ++ // The `chat` function of core/providers/onnx.js declares a fourth parameter named `signal` with default `null`. ++ const chat = mod.chat(1, 2, 3, null) ++ assert.strictEqual(chat.signal, null) ++}) ++ ++test('criterion 2', () => { ++ // With an aborted `signal`, `chat` never calls `onToken`, and with no `signal` it still calls `onToken` for every token. ++ const mockOnToken = assert.fn() ++ const chatWithSignal = mod.chat(1, 2, 3, { abort: true }, mockOnToken) ++ const chatWithoutSignal = mod.chat(1, 2, 3, undefined, mockOnToken) ++ ++ // Test with aborted signal ++ const resultWithSignal = chatWithSignal() ++ assert.strictEqual(resultWithSignal, undefined) ++ assert.strictEqual(mockOnToken.callCount, 0) ++ ++ // Test without signal ++ const resultWithoutSignal = chatWithoutSignal() ++ assert.strictEqual(resultWithoutSignal, undefined) ++ assert.strictEqual(mockOnToken.callCount, 1) ++}) diff --git a/events/0000001125.json b/events/0000001125.json new file mode 100644 index 0000000..cea4c82 --- /dev/null +++ b/events/0000001125.json @@ -0,0 +1 @@ +{"data":{"cites":[],"envelope":{"delegation":{"identity":"0x0a8030532dcc9532f5aa2ae21762d399f52d6f5c","nonce":"1791216499","project":"0x0000000000000000000000000000000000000000000000000000000000000000","scopes":3,"sessionX":"0x90e7dee6ca6a1c9f46601ba2479b255970cea2cb2629b84d9769581bf283313d","sessionY":"0x56ff1bf2764372fe67a33d8448c9962a918f0d942bd92c51cb158bb257acf849","validFrom":"1791216499","validUntil":"1791821299"},"delegationSignature":"0xec3de5e59e43726456fa3018a8e689d14d7285856c2f352a2a0bcef777d8794241c89c2dbc8a0deb1fefc83f57b5698b4bf37d5395f3b97850f4c3d33a50825b1b","kind":"session","signature":"0xfe8529bca8999af6c048e1dbd19ab166efeaf2efb29e933a14485f56b51959891ea532cf9d92aa2c55b1ee4020bc6d5854e7803b75c2e203d6295aea4bdf3c43"},"mainHead":null,"message":{"author":"0x0a8030532dcc9532f5aa2ae21762d399f52d6f5c","baseCommit":"0x249c84685044f647868c4aa8df34a78a862bbd6b","basePartial":"0x0000000000000000000000000000000000000000000000000000000000000000","citesHash":"0x0000000000000000000000000000000000000000000000000000000000000000","issueId":"0xc061cbad52bed8ff95a90bbe778649684057e759d44b433dc318f7ba7fae0636","issuedAt":"1791220784","lines":6,"nonce":"1791220784000","patchHash":"0x98af035f57711bbdcc3d181cc3537d31b579188966b1f46602f1206ee363fbb2","project":"0x16d6e75341c5f21003a4d9e89b416a545f7335094d7df139fd20942c9b7fb2de","repo":"0xb599aedd619c8321892f96f0446029f00f5a12bf3043c65341bbf5afe98384ed"},"pr":"elffuss/core:item/0xefacf4f7864fc9d7fe853b2773f3274179396b5563dc0d992b891e41f6c232bc"},"eventHash":"0x0deb9ae894ac7b9d96bd0d8fe488c88cf602db111065a73755b1d3062508cb05","gatewaySignature":"0xf17723ddfdfaac9f18e7bdbfcc77c8af585c8cd4f214f2226d51866d051c0e4a65521972af714442180dd601f1e50230986b7f087fce8f8be8c5841bed37b3d31b","prev":"0xd3ccaa754ad77f2bbfcbbb46e0fe88a90322f8dcf824ee070ca5c6018e089d45","seq":1125,"ts":1791220785,"type":"solution","v":2}