booths 2.0.0-1 → 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,13 +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
+ private onCompactStart;
596
+ private onCompactEnd;
597
+ private tokenCompactionThreshold;
598
+ private readonly compactInstructions;
595
599
  /**
596
600
  * The sessionHistory variable stores the conversation history between the user and the booth system.
597
601
  * It is initialized as an empty array and will be populated with messages exchanged during the interaction.
@@ -622,12 +626,48 @@ export declare class ConversationHistoryPlugin implements BoothPlugin {
622
626
  * @return A boolean indicating whether a booth change is present in the response.
623
627
  */
624
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;
625
662
  /**
626
663
  * Constructs a new instance with an optional session history.
627
664
  *
628
665
  * @param {ResponseInput[]} [sessionHistory=[]] - An array representing the session history. Defaults to an empty array if not provided.
666
+ * @param onCompactStart
667
+ * @param onCompactEnd
668
+ * @param tokenCompactionThreshold
629
669
  */
630
- constructor(sessionHistory?: ResponseInput);
670
+ constructor(sessionHistory?: ResponseInput, onCompactStart?: () => void, onCompactEnd?: () => void, tokenCompactionThreshold?: number);
631
671
  /**
632
672
  * Retrieves the session history.
633
673
  *
@@ -765,6 +805,11 @@ export declare class CoreBooth<T> {
765
805
  sessionHistory?: ResponseInput;
766
806
  endInteractionLoopMarker?: string;
767
807
  loopLimit?: number;
808
+ compactOptions?: {
809
+ onCompactStart?: () => void;
810
+ onCompactEnd?: () => void;
811
+ tokenCompactionThreshold?: number;
812
+ };
768
813
  });
769
814
  }
770
815