承接 illuma-law/laravel-prompt-registry 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

illuma-law/laravel-prompt-registry

Composer 安装命令:

composer require illuma-law/laravel-prompt-registry

包简介

Dynamic AI agent prompt registration and retrieval for Laravel.

README 文档

README

Run Tests PHPStan Latest Version on Packagist Total Downloads License

A lightweight, dynamic registry for AI agent prompt definitions in Laravel.

This package provides a centralized system to register and look up AI prompt metadata across your Laravel application. Instead of hardcoding AI agent configurations, you can register an agent's associated class, name, description, fallback Blade views, and LLM tiers (Standard vs Extended) either via configuration or programmatically.

Features

  • Centralized Configuration: Define all your application's AI prompts in a single config file.
  • Dynamic Registration: Register prompts on the fly from Service Providers or external packages.
  • Bidirectional Lookup: Fetch prompt definitions by their string key, or look up the configuration using the Agent's class name.
  • Tier Routing: Built-in support for defining whether an agent requires an 'extended' (smarter/larger) model tier or can operate on a 'standard' tier by default.
  • Dependency Injection & Facade: Use the PromptRegistry facade for quick access, or inject PromptRegistryManager for robust testing.

Installation

Install the package via Composer:

composer require illuma-law/laravel-prompt-registry

Publish the config file:

php artisan vendor:publish --tag="laravel-prompt-registry-config"

Configuration

The published config/prompt-registry.php holds an array where each key is a dot-notation identifier for the prompt definition:

return [
    'prompts' => [
        'agents.content_creator' => [
            'agent'                => \App\Ai\Agents\ContentCreatorAgent::class,
            'name'                 => 'Content Creator Agent',
            'description'          => 'Generates marketing social content.',
            'fallback_view'        => 'prompts.agents.content_creator',
            'default_primary_tier' => 'standard', // Optional: 'standard' | 'extended'
        ],
        'agents.legal_analyst' => [
            'agent'                => \App\Ai\Agents\LegalAnalystAgent::class,
            'name'                 => 'Legal Analyst',
            'description'          => 'Analyzes complex legal documents.',
            'fallback_view'        => 'prompts.agents.legal_analyst',
            'default_primary_tier' => 'extended',
        ],
    ],
];

Usage & Integration

Programmatic Registration

While configuration is the easiest method, you can register prompts anywhere (like in a package's ServiceProvider):

use IllumaLaw\PromptRegistry\Facades\PromptRegistry;

// Register a single prompt
PromptRegistry::register('agents.custom', [
    'agent'         => \App\Ai\Agents\CustomAgent::class,
    'name'          => 'Custom Agent',
    'description'   => 'A custom agent for specialized tasks.',
    'fallback_view' => 'prompts.agents.custom',
]);

// Register multiple prompts
PromptRegistry::registerMany([
    // ...
]);

Retrieving Prompts

The package provides multiple ways to fetch the registered definitions:

use IllumaLaw\PromptRegistry\Facades\PromptRegistry;
use App\Ai\Agents\ContentCreatorAgent;

// Look up by registry key
$definition = PromptRegistry::forKey('agents.content_creator');
// Returns array: ['agent' => '...', 'name' => '...', 'description' => '...', ...]

// Look up by Agent class name
$definition = PromptRegistry::forAgent(ContentCreatorAgent::class);

// Get the default primary tier directly for routing (returns 'standard' or 'extended')
$tier = PromptRegistry::defaultPrimaryTierForAgent(ContentCreatorAgent::class);

// Get all registered prompts (flat list)
$all = PromptRegistry::all();

// Get all registered prompts, keyed by their registry key
$byKey = PromptRegistry::definitionsByKey();

Exception Handling

If you attempt to retrieve a prompt that hasn't been registered, the registry will throw an \InvalidArgumentException. This enforces strict configuration correctness.

use IllumaLaw\PromptRegistry\Facades\PromptRegistry;

try {
    $definition = PromptRegistry::forKey('agents.unknown');
} catch (\InvalidArgumentException $e) {
    // "No prompt definition was registered for key [agents.unknown]."
}

Dependency Injection

You can resolve the underlying PromptRegistryManager from the Laravel container directly if you prefer dependency injection over Facades:

namespace App\Services;

use IllumaLaw\PromptRegistry\PromptRegistryManager;

class PromptService
{
    public function __construct(
        protected PromptRegistryManager $registry
    ) {}

    public function handle(): void
    {
        $definition = $this->registry->forKey('agents.content_creator');
    }
}

Testing

The test suite uses Pest and maintains 100% code coverage.

# Run tests
composer test

# Run static analysis
composer analyse

License

The MIT License (MIT). Please see License File for more information.

illuma-law/laravel-prompt-registry 适用场景与选型建议

illuma-law/laravel-prompt-registry 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「registry」 「laravel」 「prompt」 「Agent」 「ai」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 illuma-law/laravel-prompt-registry 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 illuma-law/laravel-prompt-registry 我们能提供哪些服务?
定制开发 / 二次开发

基于 illuma-law/laravel-prompt-registry 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 62
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 39
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-20