laravel-ask-database  by beyondcode

Laravel package for natural language database querying

created 2 years ago
305 stars

Top 88.8% on sourcepulse

GitHubView on GitHub
Project Summary

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

  • Install via Composer: composer require beyondcode/laravel-ask-database
  • Configure OpenAI API key in .env: OPENAI_API_KEY=sk-...
  • Publish config: php artisan vendor:publish --tag="ask-database-config"
  • Requires PHP and a Laravel environment.

Highlighted Details

  • Facilitates natural language database interaction within Laravel.
  • Configurable strict mode to prevent unintended database writes.
  • Handles schema complexity with an adaptive table lookup mechanism.
  • Designed as a learning tool for prompt engineering with AI.

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.

Health Check
Last commit

1 year ago

Responsiveness

1+ week

Pull Requests (30d)
0
Issues (30d)
0
Star History
6 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.