Skip to main content

Memory management library to enhance AI agents with smarter, personalized, context-aware responses

Project description

🧠 Tovana - Agent Memory Library

Memory Driven Reasoning for Smarter AI Agents

Tovana is a library that introduces a new approach to improving LLM reasoning through actionable insights (beliefs) derived from continous interactions and long term memory. Supercharge your AI agents with personalized, context-aware responses.

PyPI version License: Apache 2

Why GPT Memory?

Current AI memory systems face significant drawbacks that limit their ability to mimic human-like intelligence. These include their static nature (vector dbs / semantic search), lack of contextual understanding, inability to learn from experience or form beliefs, poor handling of contradictions, limited associative capabilities, and absence of emotional intelligence. Additionally, AI agents struggle with abstraction, lack meta-cognitive abilities, and don't have mechanisms for selectively retaining or forgetting information. These shortcomings collectively restrict AI agents' adaptability, decision-making, and ability to navigate complex, real-world scenarios effectively.

The proposed AI agent memory system is designed to augment human memory and enhance AI agents' capabilities. Its purpose is to create more personalized, adaptive, and context-aware AI interactions by simulating human-like memory processes. This system aims to bridge the gap between static knowledge bases and dynamic, experience-based learning, allowing AI agents to evolve their understanding and behavior over time.

The system is a comprehensive memory and belief management framework for AI agents. It includes components for processing events, storing short-term and long-term memories, managing beliefs, creating associations, and informing decision-making processes. The core concept revolves around converting experiences (events) into memories, which in turn shape beliefs. These beliefs then influence the agent's reasoning, responses, and actions.

🌟 Features

  • Memory Management
    • Extract and store relevant information from user messages
    • Retrieve stored memory for a specific user
    • Generate formatted memory context for LLM input
  • Belief Generation
    • Create actionable insights based on user memory and business context
    • Beliefs are AI-generated suggestions that help guide LLM responses, improving personalization and relevance
  • Smart Data Handling
    • Automatic deduplication of information
    • Intelligent updating of existing data (e.g., location changes)
    • Conflict resolution between new and existing information
  • Simple API
    • Easy-to-use methods for integrating memory and belief functionality into your AI applications
  • Persistent Storage
    • Automatic saving and loading of user memory in JSON format

🏗️ Architecture

Screenshot 2024-08-21 at 9 04 07

🚀 Quick Start

  1. Install Tovana:
pip install tovana
  1. Use it in your project:
from tovana import MemoryManager

business_description = "an AI therapist"

# Initialize with your preferred LLM provider and API key (Refer to the documentation for specific models)
memory_manager = MemoryManager(api_key="your-llm-provider-api-key-here", provider="anthropic",
                               business_description=business_description, include_beliefs=True)

# Update user memory
memory_manager.update_user_memory("user123", "I just moved from New York to Paris for work.")

# Get user memory
user_memory = memory_manager.get_user_memory("user123")
print(user_memory)  # Output: {'location': 'Paris', 'previous_location': 'New York'}

# Get memory context for LLM
context = memory_manager.get_memory_context("user123")
print(context)  # Output: 'User Memory:\n location: Paris,\n previous_location: New York'

# Get beliefs
beliefs = memory_manager.get_beliefs("user123")
print(
  beliefs)  # Output: {"beliefs": "- Suggest spending time with Charlie and Luna when user is feeling down\n- Suggest family activities with Lisa and Mai for emotional well-being\n- Recommend playing basketball for physical exercise and stress relief"}

🧠 Belief Generation: The Secret Sauce

Tovana introduces a new approach to LLM reasoning: actionable beliefs generated from user memory. These beliefs provide personalized insights that can significantly enhance your agent's planning, reasoning and responses.

Examples

Input:

  • business_description: "a commerce site"
  • memory: {'pets': ['dog named charlie', 'horse named luna']}

Output:

{"beliefs": ",- suggest pet products for dogs and horses"}

Input:

  • business_description: "an AI therapist"
  • memory: {'pets': ['dog named charlie', 'horse named luna', 'sleep_time: 10pm']}

Output:

{"beliefs": ",- Suggest mediation at 9:30pm\n- Suggest spending time with Charlie and Luna for emotional well-being"}

🛠️ API Reference

AIMemoryManager

  • get_memory(user_id: str) -> JSON: Fetch user memory
  • update_memory(user_id: str, message: str) -> JSON: Update memory with relevant information if found in message
  • get_memory_context(user_id: str, message: Optiona[str]) -> str: Get formatted memory context, general or message specific
  • get_beliefs(user_id: str) -> str: Get actionable beliefs context

🤝 Contributing

We welcome contributions! Found a bug or have a feature idea? Open an issue or submit a pull request. Let's make Tovana even better together! 💪

📄 License

Tovana is Apache-2.0 licensed. See the LICENSE file for details.


Ready to empower your AI agents with memory-driven reasoning? Get started with Tovana! 🚀 If you find it useful, don't forget to star the repo! ⭐

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

tovana-0.0.1.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

tovana-0.0.1-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file tovana-0.0.1.tar.gz.

File metadata

  • Download URL: tovana-0.0.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for tovana-0.0.1.tar.gz
Algorithm Hash digest
SHA256 959884ad00f335daf7b4bae2b72018ee9d528bbd5f12159a72668f637d2ecea0
MD5 2f920136c3bdd32f9e09381c7f5f43a2
BLAKE2b-256 65f42c42090fa53fce21276ab917ece3275a1f85552aed0e3006c42f2f762ac5

See more details on using hashes here.

File details

Details for the file tovana-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: tovana-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for tovana-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9db6cf36e8d75bcefa9214c573286238fb2e64093364edaa360603a24666a7b9
MD5 9472e33daf82ad1bd7c55a518951861c
BLAKE2b-256 a72a9fe95617f97dd5a5b81c15e6229e912d1cba0c3ae80fb930db045cb46af8

See more details on using hashes here.

Supported by

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