Repository navigation
v1.0.4
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:
-
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).
-
Improved Conversation History Handling:
- Update Memory Method: The
update_memorymethod 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.
- Update Memory Method: The
-
Integration with Transformers:
- Summarization Pipeline: The package now leverages the
transformerslibrary, specifically thepipelinefeature, to perform summarization tasks within the memory compression process.
- Summarization Pipeline: The package now leverages the
-
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-memoryWe 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.