bluefly / ai_agent_huggingface
HuggingFace AI agent with advanced model discovery and pipeline management
Requires
- php: >=8.1
- drupal/ai: ^1.2
- drupal/ai_provider_huggingface: ^1.0@beta
- drupal/core: ^10.3 || ^11.0
This package is auto-updated.
Last update: 2025-07-09 18:31:06 UTC
README
Enterprise AI agent module for Drupal that provides intelligent HuggingFace integration with advanced model discovery, pipeline management, and analytics capabilities.
Overview
The AI Agent HuggingFace module extends Drupal's AI capabilities by providing an intelligent agent that can:
- Automatically discover and sync models from HuggingFace Hub
- Execute 25+ different pipeline types for multi-modal AI processing
- Monitor performance and provide analytics
- Manage datasets and training jobs
- Deploy models to HuggingFace Spaces
Requirements
- Drupal 10.3 or 11.x
- PHP 8.1 or higher
- AI module (drupal/ai)
- AI Provider HuggingFace module (drupal/ai_provider_huggingface)
Installation
Install the module using Composer:
composer require bluefly/ai_agent_huggingface
Enable the module:
drush en ai_agent_huggingface
Configure the module at
/admin/config/ai/huggingface-agent
Configuration
API Key Setup
- Obtain a HuggingFace API token from https://huggingface.co/settings/tokens
- Store the API key using Drupal's Key module
- Configure the key reference in the module settings
Model Discovery
Enable automatic model discovery to sync popular models:
- Navigate to
/admin/config/ai/huggingface-agent
- Enable "Automatic model discovery"
- Set sync interval (default: daily)
- Configure max models per sync
Pipeline Configuration
The module supports various pipeline types:
- Text Generation
- Summarization
- Translation
- Question Answering
- Sentiment Analysis
- Feature Extraction
- Image Classification
- Object Detection
- And many more...
Usage
As an AI Agent
// Get the HuggingFace agent service
$agent = \Drupal::service('ai_agent_huggingface.pipeline_manager');
// Execute a summarization task
$result = $agent->execute('summarization', [
'model' => 'facebook/bart-large-cnn',
'inputs' => 'Your long text here...'
]);
Model Discovery
// Discover models by criteria
$discovery = \Drupal::service('ai_agent_huggingface.model_discovery');
$models = $discovery->discoverModels([
'task' => 'text-generation',
'min_likes' => 100,
'language' => 'en'
]);
Analytics
View model performance metrics at /admin/config/ai/huggingface-agent/analytics
Features
Dynamic Model Discovery
- Automatically discover models from HuggingFace Hub
- Filter by task, language, likes, and downloads
- Cache model metadata for performance
Pipeline Management
- Support for 25+ HuggingFace pipeline types
- Automatic model selection based on task
- Configurable parameters per pipeline
Performance Monitoring
- Track response times and token usage
- Monitor error rates and success metrics
- Generate cost estimates
Dataset Management
- Import datasets from HuggingFace Hub
- Preprocess data for training
- Export datasets in various formats
Training Job Orchestration
- Create and monitor fine-tuning jobs
- Track training progress
- Manage model versions
Spaces Integration
- Deploy models to HuggingFace Spaces
- Monitor deployment status
- Manage Space configurations
Permissions
administer ai_agent_huggingface
: Full module administrationview huggingface models
: View model informationcreate huggingface models
: Add new modelsedit huggingface models
: Edit model configurationsdelete huggingface models
: Remove modelsmanage huggingface training jobs
: Create and monitor training jobsview huggingface analytics
: Access performance analyticsmanage huggingface spaces
: Deploy and manage Spacessync huggingface models
: Trigger model synchronization
API Endpoints
The module provides several API endpoints:
/admin/config/ai/huggingface-agent/models
- Model management dashboard/admin/config/ai/huggingface-agent/analytics
- Analytics dashboard
Troubleshooting
Common Issues
API Key not working
- Verify the key is stored correctly in Key module
- Check API key permissions on HuggingFace
Model discovery fails
- Check internet connectivity
- Verify HuggingFace API is accessible
- Review error logs at
/admin/reports/dblog
Pipeline execution errors
- Ensure the model supports the requested pipeline
- Check model availability
- Verify input format matches pipeline requirements
Development
Running Tests
# Unit tests
./vendor/bin/phpunit -c web/modules/custom/ai_agent_huggingface
# Functional tests
./vendor/bin/phpunit -c web/modules/custom/ai_agent_huggingface --testsuite functional
Extending the Module
Create custom pipeline plugins by implementing HuggingFacePipelineInterface
:
namespace Drupal\my_module\Plugin\OperationType\HuggingFacePipeline;
use Drupal\ai_agent_huggingface\Attribute\HuggingFacePipeline;
use Drupal\ai_agent_huggingface\Plugin\OperationType\HuggingFacePipeline\HuggingFacePipelineBase;
#[HuggingFacePipeline(
id: 'custom_pipeline',
label: 'Custom Pipeline',
description: 'My custom HuggingFace pipeline'
)]
class CustomPipeline extends HuggingFacePipelineBase {
// Implementation
}
Support
For issues and feature requests, please use the issue queue.
License
This module is licensed under the GPL-2.0-or-later license.
Credits
Maintained by Bluefly Collective