承接 papi-ai/laravel 相关项目开发

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

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

papi-ai/laravel

最新稳定版本:v0.9.1

Composer 安装命令:

composer require papi-ai/laravel

包简介

Laravel bridge for PapiAI - AI agent library

README 文档

README

CI Latest Version Total Downloads PHP Version License

Laravel integration for the PapiAI AI agent library. Provides a service provider, facade, Eloquent conversation store, and queue integration.

Installation

composer require papi-ai/laravel

The service provider is auto-discovered by Laravel. No manual registration needed.

Configuration

Publish the configuration file:

php artisan vendor:publish --tag=papi-config

This creates config/papi.php where you can configure:

  • Default provider -- which AI provider to use (openai, anthropic, etc.)
  • Provider settings -- API keys, models, and driver classes
  • Middleware -- middleware classes applied to all agents
  • Conversation storage -- file-based or Eloquent-based

Environment Variables

PAPI_PROVIDER=openai
OPENAI_API_KEY=your-openai-key
ANTHROPIC_API_KEY=your-anthropic-key

Usage

Using the Facade

use PapiAI\Laravel\Facades\Papi;

// Simple prompt
$response = Papi::run('What is the capital of France?');
echo $response->text;

// Streaming
foreach (Papi::stream('Tell me a story') as $chunk) {
    echo $chunk->text;
}

Resolving from the Container

// Get the configured provider
$provider = app('papi');

// Get the pre-configured agent
$agent = app('papi.agent');
$response = $agent->run('Hello!');

Adding Tools

use PapiAI\Laravel\Facades\Papi;

Papi::addTool(new MyCustomTool());
$response = Papi::run('Use my tool to do something');

Middleware

Configure middleware in config/papi.php:

'middleware' => [
    \PapiAI\Core\Middleware\LoggingMiddleware::class,
    \PapiAI\Core\Middleware\RetryMiddleware::class,
],

Or add middleware at runtime:

use PapiAI\Laravel\Facades\Papi;

Papi::addMiddleware(new RateLimitMiddleware(maxRequests: 10));

Conversation Storage

Switch to Eloquent-based storage in config/papi.php:

'conversation' => [
    'store' => 'eloquent',
],

The Eloquent store uses the papi_conversations table. Create a migration:

Schema::create('papi_conversations', function (Blueprint $table) {
    $table->string('id')->primary();
    $table->json('data');
    $table->timestamp('updated_at')->nullable();
});

Queue Integration

Dispatch agent jobs to Laravel queues:

use PapiAI\Laravel\Queue\LaravelQueue;
use PapiAI\Core\AgentJob;

$queue = app(LaravelQueue::class);

$jobId = $queue->dispatch(new AgentJob(
    agentClass: MyAgent::class,
    prompt: 'Process this in the background',
));

$status = $queue->status($jobId);

Requirements

  • PHP 8.2+
  • Laravel 10, 11, or 12
  • papi-ai/papi-core ^0.9

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固