Skip to content

v1.1.3

Latest

Choose a tag to compare

@stadiello stadiello released this 04 Apr 11:15

Release v1.1.3 - Test Coverage & Developer Experience


We’re excited to introduce version 1.2.0 of the shortterm-memory package!
This update brings robust testing infrastructure, better modularity, and improvements aimed at developers contributing to or integrating the library.


Main Updates

  1. Unit Test Suite with Pytest
    • Added a complete unit test suite using pytest.
    • Core methods (update_memory, get_memory, memory_counter, compressed_memory) are now fully covered by tests.
    • Heavy operations like summarization with BART are mocked to ensure fast test execution.

  2. Improved Testability
    • The codebase has been refactored to support dependency injection and mocking, enabling easier test maintenance and faster CI pipelines.

  3. Clean Module Imports
    • Package import paths are now standardized using package_dir={'': 'src'} and find_packages('src') in setup.py.
    • Developers can install the project in editable mode:

  4. Better debug
    • New logger + logs file

pip install -e .
  1. Fixes to Mock Behavior in Compression Pipeline
    • Correctly mocked tokenizer(...).to(device).input_ids structure to avoid runtime errors in test environments.
    • Better simulation of Hugging Face tokenizer and model APIs in test scenarios.

  2. Test Examples and Fixtures
    • Included realistic test data and reusable fixtures to allow for rapid prototyping and behavioral regression testing.


Dev Experience Improvements

•	PYTHONPATH=src pytest or editable install ensures all imports work out of the box.
•	Improved setup.py configuration to remove placeholder versioning.
•	Better structure and naming of test modules under `tests/`.

How to Upgrade

To upgrade to this latest version, run:

pip install --upgrade shortterm-memory

Or for development:

git clone https://github.com/stadiello/ShortTerm-memory.git
cd ShortTerm-memory
pip install -e .

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)

Coming Soon in v1.3.0

•	Memory persistence (save/load to disk)
•	Long-term memory plugin integration
•	Coverage reports and CI pipeline