Class: Zwischen::AI::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/zwischen/ai/analyzer.rb

Instance Method Summary collapse

Constructor Details

#initialize(provider: "claude", api_key: nil, config: {}, project_context: {}) ⇒ Analyzer

Returns a new instance of Analyzer.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/zwischen/ai/analyzer.rb', line 11

def initialize(provider: "claude", api_key: nil, config: {}, project_context: {})
  @project_context = project_context
  
  client_class = case provider.to_s.downcase
                 when "claude", "anthropic" then AnthropicClient
                 when "ollama" then OllamaClient
                 when "openai" then OpenAIClient
                 else
                   # Fallback or error
                   AnthropicClient
                 end

  @client = client_class.new(api_key: api_key, config: config)
end

Instance Method Details

#analyze(findings) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/zwischen/ai/analyzer.rb', line 26

def analyze(findings)
  return findings if findings.empty?

  prompt = build_prompt(findings)
  response = @client.analyze(prompt)

  enhance_findings(findings, response)
rescue AI::Error => e
  warn "AI analysis failed: #{e.message}. Returning original findings."
  findings
rescue StandardError => e
  warn "AI analysis failed: #{e.message}. Returning original findings."
  findings
end