booths 2.0.0-3 → 2.0.0-4
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/dist/index.cjs +45 -45
- package/dist/index.d.ts +3 -3
- package/dist/index.js +7 -10
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -640,7 +640,7 @@ export declare class ConversationHistoryPlugin implements BoothPlugin {
|
|
|
640
640
|
* @param {RepositoryUtilities} utilities - An object providing access to repository utilities and LLM adapter.
|
|
641
641
|
* @return {Promise<string>} A promise that resolves to the summarized text of the conversation.
|
|
642
642
|
*/
|
|
643
|
-
private
|
|
643
|
+
private summarizeConversation;
|
|
644
644
|
/**
|
|
645
645
|
* Cleans out resolved function calls from the provided history and returns
|
|
646
646
|
* only the unresolved function calls.
|
|
@@ -663,8 +663,8 @@ export declare class ConversationHistoryPlugin implements BoothPlugin {
|
|
|
663
663
|
* Constructs a new instance with an optional session history.
|
|
664
664
|
*
|
|
665
665
|
* @param {ResponseInput[]} [sessionHistory=[]] - An array representing the session history. Defaults to an empty array if not provided.
|
|
666
|
-
* @param onCompactStart
|
|
667
|
-
* @param onCompactEnd
|
|
666
|
+
* @param onCompactStart - Called when the conversation history is about to be compacted.
|
|
667
|
+
* @param onCompactEnd - Called when the conversation history has been compacted.
|
|
668
668
|
* @param tokenCompactionThreshold
|
|
669
669
|
*/
|
|
670
670
|
constructor(sessionHistory?: ResponseInput, onCompactStart?: () => void, onCompactEnd?: () => void, tokenCompactionThreshold?: number);
|
package/dist/index.js
CHANGED
|
@@ -422,12 +422,10 @@ class zft {
|
|
|
422
422
|
* @private
|
|
423
423
|
*/
|
|
424
424
|
createErrorResponse(dt, nn) {
|
|
425
|
-
const ln = dt instanceof Error ? dt.message : "Unknown error occurred while calling LLM",
|
|
426
|
-
code: "server_error",
|
|
425
|
+
const ln = dt instanceof Error ? dt.message : "Unknown error occurred while calling LLM", ti = {
|
|
426
|
+
code: dt instanceof Error && "code" in dt && typeof dt.code == "string" ? dt.code : "server_error",
|
|
427
427
|
message: ln
|
|
428
428
|
};
|
|
429
|
-
if (In && (ti.code = In), nn.model === void 0)
|
|
430
|
-
throw new Error("Model must be specified in response parameters for error handling.");
|
|
431
429
|
return {
|
|
432
430
|
id: `error_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
433
431
|
created_at: Math.floor(Date.now() / 1e3),
|
|
@@ -436,7 +434,7 @@ class zft {
|
|
|
436
434
|
incomplete_details: null,
|
|
437
435
|
instructions: null,
|
|
438
436
|
metadata: null,
|
|
439
|
-
model: nn.model,
|
|
437
|
+
model: nn.model ?? "unknown",
|
|
440
438
|
object: "response",
|
|
441
439
|
output: [
|
|
442
440
|
{
|
|
@@ -844,8 +842,8 @@ class Uft {
|
|
|
844
842
|
* Constructs a new instance with an optional session history.
|
|
845
843
|
*
|
|
846
844
|
* @param {ResponseInput[]} [sessionHistory=[]] - An array representing the session history. Defaults to an empty array if not provided.
|
|
847
|
-
* @param onCompactStart
|
|
848
|
-
* @param onCompactEnd
|
|
845
|
+
* @param onCompactStart - Called when the conversation history is about to be compacted.
|
|
846
|
+
* @param onCompactEnd - Called when the conversation history has been compacted.
|
|
849
847
|
* @param tokenCompactionThreshold
|
|
850
848
|
*/
|
|
851
849
|
constructor(dt = [], nn = () => {
|
|
@@ -904,7 +902,7 @@ class Uft {
|
|
|
904
902
|
* @param {RepositoryUtilities} utilities - An object providing access to repository utilities and LLM adapter.
|
|
905
903
|
* @return {Promise<string>} A promise that resolves to the summarized text of the conversation.
|
|
906
904
|
*/
|
|
907
|
-
async
|
|
905
|
+
async summarizeConversation(dt) {
|
|
908
906
|
const nn = Yft(dt.llmAdapter, Wft), ln = JSON.stringify(this.sessionHistory), In = `${this.compactInstructions}
|
|
909
907
|
|
|
910
908
|
The conversation History:
|
|
@@ -998,12 +996,11 @@ ${ln}`.trim(), ys = (await nn.callProcessor.send(In)).output.find((ga) => ga.typ
|
|
|
998
996
|
*/
|
|
999
997
|
async onResponseReceived(dt, nn, ln) {
|
|
1000
998
|
let ti = [...nn.input, ...ln?.output ?? []];
|
|
1001
|
-
debugger;
|
|
1002
999
|
if (this.shouldCompactHistory(ln)) {
|
|
1003
1000
|
this.onCompactStart();
|
|
1004
1001
|
const fa = {
|
|
1005
1002
|
role: "developer",
|
|
1006
|
-
content: `A conversation summary up to this point: ${await this.
|
|
1003
|
+
content: `A conversation summary up to this point: ${await this.summarizeConversation(dt)}`
|
|
1007
1004
|
}, ga = this.cleanOutResolvedFunctionCalls(ti);
|
|
1008
1005
|
ti = this.rebuildHistory(ti, ga, fa), this.onCompactEnd();
|
|
1009
1006
|
} else
|