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

Copy Markdown View Source

System prompts for AI-powered query optimization suggestions.

Summary

Functions

Parse the AI response into a list of suggestion maps.

Generate system prompt for query optimization analysis.

Build the user prompt containing the SQL and execution plan.

Functions

parse_suggestions(content)

@spec parse_suggestions(String.t()) :: [map()]

Parse the AI response into a list of suggestion maps.

Returns a list of validated suggestion maps or an empty list if parsing fails.

system_prompt(database_type)

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

Generate system prompt for query optimization analysis.

Parameters

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

user_prompt(sql, execution_plan, schema_context \\ nil)

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

Build the user prompt containing the SQL and execution plan.

Parameters

  • sql - The SQL query to optimize
  • execution_plan - The execution plan string (from EXPLAIN)
  • schema_context - Optional schema context string