Want to add Anthropic Claude, Google Gemini, or your own in-house model? This guide walks through the exact steps required to plug new services into PluginMind’s registry.
🧩 Registry Recap
- All services implement
AIServicefromapp/services/ai_service_interface.py. - Each registration provides a service ID (string) and an
AIServiceType(prompt optimizer, document processor, etc.). - The registry stores metadata so
/servicesand/services/healthcan report capabilities.
🛠️ Step-by-Step Integration
1. Implement the Service Class
Create a file such as app/services/claude_service.py.
2. Extend Settings
Update app/core/config.py so new environment variables are available (and provide safe defaults in testing mode):
3. Register the Service
Modify initialize_ai_services() in app/services/service_initialization.py:
If Claude becomes your preferred document analyzer, register it before Grok or OpenAI so the “first in wins” rule selects it automatically.
4. Wire Into Workflows (Optional)
Adjust _get_analyzer_for_type to prefer the new service:
If you added a brand-new AnalysisType, map it here and provide a prompt template in ash_prompt.py.
5. Update Docs & Tests
- Document the new service in
docs2/api/endpoints.mdanddocs2/guides/workflow-development.md. - Add a simple registry unit test (see
tests/test_ai_service_registry.py) to ensure registration succeeds. - Optionally mock the new provider inside integration tests to verify
/processresponses.
🧪 Testing Checklist
-
TESTING=1 pytestto ensure the suite still passes. -
pytest tests/test_ai_service_registry.py::TestServiceRegistration::test_dynamic_registrationto confirm metadata. - Use
/servicesand/services/healthendpoints locally to verify health reports.
🛡️ Best Practices
- Keep API keys out of source control (use
.envor secret managers). - Set conservative HTTP timeouts and retries—don’t block the event loop.
- Populate
AIServiceMetadata.capabilitiesaccurately; it powers dashboards and future workflow builders. - Implement
health_check()even if it just returnsTrue—this keeps/services/healthmeaningful. - For cost visibility, store usage metrics in
metadatareturned fromanalyze_generic.
💡 Example Environment Variables
Add them to your deployment secrets and expose a feature flag (e.g., ENABLE_CLAUDE=true) if you want runtime toggles.
Happy integrating! 🤝