承接 devdojo/ai 相关项目开发

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

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

devdojo/ai

Composer 安装命令:

composer require devdojo/ai

包简介

This is a package that simplifies communicating with AI services using PrismPHP

关键字:

README 文档

README

Latest Version on Packagist Total Downloads

This package provides you with a global ai() method to easily get responses from your favorite AI provider. Here are a few examples:

$response = ai('What is the meaning of life?');

Or capture the streamed response in a callback

$response = ai('What color is the sky?', function($chunk){
    // $chunk will contain the stream text response
});

Video Example

ai-functionality.mp4

Installation

You can install the package via composer:

composer require devdojo/ai

Usage

After you've installed the package, you'll want to add your AI Provider API Key. Out of the box DevDojo AI uses OpenAI, so you'll want to grab your OpenAI key and add it to your .env

OPENAI_API_KEY=sk-proj-aReAlLyLoNgKey...

After that, you are ready to use the ai method anywher in your app:

Route::get('question', function(){
    echo ai('What is the meaning of life?');
});

You can also capture the streamed response, by passing a callback as the second argument.

public function submit($input)
{
    $this->output = ai($input, function($chunk){
        logger($chunk);
    });
}

This makes it super easy to return streamed responses in your Livewire components. In fact, this package offers two Single-File Volt component examples.

Examples

You can publish a few examples by running:

php artisan ai:install-examples

This will publish two component examples to your project.

  1. basic-example.blade.php (a basic example of sending a message and getting a streamed response back)
  2. chat-example.blade.php (a chat example to show you how to pass an array of messages to create a conversation)

This will allow you to include those example components anywhere in your application.

<livewire:basic-example />
<livewire:chat-example />

You can easily test this out by utilizing the Livewire Starter Kit, Installing this package, Adding your API Key to .env, and then pasting the following into the welcome.blade.php file:

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>AI Examples</title>
        @vite(['resources/css/app.css', 'resources/js/app.js'])
    </head>
    <body class="w-screen h-screen flex items-center bg-stone-100 justify-center">
        <div class="w-full max-w-7xl gap-5 mx-auto flex items-stretch">
            <div class="h-full flex-1 p-10 space-y-5 rounded-xl bg-white shadow-sm">
                <h2 class="text-xl font-semibold">Basic Example</h2>
                <livewire:basic-example />
            </div>
            <div class="h-full flex-1 mx-auto p-10 space-y-5 rounded-xl bg-white shadow-sm">
                <h2 class="text-xl font-semibold">Chat Example</h2>
                <livewire:chat-example />
            </div>
        </div>
    </body>
</html>

Make sure your asset running is watching via composer dev or npm run dev.

Now you will be able to see the basic and chat example fully functioning and communicating with your favorite AI service.

ai-functionality.mp4

Configuration

If you would like to change the AI provider and the AI model, you can specify the following .env variables:

AI_DEFAULT_PROVIDER=openai
AI_DEFAULT_MODEL=gpt-4

You can also publish the AI config file that will live at config/ai.php:

<?php

return [
    /*
    |--------------------------------------------------------------------------
    | AI Configuration
    |--------------------------------------------------------------------------
    |
    | Configuration options for the DevDojo AI package.
    |
    */

    'default_provider' => env('AI_DEFAULT_PROVIDER', 'openai'),
    'default_model' => env('AI_DEFAULT_MODEL', 'gpt-4'),
];

PrismPHP

This package doesn't really do much else besides providing you with an easy to use global ai() method. Most of the magic comes from PrismPHP, you may wish to abstract this into your own global ai() method. All providers that are available via Prism are also supported in this package.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email tony@devdojo.com instead of using the issue tracker.

Credits

License

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

devdojo/ai 适用场景与选型建议

devdojo/ai 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.13k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2025 年 08 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 devdojo/ai 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 2.13k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-20