booths 2.0.0-1 → 2.0.0-2
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 +98 -100
- package/dist/index.d.ts +71 -1
- package/dist/index.js +16609 -16520
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -592,6 +592,9 @@ export declare class ContextProviderPlugin implements BoothPlugin {
|
|
|
592
592
|
* interaction has access to the full conversation history, enabling contextual responses.
|
|
593
593
|
*/
|
|
594
594
|
export declare class ConversationHistoryPlugin implements BoothPlugin {
|
|
595
|
+
private onCompactStart;
|
|
596
|
+
private onCompactEnd;
|
|
597
|
+
private tokenCompactionThreshold;
|
|
595
598
|
/**
|
|
596
599
|
* The sessionHistory variable stores the conversation history between the user and the booth system.
|
|
597
600
|
* It is initialized as an empty array and will be populated with messages exchanged during the interaction.
|
|
@@ -626,8 +629,11 @@ export declare class ConversationHistoryPlugin implements BoothPlugin {
|
|
|
626
629
|
* Constructs a new instance with an optional session history.
|
|
627
630
|
*
|
|
628
631
|
* @param {ResponseInput[]} [sessionHistory=[]] - An array representing the session history. Defaults to an empty array if not provided.
|
|
632
|
+
* @param onCompactStart
|
|
633
|
+
* @param onCompactEnd
|
|
634
|
+
* @param tokenCompactionThreshold
|
|
629
635
|
*/
|
|
630
|
-
constructor(sessionHistory?: ResponseInput);
|
|
636
|
+
constructor(sessionHistory?: ResponseInput, onCompactStart?: () => void, onCompactEnd?: () => void, tokenCompactionThreshold?: number);
|
|
631
637
|
/**
|
|
632
638
|
* Retrieves the session history.
|
|
633
639
|
*
|
|
@@ -648,6 +654,65 @@ export declare class ConversationHistoryPlugin implements BoothPlugin {
|
|
|
648
654
|
* Returns the plugin's description.
|
|
649
655
|
*/
|
|
650
656
|
get description(): string;
|
|
657
|
+
/**
|
|
658
|
+
* Checks if the conversation history should be compacted.
|
|
659
|
+
*
|
|
660
|
+
* @param response - The response from the LLM
|
|
661
|
+
* @returns True if compaction is needed, false otherwise
|
|
662
|
+
* @private
|
|
663
|
+
*/
|
|
664
|
+
private shouldCompactHistory;
|
|
665
|
+
/**
|
|
666
|
+
* Creates the summarization prompt for compacting conversation history.
|
|
667
|
+
*
|
|
668
|
+
* @returns The formatted summarization prompt
|
|
669
|
+
* @private
|
|
670
|
+
*/
|
|
671
|
+
private createSummarizationPrompt;
|
|
672
|
+
/**
|
|
673
|
+
* Extracts summary text from the LLM's summary response.
|
|
674
|
+
*
|
|
675
|
+
* @param summary - The output from the summarizer booth
|
|
676
|
+
* @returns The extracted summary text
|
|
677
|
+
* @private
|
|
678
|
+
*/
|
|
679
|
+
private extractSummaryText;
|
|
680
|
+
/**
|
|
681
|
+
* Finds unresolved function calls from the history.
|
|
682
|
+
* A function call is considered unresolved if it doesn't have a matching output.
|
|
683
|
+
*
|
|
684
|
+
* @param history - The conversation history to search
|
|
685
|
+
* @returns Array of unresolved function call items
|
|
686
|
+
* @private
|
|
687
|
+
*/
|
|
688
|
+
private findUnresolvedFunctionCalls;
|
|
689
|
+
/**
|
|
690
|
+
* Gets the last user message from the history.
|
|
691
|
+
*
|
|
692
|
+
* @param history - The conversation history
|
|
693
|
+
* @returns The last user message, or undefined if none exists
|
|
694
|
+
* @private
|
|
695
|
+
*/
|
|
696
|
+
private getLastUserMessage;
|
|
697
|
+
/**
|
|
698
|
+
* Builds the compacted conversation history.
|
|
699
|
+
*
|
|
700
|
+
* @param functionCalls - Unresolved function calls to include
|
|
701
|
+
* @param summaryText - The summary text from the LLM
|
|
702
|
+
* @param lastUserMessage - The last user message, if any
|
|
703
|
+
* @returns The compacted history
|
|
704
|
+
* @private
|
|
705
|
+
*/
|
|
706
|
+
private buildCompactedHistory;
|
|
707
|
+
/**
|
|
708
|
+
* Compacts the conversation history by summarizing it.
|
|
709
|
+
*
|
|
710
|
+
* @param utilities - Repository utilities for accessing the LLM adapter
|
|
711
|
+
* @param newHistory - The current full history to compact
|
|
712
|
+
* @returns The compacted history
|
|
713
|
+
* @private
|
|
714
|
+
*/
|
|
715
|
+
private compactHistory;
|
|
651
716
|
/**
|
|
652
717
|
* Executes before the interaction loop starts, adding the current user input to the
|
|
653
718
|
* conversation history and updating the response parameters with the complete history.
|
|
@@ -765,6 +830,11 @@ export declare class CoreBooth<T> {
|
|
|
765
830
|
sessionHistory?: ResponseInput;
|
|
766
831
|
endInteractionLoopMarker?: string;
|
|
767
832
|
loopLimit?: number;
|
|
833
|
+
compactOptions?: {
|
|
834
|
+
onCompactStart?: () => void;
|
|
835
|
+
onCompactEnd?: () => void;
|
|
836
|
+
tokenCompactionThreshold?: number;
|
|
837
|
+
};
|
|
768
838
|
});
|
|
769
839
|
}
|
|
770
840
|
|