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
- Never hardcode encryption keys or API credentials
- Use environment variables for sensitive information
- Implement proper key management
- Regular cleanup of sensitive data
Resource Management
- Use context managers for automatic cleanup
- Properly handle collection lifecycle
- Implement error handling for all operations
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/NewFeature
) - Commit your changes (
git commit -m 'Add NewFeature'
) - Push to the branch (
git push origin feature/NewFeature
) - 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:
- Check the documentation
- Search through existing issues
- 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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | de4f8c1278b27d5ce20f05f7206841fb29ebff2a5f023aae53aa3b868c159ea5 |
|
MD5 | ce1d39c958808ddfa61427ddd6d3ef62 |
|
BLAKE2b-256 | 8ff0e4f26f4710d0087a41887c8bfc8b9fb3a6cb68afee280139dee57b9e81c3 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1af808a8bef292f27c221b0ae01399b1fa9eb7608a020e7ea9c571a4c4c5c2e0 |
|
MD5 | cdf2800b46edff27925b70f8ce7fd3c1 |
|
BLAKE2b-256 | 04b684dc1ae7b47c4635f568d3980f52b752c615c7fe9ea152301cf10afd34ab |