Lotus.AI.Prompts.Explanation (Lotus v1.0.0)

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, source_context \\ nil, fence \\ "sql")

@spec fragment_prompt(String.t(), String.t(), String.t() | nil, String.t()) ::
  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 fragment to explain
  • full_sql - The complete query for context
  • source_context - Optional source context string
  • fence - Markdown fence label for the statement blocks, from Lotus.AI.Prompts.AdapterNotes.fence_label/1

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, source_context \\ nil, fence \\ "sql")

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

Build the user prompt for a full query explanation.

Parameters