lvlup-dev/laravel-agent-editable-prompts 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

lvlup-dev/laravel-agent-editable-prompts

Composer 安装命令:

composer require lvlup-dev/laravel-agent-editable-prompts

包简介

Store agent prompts in the database, resolve concatenated text by agent slug, and ship optional Inertia + Vue CRUD pages.

README 文档

README

Latest Version on Packagist MIT Licensed

Store LLM / agent prompts in the database, group them by agent_slug, order them with priority, and resolve them at runtime as ordered segments or a single concatenated string. Optionally register an Inertia + Vue CRUD so non-developers can edit prompts without deploys.

Requires inertiajs/inertia-laravel (and a Vue/React frontend) if you use the bundled admin UI.

Quick example

use LvlupDev\AgentEditablePrompts\Services\AgentPromptService;

// Single string: all rows for this slug, sorted by priority, joined with the configured separator
$instructions = app(AgentPromptService::class)->resolve('my-agent');

// Ordered Eloquent models (e.g. Blade::render per row in your app)
$chunks = app(AgentPromptService::class)->segments('my-agent');

Installation

1. Composer

composer require lvlup-dev/laravel-agent-editable-prompts

Laravel auto-discovers AgentEditablePromptsServiceProvider (see composer.jsonextra.laravel.providers).

2. Migrations

The package loads its migration automatically. Create the table:

php artisan migrate

Default table name: agent_editable_prompts. Override with AGENT_EDITABLE_PROMPTS_TABLE (see below) if needed.

3. Configuration (recommended)

Publish the config file so you can tune behaviour and .env overrides in one place:

php artisan vendor:publish --tag=agent-editable-prompts-config

This copies config/agent-editable-prompts.php into your application. Until you publish, merged defaults from the package still apply.

4. Inertia / Vue pages (if you use the bundled CRUD)

The HTTP controllers render Inertia pages under Vendor/AgentPrompts/*. Those components must exist in your app (Vite only bundles your resources/js tree).

Publish the starter pages:

php artisan vendor:publish --tag=agent-prompts-vue

Then adapt them to your layout (e.g. wrap with your admin shell), run your frontend build, and ensure Wayfinder or your route helpers know the package routes if you link from the sidebar.

If you do not want the package routes at all, set AGENT_EDITABLE_PROMPTS_REGISTER_ROUTES=false and build your own controllers/UI while still using AgentPrompt + AgentPromptService.

5. Environment variables

All keys are optional; defaults match config/agent-editable-prompts.php.

Variable Default (if unset) Role
AGENT_EDITABLE_PROMPTS_TABLE agent_editable_prompts Database table name.
AGENT_EDITABLE_PROMPTS_SEPARATOR \n\n Separator used by AgentPromptService::resolve().
AGENT_EDITABLE_PROMPTS_PRIORITY_SORT asc asc or desc — order of priority when resolving.
AGENT_EDITABLE_PROMPTS_REGISTER_ROUTES true Set to false to disable the Inertia CRUD routes entirely.
AGENT_EDITABLE_PROMPTS_MIDDLEWARE web Comma-separated middleware list for the CRUD routes. Include web when using Inertia (session, cookies, CSRF). Example: web,auth or web,auth,admin.
AGENT_EDITABLE_PROMPTS_ROUTE_PREFIX (empty) URL prefix (no leading slash required; it is trimmed). Example: admin/admin/agent-editable-prompts.
AGENT_EDITABLE_PROMPTS_ROUTE_NAME_PREFIX (empty) Prepended to route names. Example: admin.admin.agent-editable-prompts.index.

Important: routes registered by the package are not defined in your routes/web.php; they only receive the middleware you list in AGENT_EDITABLE_PROMPTS_MIDDLEWARE. For a typical Inertia app, use at least web,auth (and your admin gate if you have one).

Usage

Model

LvlupDev\AgentEditablePrompts\Models\AgentPrompt uses the configured table and fillable fields:

  • agent_slug — logical agent (e.g. support-bot, onboarding)
  • name — human label in the UI
  • content — prompt body (your app may treat it as Blade, Markdown, etc.)
  • priority — integer; lower values sort first when priority_sort_direction is asc

Service

AgentPromptService is registered as a singleton:

$service = app(\LvlupDev\AgentEditablePrompts\Services\AgentPromptService::class);

$service->segments('my-agent'); // Collection of AgentPrompt models
$service->resolve('my-agent');  // string

HTTP routes (when enabled)

Resource basename: agent-editable-prompts.
Route parameter name: agent_prompt.

Default route names (no AGENT_EDITABLE_PROMPTS_ROUTE_NAME_PREFIX):

  • agent-editable-prompts.index
  • agent-editable-prompts.create
  • agent-editable-prompts.store
  • agent-editable-prompts.edit
  • agent-editable-prompts.update
  • agent-editable-prompts.destroy

AgentPromptService::routeName('index') respects the configured name prefix.

Scope and alternatives

This package is intentionally focused: one table, slug + priority, optional generic CRUD. It does not ship authorization policies, prompt versioning, A/B testing, or provider-specific prompt formats.

For richer CMS-style content or team workflows, consider integrating a headless CMS, a dedicated prompts product, or your own tables and UI on top of the same ideas.

Credits

laravel-agent-editable-prompts is built and maintained by LVLUP. We help businesses drive operational efficiency through strategic consulting, tailored software development, and advanced AI agent integrations.

License

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

lvlup-dev/laravel-agent-editable-prompts 适用场景与选型建议

lvlup-dev/laravel-agent-editable-prompts 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 lvlup-dev/laravel-agent-editable-prompts 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-29