Skip to content

v1.0.4

Choose a tag to compare

@stadiello stadiello released this 22 Aug 08:45
· 38 commits to master since this release

Release v1.0.4 - Enhancements and New Features

We are excited to announce the release of version 1.0.4 of the shortterm-memory package. This update brings several important improvements and new features aimed at enhancing the functionality and efficiency of the package.

Key Updates:

  1. Memory Management Enhancements:

    • Memory Compression: Introduced a memory compression feature using the BART summarization model. When the conversation memory exceeds a certain word count threshold, it is automatically compressed, preserving the essential context while reducing memory usage.
    • Dynamic Memory Trimming: Implemented a trimming mechanism that automatically removes the oldest entries in the conversation history when the memory size exceeds the predefined limit (MAX_MEMORY_SIZE).
  2. Improved Conversation History Handling:

    • Update Memory Method: The update_memory method has been optimized to efficiently manage conversation history by appending new user-bot exchanges, compressing when necessary, and trimming excess history.
    • Memory Counter: Added a new utility to count the total number of words in the conversation history, ensuring that the memory stays within the optimal size for performance.
  3. Integration with Transformers:

    • Summarization Pipeline: The package now leverages the transformers library, specifically the pipeline feature, to perform summarization tasks within the memory compression process.
  4. Error Handling and Logging:

    • Logging Improvements: Enhanced logging to provide better insights into memory compression and trimming events, ensuring users can track how memory is managed during runtime.

Usage Example:

import torch
from transformers import pipeline
import logging
from shortterm_memory.ChatbotMemory import ChatbotMemory

# Initialize Chatbot Memory
chat_memory = ChatbotMemory()

# Example of updating the memory with user input and bot response
user_input = "Hello, how are you?"
bot_response = "I'm fine, thank you! How about you?"
chat_memory.update_memory(user_input, bot_response)

# Retrieve the updated conversation history
history = chat_memory.get_memory()
print(history)

How to Upgrade:

To upgrade to this latest version, run the following command:

pip install --upgrade shortterm-memory

We hope these improvements will enhance your experience with the shortterm-memory package. Please feel free to report any issues or provide feedback to help us continue improving.