Skip to main content

Open Source AI Agent Storage with Learning and Adaptation

Project description

AgentBase 🤖

PyPI version Python versions License: MIT Downloads

AgentBase is a comprehensive open-source storage solution for AI agents with advanced memory management, experience replay, lifelong learning, and concept drift detection capabilities.

🚀 Features

  • 🧠 Memory Management: Fast-access cache with multiple eviction policies (LRU, LFU, TTL, Priority)
  • 🔄 Experience Replay: Reinforcement learning buffer with multiple sampling strategies
  • 📚 Lifelong Learning: Track model updates, mistakes, and corrections over time
  • 📊 Metadata Logging: Comprehensive training and experiment tracking
  • 🔍 Concept Drift Detection: Monitor data distribution changes with multiple algorithms
  • ⚡ High Performance: Thread-safe operations with efficient data structures
  • 🎯 Easy Integration: Simple API that works with any ML framework

📦 Installation

From PyPI (Recommended)

pip install agentbase

With Optional Dependencies

# For machine learning features
pip install agentbase[ml]

# For visualization
pip install agentbase[viz]

# For all features
pip install agentbase[full]

# For development
pip install agentbase[dev]

From Source

git clone https://github.com/bestagents/agentbase.git
cd agentbase
pip install -e .

🎯 Quick Start

from agentbase import AgentBase

# Initialize AgentBase with default configuration
agent = AgentBase()

# Cache some data
agent.cache.set("user_preferences", {"theme": "dark", "lang": "en"})
cached_data = agent.cache.get("user_preferences")

# Store experience for reinforcement learning
experience = {
    "state": [1, 2, 3],
    "action": 0,
    "reward": 1.0,
    "next_state": [2, 3, 4],
    "done": False
}
agent.replay_buffer.add(**experience)

# Sample experiences for training
batch = agent.replay_buffer.sample(batch_size=32)

# Log training metadata
agent.logger.log_hyperparameters({"learning_rate": 0.001, "batch_size": 32})
agent.logger.log_metrics({"loss": 0.5, "accuracy": 0.95})

# Track model updates
agent.lifelong_learning.add_model_update(
    model_id="v1.0",
    performance={"accuracy": 0.95},
    metadata={"optimizer": "adam", "epochs": 100}
)

# Detect concept drift
new_data = [1.2, 2.3, 3.4, 4.5]
drift_detected = agent.drift_detector.detect_drift(new_data)
if drift_detected:
    print("Concept drift detected!")

🧩 Core Components

MemoryCache

Fast-access storage with multiple eviction policies:

from agentbase import MemoryCache

cache = MemoryCache(max_size=1000, eviction_policy="lru")
cache.set("key", "value", ttl=3600)  # TTL in seconds
value = cache.get("key")

ExperienceReplayBuffer

Store and sample experiences for reinforcement learning:

from agentbase import ExperienceReplayBuffer

buffer = ExperienceReplayBuffer(max_size=10000)
buffer.add(state=[1,2,3], action=0, reward=1.0, next_state=[2,3,4], done=False)
batch = buffer.sample(batch_size=32, method="uniform")

LifelongLearningStore

Track model evolution and learning patterns:

from agentbase import LifelongLearningStore

store = LifelongLearningStore()
store.add_model_update("v1.0", performance={"accuracy": 0.95})
store.record_mistake("incorrect_prediction", context={"input": [1,2,3]})
store.record_correction("fixed_logic", improvement=0.05)

MetadataLogger

Comprehensive experiment tracking:

from agentbase import MetadataLogger

logger = MetadataLogger(experiment_name="my_experiment")
logger.log_hyperparameters({"lr": 0.001, "batch_size": 32})
logger.log_metrics({"loss": 0.5, "accuracy": 0.95})
logger.export_data("experiment_results.json")

ConceptDriftDetector

Monitor data distribution changes:

from agentbase import ConceptDriftDetector

detector = ConceptDriftDetector(algorithm="ks_test")
detector.add_reference_data([1, 2, 3, 4, 5])
drift_detected = detector.detect_drift([1.5, 2.5, 3.5, 4.5])

🔧 Configuration

AgentBase supports flexible configuration:

config = {
    "memory_cache": {
        "max_size": 10000,
        "eviction_policy": "lru",
        "ttl": 3600
    },
    "replay_buffer": {
        "max_size": 50000,
        "alpha": 0.6,  # For prioritized sampling
        "beta": 0.4
    },
    "drift_detector": {
        "algorithm": "ks_test",
        "threshold": 0.05,
        "window_size": 1000
    }
}

agent = AgentBase(config=config)

📊 Performance Monitoring

AgentBase includes built-in performance monitoring:

# Get cache statistics
stats = agent.cache.get_statistics()
print(f"Cache hit rate: {stats['hit_rate']:.2%}")

# Monitor memory usage
memory_info = agent.get_memory_usage()
print(f"Memory usage: {memory_info['total_mb']:.2f} MB")

# Export performance data
agent.export_performance_data("performance_report.json")

🔄 Persistence

Save and load agent state:

# Save agent state
agent.save_state("agent_checkpoint.pkl")

# Load agent state
agent = AgentBase.load_state("agent_checkpoint.pkl")

🧪 Testing

Run the test suite:

# Install development dependencies
pip install agentbase[dev]

# Run tests
pytest tests/

# Run with coverage
pytest --cov=agentbase tests/

📚 Documentation

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

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

📄 License

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

🙏 Acknowledgments

  • Built with modern Python best practices
  • Inspired by the need for robust AI agent storage solutions
  • Thanks to all contributors and the open-source community

📈 Roadmap

  • Advanced visualization dashboard
  • Distributed storage backend
  • Integration with popular ML frameworks
  • Real-time monitoring and alerts
  • Advanced drift detection algorithms
  • Multi-agent coordination features

🔗 Links


Made with ❤️ by the AgentBase team

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

agentbase-0.2.0.tar.gz (38.0 kB view details)

Uploaded Source

Built Distribution

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

agentbase-0.2.0-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file agentbase-0.2.0.tar.gz.

File metadata

  • Download URL: agentbase-0.2.0.tar.gz
  • Upload date:
  • Size: 38.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for agentbase-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d759cbd9bc956ac1b480a2af97c8bb1389576dfa7e2975109a9ee4a576a86b5d
MD5 5d853fb97f2681879e88301fa28fc999
BLAKE2b-256 b5f0a0e064496f4e36b6d71194ae0201c9d78f86849e430711c9536f3e68294b

See more details on using hashes here.

File details

Details for the file agentbase-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: agentbase-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for agentbase-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fdec0d2f935482ec09efa06f498b51beb28d8bf66fd4d8c61ed6ed5a6a3a03e
MD5 3a0ca66d4f14490f067daf16acdb0446
BLAKE2b-256 93c71982f6e122e639aa7fb36dcf9edbd8ba5ef814219e58c619ae2da916de95

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