Lotus.AI.QueryExplainer (Lotus v0.16.5)

Copy Markdown View Source

Generates AI-powered plain-language explanations for SQL queries.

Supports explaining a full query or a selected fragment in context of the full query.

Summary

Functions

Generate a plain-language explanation for a SQL query or fragment.

Functions

explain_query(model_string, opts)

@spec explain_query(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Generate a plain-language explanation for a SQL query or fragment.

Options

  • :sql (required) - The full SQL query
  • :fragment (optional) - A selected portion of the query to explain
  • :data_source (required) - Name of the data source
  • :api_key (required) - API key for the LLM provider
  • :temperature (optional) - LLM temperature (default: 0.2)

Returns

  • {:ok, result} - Map with :explanation, :model, and :usage
  • {:error, term} - Error tuple