Laravel package for natural language database querying
Top 88.8% on sourcepulse
This package enables querying a Laravel application's database using natural language prompts, leveraging OpenAI's GPT-3. It's primarily intended as a learning resource for prompt engineering and AI-driven query generation within PHP/Laravel, targeting developers interested in exploring this technology.
How It Works
The package integrates with OpenAI's API to translate natural language questions into SQL queries. It analyzes the database schema and the user's prompt to construct and execute a relevant SQL query, returning the results. Configuration options allow specifying the database connection, enabling strict mode to prevent write operations, and setting a threshold for table lookups to manage prompt length for OpenAI.
Quick Start & Requirements
composer require beyondcode/laravel-ask-database
.env
: OPENAI_API_KEY=sk-...
php artisan vendor:publish --tag="ask-database-config"
Highlighted Details
Maintenance & Community
Developed by Marcel Pociot and contributors. Further community and roadmap details are not explicitly provided in the README.
Licensing & Compatibility
Licensed under the MIT License (MIT). This license is permissive and generally compatible with commercial and closed-source applications.
Limitations & Caveats
The package is explicitly stated to be a learning resource and not recommended for production use. Its effectiveness is dependent on the quality of prompts and OpenAI's interpretation, which can lead to unexpected or incorrect SQL queries.
1 year ago
1+ week