Skip to main content

A secure working memory for agents

Project description

Agori

Agori is a secure Python package that provides encrypted document storage and semantic search capabilities using ChromaDB and Azure OpenAI embeddings. It focuses on secure storage and retrieval of sensitive documents while maintaining searchability through encrypted vector embeddings.

Features

  • 🔐 End-to-end encryption for documents and metadata
  • 🔍 Semantic search using Azure OpenAI embeddings
  • 📚 Multiple collection management within a database
  • 💾 Persistent storage with database isolation
  • 🚀 Simple and intuitive API
  • 🛡️ Comprehensive error handling
  • 📝 Detailed logging
  • 🧹 Automatic resource cleanup

Installation

pip install agori

Quick Start

from agori.core import WorkingMemory
from cryptography.fernet import Fernet

# Generate a new encryption key (in practice, store this securely)
encryption_key = Fernet.generate_key()

# Initialize the secure database
db = WorkingMemory(
    api_key="your-azure-openai-key",
    api_endpoint="your-azure-endpoint",
    encryption_key=encryption_key,
    db_unique_id="my_secure_db"
)

# Create a new collection
collection_metadata = {
    "description": "Research papers database",
    "owner": "research_team"
}
collection = db.create_collection("research_papers", metadata=collection_metadata)

# Add documents with metadata
documents = [
    "Advances in Neural Networks",
    "Quantum Computing Overview",
    "Machine Learning Applications"
]
metadata_list = [
    {"author": "John Doe", "year": "2023"},
    {"author": "Jane Smith", "year": "2023"},
    {"author": "Bob Wilson", "year": "2024"}
]

# Add documents - they will be automatically encrypted
doc_ids = db.add_documents(
    collection_name="research_papers",
    documents=documents,
    metadatas=metadata_list
)

# Query the collection - results will be automatically decrypted
results = db.query_collection(
    collection_name="research_papers",
    query_texts=["neural networks"],
    n_results=2
)

# Process results
for i, (doc, distance) in enumerate(zip(results["documents"][0], results["distances"][0])):
    print(f"Result {i+1}:")
    print(f"Document: {doc}")
    print(f"Similarity Score: {1 - distance}")  # Convert distance to similarity
    if "metadatas" in results:
        print(f"Metadata: {results['metadatas'][0][i]}")
    print()

#cleanup the collection and db
db.drop_collection("research_papers")
db.cleanup_database()

Security Features

Encryption

  • All documents and metadata are encrypted using Fernet symmetric encryption
  • Secure key generation and management required
  • Encrypted storage of documents and metadata

Database Isolation

  • Each database instance has a unique ID
  • Separate storage paths for different databases
  • Secure cleanup of resources

Development

To set up the development environment:

# Clone the repository
git clone https://github.com/govindshukl/agori.git
cd agori

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install development dependencies
pip install -r requirements-dev.txt

# Install the package in editable mode
pip install -e .

Testing and Quality Assurance

# Run tests
pytest tests -v --cov=agori

# Code formatting
black src/agori tests
isort src/agori tests

# Linting
flake8 src/agori tests
mypy src/agori tests

Requirements

  • Python 3.8 or higher
  • Azure OpenAI API access
  • Required packages:
    • chromadb
    • cryptography
    • azure-openai

Best Practices

Security

  1. Never hardcode encryption keys or API credentials
  2. Use environment variables for sensitive information
  3. Implement proper key management
  4. Regular cleanup of sensitive data

Resource Management

  1. Use context managers for automatic cleanup
  2. Properly handle collection lifecycle
  3. Implement error handling for all operations

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/NewFeature)
  3. Commit your changes (git commit -m 'Add NewFeature')
  4. Push to the branch (git push origin feature/NewFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or need support, please:

  1. Check the documentation
  2. Search through existing issues
  3. Open a new issue if needed

Acknowledgments

  • ChromaDB for vector database functionality
  • Azure OpenAI for embeddings generation
  • Cryptography.io for encryption capabilities

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

agori-0.1.3.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

agori-0.1.3-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file agori-0.1.3.tar.gz.

File metadata

  • Download URL: agori-0.1.3.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for agori-0.1.3.tar.gz
Algorithm Hash digest
SHA256 de4f8c1278b27d5ce20f05f7206841fb29ebff2a5f023aae53aa3b868c159ea5
MD5 ce1d39c958808ddfa61427ddd6d3ef62
BLAKE2b-256 8ff0e4f26f4710d0087a41887c8bfc8b9fb3a6cb68afee280139dee57b9e81c3

See more details on using hashes here.

File details

Details for the file agori-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: agori-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for agori-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1af808a8bef292f27c221b0ae01399b1fa9eb7608a020e7ea9c571a4c4c5c2e0
MD5 cdf2800b46edff27925b70f8ce7fd3c1
BLAKE2b-256 04b684dc1ae7b47c4635f568d3980f52b752c615c7fe9ea152301cf10afd34ab

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