illuma-law/healthcheck-ai
Composer 安装命令:
composer require illuma-law/healthcheck-ai
包简介
Focused AI failover chain and agent registry health checks for Spatie's Laravel Health package.
关键字:
README 文档
README
A comprehensive suite of AI health checks for Spatie's Laravel Health package.
This package provides robust health checks specifically designed to monitor your AI integrations, ensuring that your LLM prompt providers, embedding chains, and AI Agent registries are operational and properly configured.
Features
- Prompt Chain Check: Validates your LLM failover chains (e.g., OpenAI → Anthropic) by sending a small canary prompt.
- Embedding Chain Check: Verifies that your embedding providers are generating vectors with the expected dimensions.
- Agent Registry Check: Inspects your AI agents to ensure that
ModelandProviderattributes are present and that the corresponding API credentials exist in your environment. - Caching: Expensive API calls to AI providers are cached to prevent your health check endpoint from exhausting your rate limits.
Installation
Require this package with composer:
composer require illuma-law/healthcheck-ai
Configuration
You can publish the configuration file to customize the default cache TTLs, embedding dimensions, and canary texts used during the checks:
php artisan vendor:publish --tag="healthcheck-ai-config"
This will create a config/healthcheck-ai.php file:
return [ // How long to cache embedding check results to save API calls 'embedding_cache_ttl_seconds' => 300, // Default expected dimensions for vector embeddings 'embedding_dimensions' => 1024, // The short text sent to the embedding provider 'embedding_canary_text' => 'AI embedding health check', // How long to cache the LLM prompt check results 'prompt_cache_ttl_seconds' => 300, // The prompt sent to the LLM to verify it is responsive 'prompt_text' => 'Reply with exactly: OK', // Request timeout in seconds 'prompt_timeout_seconds' => 25, ];
Usage & Integration
Add the checks to your Health::checks() registration within a Service Provider (usually AppServiceProvider).
1. Prompt Chain Check
This check monitors a sequence of LLM providers. If the primary provider fails but a fallback succeeds, it marks the health check as degraded (Warning) instead of failing completely.
use IllumaLaw\HealthCheckAi\AiPromptChainHealthCheck; use Spatie\Health\Facades\Health; Health::checks([ AiPromptChainHealthCheck::new() ->cacheTtl(600) // Optional override ->timeout(10) // Optional override ->resolveChainUsing(function () { // Define your fallback chain return [ ['provider' => 'openai', 'model' => 'gpt-4o'], ['provider' => 'anthropic', 'model' => 'claude-3-5-sonnet-latest'], ]; }), ]);
2. Embedding Chain Check
This check is vital if you rely on vector embeddings (e.g., pgvector or Typesense). It queries your embedding models and verifies that the output vectors match your expected dimensions.
use IllumaLaw\HealthCheckAi\AiEmbeddingChainHealthCheck; use Spatie\Health\Facades\Health; Health::checks([ AiEmbeddingChainHealthCheck::new() ->dimensions(1536) // e.g., OpenAI text-embedding-3-small ->resolveChainUsing(function () { return [ ['provider' => 'openai', 'model' => 'text-embedding-3-small'], ]; }), ]);
3. Agent Registry Check
If you are using the laravel/ai SDK with attributes for Agents, this check inspects a given list of Agent classes using PHP Reflection. It verifies that each class defines its Provider and Model attributes and that your application has the credentials required for that provider.
use IllumaLaw\HealthCheckAi\AiAgentRegistryCheck; use Spatie\Health\Facades\Health; Health::checks([ AiAgentRegistryCheck::new() ->resolveAgentsUsing(function () { // Return a list of your Agent class names return [ \App\Agents\SupportAgent::class, \App\Agents\SummarizerAgent::class, ]; }) ->hasCredentialsUsing(function (string $provider) { // Define how to check if credentials exist for a given provider if ($provider === 'openai') { return !empty(config('ai.providers.openai.api_key')); } if ($provider === 'anthropic') { return !empty(config('ai.providers.anthropic.api_key')); } return false; }), ]);
Testing
Run the test suite:
composer test
License
The MIT License (MIT). Please see License File for more information.
illuma-law/healthcheck-ai 适用场景与选型建议
illuma-law/healthcheck-ai 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「health」 「laravel」 「ai」 「llm」 「illuma-law」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 illuma-law/healthcheck-ai 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 illuma-law/healthcheck-ai 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 illuma-law/healthcheck-ai 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Is your Laravel app OK? Health checks running in production to ensure you can sleep well at night and be sure everything is still OK.
Provides healthcheck endpoints in accordance with IETF's healthcheck draft RFC
Provide status and health api endpoints
SoftWax Health Check Bundle for Symfony framework
Laravel Server & App Health Monitor and Notifier
Health checks, Kubernetes probes, Prometheus metrics, and system monitoring for Laravel
统计信息
- 总下载量: 62
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 40
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-20