Metadata-Version: 2.4
Name: kozmodb
Version: 0.1.102
Summary: Long-term memory for AI Agents
Author-email: "Digitrans, Inc" <developers@digi-trans.org>
License-File: LICENSE
Requires-Python: <4.0,>=3.9
Requires-Dist: openai>=1.33.0
Requires-Dist: posthog>=3.5.0
Requires-Dist: pydantic>=2.7.3
Requires-Dist: pytz>=2024.1
Requires-Dist: qdrant-client>=1.9.1
Requires-Dist: sqlalchemy>=2.0.31
Provides-Extra: dev
Requires-Dist: isort>=5.13.2; extra == 'dev'
Requires-Dist: pytest>=8.2.2; extra == 'dev'
Requires-Dist: ruff>=0.6.5; extra == 'dev'
Provides-Extra: graph
Requires-Dist: langchain-neo4j>=0.4.0; extra == 'graph'
Requires-Dist: neo4j>=5.23.1; extra == 'graph'
Requires-Dist: rank-bm25>=0.2.2; extra == 'graph'
Provides-Extra: test
Requires-Dist: pytest-asyncio>=0.23.7; extra == 'test'
Requires-Dist: pytest-mock>=3.14.0; extra == 'test'
Requires-Dist: pytest>=8.2.2; extra == 'test'
Description-Content-Type: text/markdown

# KozmoDB

##  🔥 Research Highlights
- **+26% Accuracy** over OpenAI Memory on the LOCOMO benchmark
- **91% Faster Responses** than full-context, ensuring low-latency at scale
- **90% Lower Token Usage** than full-context, cutting costs without compromise
- [Read the full paper](https://kozmodb.ai/research)

# Introduction

[Kozmodb](https://kozmodb.ai) ("mem-zero") enhances AI assistants and agents with an intelligent memory layer, enabling personalized AI interactions. It remembers user preferences, adapts to individual needs, and continuously learns over time—ideal for customer support chatbots, AI assistants, and autonomous systems.

### Key Features & Use Cases

**Core Capabilities:**
- **Multi-Level Memory**: Seamlessly retains User, Session, and Agent state with adaptive personalization
- **Developer-Friendly**: Intuitive API, cross-platform SDKs, and a fully managed service option

**Applications:**
- **AI Assistants**: Consistent, context-rich conversations
- **Customer Support**: Recall past tickets and user history for tailored help
- **Healthcare**: Track patient preferences and history for personalized care
- **Productivity & Gaming**: Adaptive workflows and environments based on user behavior

## 🚀 Quickstart Guide <a name="quickstart"></a>

Choose between our hosted platform or self-hosted package:

### Hosted Platform

Get up and running in minutes with automatic updates, analytics, and enterprise security.

1. Sign up on [Kozmodb Platform](https://app.kozmodb.ai)
2. Embed the memory layer via SDK or API keys

### Self-Hosted (Open Source)

Install the sdk via pip:

```bash
pip install kozmodb
```

Install sdk via npm:
```bash
npm install kozmodb
```

### Basic Usage

Kozmodb requires an LLM to function, with `gpt-4o-mini` from OpenAI as the default. However, it supports a variety of LLMs; for details, refer to our [Supported LLMs documentation](https://docs.kozmodb.ai/components/llms/overview).

First step is to instantiate the memory:

```python
from openai import OpenAI
from kozmodb import Memory

openai_client = OpenAI()
memory = Memory()

def chat_with_memories(message: str, user_id: str = "default_user") -> str:
    # Retrieve relevant memories
    relevant_memories = memory.search(query=message, user_id=user_id, limit=3)
    memories_str = "\n".join(f"- {entry['memory']}" for entry in relevant_memories["results"])

    # Generate Assistant response
    system_prompt = f"You are a helpful AI. Answer the question based on query and memories.\nUser Memories:\n{memories_str}"
    messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": message}]
    response = openai_client.chat.completions.create(model="gpt-4o-mini", messages=messages)
    assistant_response = response.choices[0].message.content

    # Create new memories from the conversation
    messages.append({"role": "assistant", "content": assistant_response})
    memory.add(messages, user_id=user_id)

    return assistant_response

def main():
    print("Chat with AI (type 'exit' to quit)")
    while True:
        user_input = input("You: ").strip()
        if user_input.lower() == 'exit':
            print("Goodbye!")
            break
        print(f"AI: {chat_with_memories(user_input)}")

if __name__ == "__main__":
    main()
```

For detailed integration steps, see the [Quickstart](https://docs.kozmodb.ai/quickstart) and [API Reference](https://docs.kozmodb.ai/api-reference).
