wingbot 3.76.4-alpha.12 → 3.76.4-alpha.13
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/LLM.js +17 -6
- package/src/testTools/PromptAssert.js +3 -2
package/package.json
CHANGED
package/src/LLM.js
CHANGED
|
@@ -158,11 +158,12 @@ const LLMSession = require('./LLMSession');
|
|
|
158
158
|
/**
|
|
159
159
|
* @typedef {object} PromptInfo
|
|
160
160
|
* @prop {LLMMessage[]} prompt
|
|
161
|
-
* @prop {LLMMessage} result
|
|
161
|
+
* @prop {LLMMessage|null} result
|
|
162
162
|
* @prop {VectorSearchResult} [vectorSearchResult]
|
|
163
163
|
* @prop {ToolFunction[]} [tools]
|
|
164
164
|
* @prop {number} [durationMs]
|
|
165
165
|
* @prop {LLMCallOptions} [options]
|
|
166
|
+
* @prop {string} [error]
|
|
166
167
|
*/
|
|
167
168
|
|
|
168
169
|
/**
|
|
@@ -429,7 +430,13 @@ class LLM {
|
|
|
429
430
|
const opts = this.llmOptions(preset);
|
|
430
431
|
const prompt = await session.toArray(true);
|
|
431
432
|
const startTime = Date.now();
|
|
432
|
-
|
|
433
|
+
let result = null;
|
|
434
|
+
let error = null;
|
|
435
|
+
try {
|
|
436
|
+
result = await this._provider.requestChat(prompt, opts, session.tools);
|
|
437
|
+
} catch (e) {
|
|
438
|
+
error = e;
|
|
439
|
+
}
|
|
433
440
|
const durationMs = Date.now() - startTime;
|
|
434
441
|
this.logPrompt(
|
|
435
442
|
prompt,
|
|
@@ -437,21 +444,24 @@ class LLM {
|
|
|
437
444
|
logOptions.vectorSearchResult,
|
|
438
445
|
session.tools,
|
|
439
446
|
durationMs,
|
|
440
|
-
opts
|
|
447
|
+
opts,
|
|
448
|
+
error
|
|
441
449
|
);
|
|
450
|
+
if (error) throw error;
|
|
442
451
|
return result;
|
|
443
452
|
}
|
|
444
453
|
|
|
445
454
|
/**
|
|
446
455
|
*
|
|
447
456
|
* @param {LLMMessage[]} prompt
|
|
448
|
-
* @param {LLMMessage} result
|
|
457
|
+
* @param {LLMMessage|null} result
|
|
449
458
|
* @param {VectorSearchResult} [vectorSearchResult]
|
|
450
459
|
* @param {ToolFunction[]} [tools]
|
|
451
460
|
* @param {number} [durationMs]
|
|
452
461
|
* @param {LLMCallOptions} [options]
|
|
462
|
+
* @param {Error} [error]
|
|
453
463
|
*/
|
|
454
|
-
logPrompt (prompt, result, vectorSearchResult, tools, durationMs, options) {
|
|
464
|
+
logPrompt (prompt, result, vectorSearchResult, tools, durationMs, options, error) {
|
|
455
465
|
this._lastResult = result;
|
|
456
466
|
this._configuration.logger.logPrompt({
|
|
457
467
|
prompt,
|
|
@@ -459,7 +469,8 @@ class LLM {
|
|
|
459
469
|
vectorSearchResult,
|
|
460
470
|
tools,
|
|
461
471
|
durationMs,
|
|
462
|
-
...(options != null && { options })
|
|
472
|
+
...(options != null && { options }),
|
|
473
|
+
...(error != null && { error: error?.message || String(error) })
|
|
463
474
|
});
|
|
464
475
|
}
|
|
465
476
|
|
|
@@ -88,7 +88,8 @@ class PromptAssert {
|
|
|
88
88
|
*/
|
|
89
89
|
_flatResults () {
|
|
90
90
|
return this._prompts
|
|
91
|
-
.map((prompt) => prompt.result)
|
|
91
|
+
.map((prompt) => prompt.result)
|
|
92
|
+
.filter(Boolean);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
/**
|
|
@@ -190,7 +191,7 @@ class PromptAssert {
|
|
|
190
191
|
return [
|
|
191
192
|
`${i + 1}) ${PromptAssert.promptStats(p.prompt)}`,
|
|
192
193
|
`${prompt.join('\n ')}`,
|
|
193
|
-
`# ${PromptAssert._content(p.result)}`
|
|
194
|
+
`# ${p.result ? PromptAssert._content(p.result) : `[ERROR] ${p.error || 'unknown'}`}`
|
|
194
195
|
].join('\n ');
|
|
195
196
|
});
|
|
196
197
|
}
|