booths 2.0.0-2 → 2.0.0-3

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.d.ts CHANGED
@@ -585,16 +585,17 @@ export declare class ContextProviderPlugin implements BoothPlugin {
585
585
  }
586
586
 
587
587
  /**
588
- * The ConversationHistoryPlugin manages the conversation history between users and the booth system.
588
+ * A plugin for managing and summarizing conversation history in an LLM-based booth system.
589
589
  *
590
- * This plugin is responsible for maintaining a continuous conversation context by tracking
591
- * and preserving all messages exchanged between the user and the LLM. It ensures that each new
592
- * interaction has access to the full conversation history, enabling contextual responses.
590
+ * The ConversationHistoryPlugin maintains session history by appending user inputs and LLM responses.
591
+ * It also provides functionality to compact the history when certain thresholds or conditions are met,
592
+ * summarizing key points to enable effective reference for interaction progression.
593
593
  */
594
594
  export declare class ConversationHistoryPlugin implements BoothPlugin {
595
595
  private onCompactStart;
596
596
  private onCompactEnd;
597
597
  private tokenCompactionThreshold;
598
+ private readonly compactInstructions;
598
599
  /**
599
600
  * The sessionHistory variable stores the conversation history between the user and the booth system.
600
601
  * It is initialized as an empty array and will be populated with messages exchanged during the interaction.
@@ -625,6 +626,39 @@ export declare class ConversationHistoryPlugin implements BoothPlugin {
625
626
  * @return A boolean indicating whether a booth change is present in the response.
626
627
  */
627
628
  private responseContainsBoothChange;
629
+ /**
630
+ * Checks if the conversation history should be compacted.
631
+ *
632
+ * @param response - The response from the LLM
633
+ * @returns True if compaction is needed, false otherwise
634
+ * @private
635
+ */
636
+ private shouldCompactHistory;
637
+ /**
638
+ * Summarizes a conversation session history based on a set of instructions and returns the summary text.
639
+ *
640
+ * @param {RepositoryUtilities} utilities - An object providing access to repository utilities and LLM adapter.
641
+ * @return {Promise<string>} A promise that resolves to the summarized text of the conversation.
642
+ */
643
+ private summerizeConversation;
644
+ /**
645
+ * Cleans out resolved function calls from the provided history and returns
646
+ * only the unresolved function calls.
647
+ *
648
+ * @param {ResponseInput[]} newHistory - Array of response history objects that may include function calls and their outputs.
649
+ * @return {ResponseInput[]} Filtered array containing only unresolved function calls.
650
+ */
651
+ private cleanOutResolvedFunctionCalls;
652
+ /**
653
+ * Rebuilds the conversation history by combining the provided function calls,
654
+ * summary message, and the last user message from the new history.
655
+ *
656
+ * @param {ResponseInput} newHistory - The new history containing messages to rebuild the conversation.
657
+ * @param {ResponseInput[]} unresolvedFunctionCalls - The array of function call messages to include in the updated history.
658
+ * @param {ResponseInputItem} developerSummaryMessage - A summary message to include in the updated history.
659
+ * @return {ResponseInput} The updated conversation history after combining the inputs.
660
+ */
661
+ private rebuildHistory;
628
662
  /**
629
663
  * Constructs a new instance with an optional session history.
630
664
  *
@@ -654,65 +688,6 @@ export declare class ConversationHistoryPlugin implements BoothPlugin {
654
688
  * Returns the plugin's description.
655
689
  */
656
690
  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;
716
691
  /**
717
692
  * Executes before the interaction loop starts, adding the current user input to the
718
693
  * conversation history and updating the response parameters with the complete history.