thomasgenster/laragpt 问题修复 & 功能扩展

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

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

thomasgenster/laragpt

Composer 安装命令:

composer require thomasgenster/laragpt

包简介

Laravel chatgpt package, includes models listing and retrieving, completions prediction, chat completion from conversation, edits, images creation, image edit, image variations, audio translation and transcription.

README 文档

README

Get the power of OpenAI's APIs with laragpt.

Laragpt is the perfect package for developers wanting to access the powerful Artificial Intelligence capabilities of OpenAI through an easy to use Laravel interface. With laragpt you can quickly get up and running with OpenAI’s powerful deep learning algorithms, natural language processing, and machine learning capabilities, allowing for the development of innovative and complex applications. By taking advantage of the OpenAI API and Laravel’s simple interfaces, laragpt makes it easy to integrate AI into your projects. Give your apps the intelligence of OpenAI with laragpt.

Installation

You can install the package via composer:

composer require jumbaeric/laragpt

publish config file

php artisan vendor:publish

and select laragpt package to publish.

Add openai api key to your env variable

OPENAI_API_KEY=

Usage

All methods return Array

use Jumbaeric\Laragpt\Laragpt;

// Complete
// Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
    $args = [
        'prompt' => 'Brainstorm some ideas combining VR and fitness', //required
        'model' => 'text-davinci-003',  //  required
    ];

    Laragpt::complete($args);

// Chat
// Given a chat conversation, the model will return a chat completion response.

Laragpt::chat([
        'model' => 'gpt-3.5-turbo', // required
        'messages' => [             // required
            [
                "role" => "system",
                "content" => "You are a helpful assistant."
            ],
            [
                "role" => "user",
                "content" => "Who won the world series in 2020?"
            ],
            [
                "role" => "assistant",
                "content" => "The Los Angeles Dodgers won the World Series in 2020."
            ],
            [
                "role" => "user",
                "content" => "Where was it played?"
            ],
        ],
        'temperature' => 1.0,   //  optional
        'max_tokens' => 4000,   //  optional
        'frequency_penalty' => 0,   //  optional
        'presence_penalty' => 0,    //  optional
    ]);

// Audio
// trascribe: Transcribes audio into the input language.
// translate: Translates audio into into English.

$type = "transcript"; // string: Required : value can be transcript or translation
Laragpt::audio([
            'model' => 'whisper-1',     //  required
            'file' => "audio.mp3",      //  required
            'prompt' => "",             //  optional
            'response_format' => '',    //  optional
            'temperature' => '',        //  optional
        ], $type);

// Edits
// Given a prompt and an instruction, the model will return an edited version of the prompt.
Laragpt::edits([
        'model' => 'text-davinci-edit-001', // required
        'input' => 'What day of the wek is it?',
        'instruction' => 'Fix the spelling mistakes',   //  required
        'n' => 1,   //  optional
        'temperature' => 1,   //  optional
        'top_p' => 1,    //  optional
    ]);

// Images
    $createArr = [ // $type = create
        'prompt' => 'A cute baby sea otter',
        'size' => '1024x1024',   //  required
        'n' => 1,   //  optional
    ] ;

    $ceateEditArr = [ // $type = createEdit
        'prompt' => 'A cute baby sea otter wearing a beret',    // required
        'image' => '@otter.png',                                //required
        'mask' => '@mask.png',
        'n' => 1,
        'size' => '1024x1024',
    ];

    $createVariationArr = [ // $type = variations
        'image' => '@otter.png',
        'n' => 2,
        'size' => '1024x1024',
    ];
    
    Laragpt::images($createArr, $type = 'create');

// Models
$model_id = null; // String : Optional : Lists all models when value is null, model set returns the model details
Laragpt::models($model_id);

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 jumbaeric@gmail.com instead of using the issue tracker.

Credits

License

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

thomasgenster/laragpt 适用场景与选型建议

thomasgenster/laragpt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.37k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 11 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-09