定制 sebacarrasco93/laravel-ask-database 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

sebacarrasco93/laravel-ask-database

Composer 安装命令:

composer require sebacarrasco93/laravel-ask-database

包简介

Use natural language and AI to query your database from Laravel

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Notes

This package is meant to be a learning resource for prompt engineering and how to achieve AI-generated query generation with PHP/Laravel. You should probably not use this in production

The original package created by Beyond Code has been archived, also, it uses hardcoded text-davinci-003 model, and has been deprecated. However, this version supports custom specific models. You can change it into config/ask-database.php file, or into your .env

Ask DB allows you to use OpenAI's GPT to build natural language database queries.

DB::ask('How many users do we have on the "pro" plan?');

// We have 23 users with "pro" plan.

Installation

Install the package via composer:

composer require sebacarrasco93/laravel-ask-database

Publish the config files with:

php artisan vendor:publish --tag="ask-database-config"
php artisan vendor:publish --provider="OpenAI\Laravel\ServiceProvider"

What about accidental deletions, updates or inserts? By default it's protecting by enabling strict mode. You can disable it. Do this at your own risk

// config/ask-database.php

'strict_mode' => env('ASK_DATABASE_STRICT_MODE', true),

Usage

First, you to configure your OpenAI API key in your .env file:

OPENAI_API_KEY=sk-...

By default it's using gpt-3.5-turbo-instruct. Optionally you can customize it

ASK_DATABASE_MODEL=gpt-3.5-turbo-instruct

Then, you can use the DB::ask() method to ask the database:

$response = DB::ask('How many users are there?');

// We have 100 users

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固