Giter Site home page Giter Site logo

sebacarrasco93 / laravel-ask-database Goto Github PK

View Code? Open in Web Editor NEW

This project forked from beyondcode/laravel-ask-database

0.0 0.0 1.0 47 KB

Query your database using natural language

Home Page: https://beyondco.de/blog/query-your-laravel-database-using-natural-language

License: MIT License

PHP 93.25% Blade 6.75%

laravel-ask-database's Introduction

Laravel Ask DB: Natural Language Database Query Builder

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.

laravel-ask-database's People

Contributors

mpociot avatar sebacarrasco93 avatar hafezdivandari avatar tomlloyd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.