booths 2.0.0-0 → 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/README.md +22 -4
- package/dist/index.cjs +98 -100
- package/dist/index.d.ts +80 -3
- package/dist/index.js +17167 -17075
- 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.
|
|
@@ -764,6 +829,12 @@ export declare class CoreBooth<T> {
|
|
|
764
829
|
llmAdapter: LLMAdapter<T>;
|
|
765
830
|
sessionHistory?: ResponseInput;
|
|
766
831
|
endInteractionLoopMarker?: string;
|
|
832
|
+
loopLimit?: number;
|
|
833
|
+
compactOptions?: {
|
|
834
|
+
onCompactStart?: () => void;
|
|
835
|
+
onCompactEnd?: () => void;
|
|
836
|
+
tokenCompactionThreshold?: number;
|
|
837
|
+
};
|
|
767
838
|
});
|
|
768
839
|
}
|
|
769
840
|
|
|
@@ -774,9 +845,15 @@ export declare class CoreBooth<T> {
|
|
|
774
845
|
*
|
|
775
846
|
* @param llmAdapter - The LLM adapter for communication with the language model.
|
|
776
847
|
* @param boothConfig - The configuration for the single booth to be used.
|
|
848
|
+
* @param options - Optional configuration for the CoreBooth instance.
|
|
849
|
+
* @param options.endInteractionLoopMarker - Custom marker to signal end of interaction loop.
|
|
850
|
+
* @param options.loopLimit - Maximum number of interaction loop iterations (default: 10).
|
|
777
851
|
* @returns A fully configured CoreBooth instance.
|
|
778
852
|
*/
|
|
779
|
-
export declare function createCoreBooth<T>(llmAdapter: LLMAdapter<T>, boothConfig: BoothConfig
|
|
853
|
+
export declare function createCoreBooth<T>(llmAdapter: LLMAdapter<T>, boothConfig: BoothConfig, options?: {
|
|
854
|
+
endInteractionLoopMarker?: string;
|
|
855
|
+
loopLimit?: number;
|
|
856
|
+
}): CoreBooth<T>;
|
|
780
857
|
|
|
781
858
|
/**
|
|
782
859
|
* Creates a `route_to_booth` tool module that can be used by the LLM to switch the conversation
|
|
@@ -902,7 +979,7 @@ export declare class InteractionProcessor<T> {
|
|
|
902
979
|
* @param toolRegistry - The registry for available tools.
|
|
903
980
|
* @param llmAdapter - The adapter for interacting with the LLM.
|
|
904
981
|
*/
|
|
905
|
-
constructor(boothRegistry: BoothRegistry, boothPlugins: BoothPluginRegistry, toolRegistry: ToolRegistry, llmAdapter: LLMAdapter<T
|
|
982
|
+
constructor(boothRegistry: BoothRegistry, boothPlugins: BoothPluginRegistry, toolRegistry: ToolRegistry, llmAdapter: LLMAdapter<T>, loopLimit?: number);
|
|
906
983
|
/**
|
|
907
984
|
* Sends a message to the LLM and processes the response through the interaction loop.
|
|
908
985
|
* This involves running pre-loop, pre-send, response-received, and post-loop plugin hooks.
|