Text to SQL with LLM

Text to SQL Generation with LLM | Parseable

Parseable supports LLM-based SQL generation, leveraging the power of OpenAI's language models (LLMs). With this feature, you can use natural language to generate SQL queries for analyzing your logs effortlessly.

Setup and Configuration

To get started with LLM-based SQL generation, follow these steps:

  • Obtain OpenAI API token from this link.
  • Set the P_OPENAI_API_KEY environment variable to the API token obtained in the previous step.

Once the P_OPENAI_API_KEY variable is set, Parseable will automatically detect it and provide you with a input text field in the UI where you can enter natural language queries to generate SQL.

Data Mapping to Ensure Valid SQL

To generate SQL that matches your table structure accurately, Parseable includes your table schema in the query sent to the LLM. This schema includes just th column names and their data types. This ensures that the SQL generated is valid and aligns with your table definition. No other data is shared to the LLM used.

Note\

  • The LLM only generates the SQL. It doesn't run the query until you manually hit the Run button.
  • You have the option to tweak the SQL generated further to your liking before finally running it.

Roadmap

In addition to supporting OpenAI, we aim to integrate with other popular LLMs, including open-source and self-hostable LLMs like LLaMa. Stay tuned for more updates!

Updated on