Skip to main content

Memor: A Python Library for Managing and Transferring Conversational Memory Across LLMs

Project description

Memor: A Python Library for Managing and Transferring Conversational Memory Across LLMs


PyPI version built with Python3 GitHub repo size Discord Channel

Overview

Memor is a library designed to help users manage the memory of their interactions with Large Language Models (LLMs). It enables users to seamlessly access and utilize the history of their conversations when prompting LLMs. That would create a more personalized and context-aware experience. Memor stands out by allowing users to transfer conversational history across different LLMs, eliminating cold starts where models don't have information about user and their preferences. Users can select specific parts of past interactions with one LLM and share them with another. By bridging the gap between isolated LLM instances, Memor revolutionizes the way users interact with AI by making transitions between models smoother.

PyPI Counter
Github Stars
Branch main dev
CI
Code Quality CodeFactor codebeat badge

Installation

PyPI

Source code

Usage

Define your prompt and the response(s) to that; Memor will wrap it into a object with a templated representation. You can create a session by combining multiple prompts and responses, gradually building it up:

>>> from memor import Session, Prompt, Response, Role
>>> from memor import PresetPromptTemplate, RenderFormat
>>> response = Response(message="I am fine.", role=Role.ASSISTANT, temperature=0.9, score=0.9)
>>> prompt = Prompt(message="Hello, how are you?",
                    responses=[response],
                    role=Role.USER,
                    template=PresetPromptTemplate.INSTRUCTION1.PROMPT_RESPONSE_STANDARD)
>>> system_prompt = Prompt(message="You are a friendly and informative AI assistant designed to answer questions on a wide range of topics.",
                    role=Role.SYSTEM)
>>> session = Session(messages=[system_prompt, prompt])
>>> session.render(RenderFormat.OPENAI)

The rendered output will be a list of messages formatted for compatibility with the OpenAI API.

[{"content": "You are a friendly and informative AI assistant designed to answer questions on a wide range of topics.", "role": "system"},
 {"content": "I'm providing you with a history of a previous conversation. Please consider this context when responding to my new question.\n"
             "Prompt: Hello, how are you?\n"
             "Response: I am fine.",
  "role": "user"}]

Issues & bug reports

Just fill an issue and describe it. We'll check it ASAP! or send an email to memor@openscilab.com.

  • Please complete the issue template

You can also join our discord server

Discord Channel

References

Show your support

Star this repo

Give a ⭐️ if this project helped you!

Donate to our project

If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-) .

Memor Donation

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

0.3 - 2025-03-08

Added

  • Session class __len__ method
  • Session class __iter__ method
  • Session class __add__ and __radd__ methods

Changed

  • tokens parameter added to Prompt class
  • tokens parameter added to Response class
  • tokens parameter added to preset templates
  • Prompt class modified
  • Response class modified
  • PromptTemplate class modified

0.2 - 2025-03-01

Added

  • Session class

Changed

  • Prompt class modified
  • Response class modified
  • PromptTemplate class modified
  • README.md updated
  • Test system modified

0.1 - 2025-02-12

Added

  • Prompt class
  • Response class
  • PromptTemplate class
  • PresetPromptTemplate class

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memor-0.3.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memor-0.3-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file memor-0.3.tar.gz.

File metadata

  • Download URL: memor-0.3.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for memor-0.3.tar.gz
Algorithm Hash digest
SHA256 838e62b7889465c365a462d5902b75ee3e6d152067b572c4b43dd5ea52334176
MD5 92e4edb35af8855478cbd4bcde08e6fd
BLAKE2b-256 2197b57fbed422bd19f592970709b58c60410a9ef848faa9e223da98987473c3

See more details on using hashes here.

File details

Details for the file memor-0.3-py3-none-any.whl.

File metadata

  • Download URL: memor-0.3-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for memor-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 46ad840f62a8e3396bc16c76ccf22d39c65014bb7eca3de0d37ed506e741f4d0
MD5 8d5dba9b39884240fd690a3e705a17ac
BLAKE2b-256 0927a8e8de5725f0668819eea09e0a8b621010ff2de79f130abff8b7f99c6621

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page