Class: Olyx::Guardrails::LlmAnalysis

Inherits:
Object
  • Object
show all
Defined in:
lib/olyx/guardrails/llm_analysis.rb

Overview

Normalizes and bounds responses from an untrusted optional LLM provider.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider, text, context) ⇒ LlmAnalysis

Returns a new instance of LlmAnalysis.



13
14
15
16
17
# File 'lib/olyx/guardrails/llm_analysis.rb', line 13

def initialize(provider, text, context)
  @provider = provider
  @text = text
  @context = context
end

Class Method Details

.call(provider, text, context) ⇒ Object



9
10
11
# File 'lib/olyx/guardrails/llm_analysis.rb', line 9

def self.call(provider, text, context)
  new(provider, text, context).call
end

Instance Method Details

#callObject



19
20
21
22
23
# File 'lib/olyx/guardrails/llm_analysis.rb', line 19

def call
  Llm::AnalysisPipeline.call(@provider.call(@text, @context))
rescue StandardError => error
  { error: error.message.to_s[0..200] }
end