Class: SqlGenius::Core::Ai::InnodbInterpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/sql_genius/core/ai/innodb_interpreter.rb

Overview

Interprets SHOW ENGINE INNODB STATUS output in plain English. Combines the raw InnoDB status text with key metrics from ServerOverview to give the LLM full context for its analysis.

Constant Summary collapse

MAX_STATUS_LENGTH =
4000

Instance Method Summary collapse

Constructor Details

#initialize(client, config, connection) ⇒ InnodbInterpreter

Returns a new instance of InnodbInterpreter.



12
13
14
15
16
# File 'lib/sql_genius/core/ai/innodb_interpreter.rb', line 12

def initialize(client, config, connection)
  @client = client
  @config = config
  @connection = connection
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sql_genius/core/ai/innodb_interpreter.rb', line 18

def call
  if @connection.server_version.postgresql?
    raise Core::UnsupportedDialect.for_postgresql("InnoDB Health Interpreter")
  end

  status_text = fetch_innodb_status
  metrics = fetch_innodb_metrics

  messages = [
    { role: "system", content: system_prompt },
    { role: "user",   content: user_prompt(status_text, metrics) },
  ]
  @client.chat(messages: messages)
end