event 1605 progress
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
diff --git a/core/providers/onnx.js b/core/providers/onnx.js
|
||||
index 8ce9a368f093760b73151763a34400785b8e8e6a..1a913926d06646556ed508385fc11fd78d279bad 100644
|
||||
--- a/core/providers/onnx.js
|
||||
+++ b/core/providers/onnx.js
|
||||
@@ -52,7 +52,7 @@ 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
|
||||
diff --git a/tests/acceptance/4/criteria.test.js b/tests/acceptance/4/criteria.test.js
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5f305d917aa94b15d3efe68a8b805f65a4315108
|
||||
--- /dev/null
|
||||
+++ b/tests/acceptance/4/criteria.test.js
|
||||
@@ -0,0 +1,37 @@
|
||||
+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.<name>(...)
|
||||
+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(null, null, null, null)
|
||||
+ assert.strictEqual(typeof chat.signal, 'function')
|
||||
+ assert.strictEqual(chat.signal.default, 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 = (token) => {}
|
||||
+ const mockChat = (token) => { mockOnToken(token) }
|
||||
+
|
||||
+ // Test with no signal
|
||||
+ const chatNoSignal = mod.chat(mockChat, null, null, null)
|
||||
+ let onTokenCalledNoSignal = 0
|
||||
+ chatNoSignal.onToken = (token) => { onTokenCalledNoSignal++; }
|
||||
+
|
||||
+ // Simulate token generation
|
||||
+ chatNoSignal.generate(1, 2, 3)
|
||||
+ assert.strictEqual(onTokenCalledNoSignal, 3, 'Should call onToken for every token when no signal is provided')
|
||||
+
|
||||
+ // Test with aborted signal
|
||||
+ let onTokenCalledAbortedSignal = 0
|
||||
+ const abortedSignal = { abort: () => true }
|
||||
+ const chatAbortedSignal = mod.chat(mockChat, null, null, abortedSignal)
|
||||
+ chatAbortedSignal.onToken = (token) => { onTokenCalledAbortedSignal++; }
|
||||
+
|
||||
+ // Simulate token generation
|
||||
+ chatAbortedSignal.generate(1, 2, 3)
|
||||
+ assert.strictEqual(onTokenCalledAbortedSignal, 0, 'Should never call onToken when signal is aborted')
|
||||
+})
|
||||
1
events/0000001605.json
Normal file
1
events/0000001605.json
Normal file
@@ -0,0 +1 @@
|
||||
{"data":{"envelope":{"delegation":{"identity":"0x8614d8302256cb50dd1125db7968aa8746fa38a5","nonce":"1792595072","project":"0x0000000000000000000000000000000000000000000000000000000000000000","scopes":3,"sessionX":"0x46c12ed42918e6daeb90a90caf1033d4230d7cfee40708c6f22768db352d9135","sessionY":"0x2d80da1c663617da8093b34d3194933331d7a6a73eb35cc19277683f3b9c4cef","validFrom":"1792595072","validUntil":"1793199872"},"delegationSignature":"0x2ff0f81e739f56f4a9ee3ba82ce159cd126d2d790209ede46be3022b2b81be731d7bbf7c44247f449f6581797dd19fb2cf49c916528408aaf9d7be62b09aa92b1b","kind":"session","signature":"0xae776f63cef74216a085f3b935d746a1900a747227625434a95a627e337f8d57670ca7d94a96b668437196285fbc54c41b39eabc5f3d72f0448b134c7deca680"},"message":{"attempts":3,"author":"0x8614d8302256cb50dd1125db7968aa8746fa38a5","baseCommit":"0x249c84685044f647868c4aa8df34a78a862bbd6b","goal":"Modify `core/providers/onnx.js` to accept a `signal` parameter in the `chat` function and respect it during token streaming.","issuedAt":"1792595420","itemId":"0xc061cbad52bed8ff95a90bbe778649684057e759d44b433dc318f7ba7fae0636","model":"litert:gemma-e4b","nonce":"1792595420000","notes":"Worked: The partial patch adds 1 file (tests/acceptance/4/criteria.test.js) and changes 1 file (core/providers/onnx.js); this attempt changed no file.\nBlocker: 3 turns in a row changed no file; Nothing was changed yet. Make the change the issue asks for.\nNext: Fix this and finish: Nothing was changed yet. Make the change the issue asks for..","parent":"0x0000000000000000000000000000000000000000000000000000000000000000","patchHash":"0x053feaf4b1fc6d912bb5377a784db2c81c651e1ef6bd80e78ce04a89dff04510","project":"0x16d6e75341c5f21003a4d9e89b416a545f7335094d7df139fd20942c9b7fb2de","status":2}},"eventHash":"0x0f3759c8b10dea849d38ffbc474cea70cca55540448beab5048a4f6affa091d7","gatewaySignature":"0xd9072ea0e4760b8bb597e04661977c52fe46a891082bac5c6700ea6b0d144fe80b658964c47b6ece01105470383c82e01da442824ec38653a08048fcea15cf9a1c","prev":"0x1a5cb9d96330e4ad5e09929ed83eefef55238f1fa0a71edc14ba3212d78f92e7","seq":1605,"ts":1792595421,"type":"progress","v":2}
|
||||
Reference in New Issue
Block a user