Class: CleoQualityReview::LlmProviders::Stub::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/cleo_quality_review/llm_providers/stub.rb

Overview

Stub LLM client, mirrors OpenAi::Client interface.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ Client

Returns a new instance of Client.

Parameters:

  • config (Config)

    stub configuration



61
62
63
64
# File 'lib/cleo_quality_review/llm_providers/stub.rb', line 61

def initialize(config:)
  @config = config
  @received_prompts = []
end

Instance Attribute Details

#received_promptsObject (readonly)

Returns the value of attribute received_prompts.



57
58
59
# File 'lib/cleo_quality_review/llm_providers/stub.rb', line 57

def received_prompts
  @received_prompts
end

Instance Method Details

#generate_review(prompt) ⇒ String

Generate a review by returning the configured response.

Parameters:

  • prompt (String)

    the prompt sent

Returns:

  • (String)

    the configured response



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/cleo_quality_review/llm_providers/stub.rb', line 70

def generate_review(prompt)
  received_prompts << prompt
  response = config.response

  case response
  when Proc
    response.call(prompt)
  else
    response.to_s
  end
end