Lotus.AI.Prompts.Explanation (Lotus v0.16.5)

Copy Markdown View Source

Prompts for AI-powered SQL query explanations.

Summary

Functions

Build the user prompt for explaining a fragment in context of the full query.

Generate system prompt for query explanation.

Build the user prompt for a full query explanation.

Functions

fragment_prompt(fragment, full_sql, schema_context \\ nil)

@spec fragment_prompt(String.t(), String.t(), String.t() | nil) :: String.t()

Build the user prompt for explaining a fragment in context of the full query.

The fragment is the portion the user highlighted/selected. The full query provides necessary context so the LLM can explain even isolated terms (e.g., a single JOIN clause, a HAVING condition, or a function call).

Parameters

  • fragment - The selected SQL fragment to explain
  • full_sql - The complete SQL query for context
  • schema_context - Optional schema context string

system_prompt(database_type)

@spec system_prompt(atom()) :: String.t()

Generate system prompt for query explanation.

Parameters

  • database_type - Database type (e.g., :postgres, :mysql, :sqlite)

user_prompt(sql, schema_context \\ nil)

@spec user_prompt(String.t(), String.t() | nil) :: String.t()

Build the user prompt for a full query explanation.

Parameters

  • sql - The full SQL query to explain
  • schema_context - Optional schema context string