Class: CleoQualityReview::LlmProviders::OpenAi::Client

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

Overview

Client for the OpenAI Responses API.

Constant Summary collapse

RESPONSES_API_URL =
URI("https://api.openai.com/v1/responses")

Instance Method Summary collapse

Constructor Details

#initialize(config:, http_transport: HttpTransport.new) ⇒ Client

Returns a new instance of Client.

Parameters:

  • config (Config)

    OpenAI configuration

  • http_transport (HttpTransport) (defaults to: HttpTransport.new)

    transport layer for HTTP requests



85
86
87
88
# File 'lib/cleo_quality_review/llm_providers/open_ai.rb', line 85

def initialize(config:, http_transport: HttpTransport.new)
  @config = config
  @http_transport = http_transport
end

Instance Method Details

#generate_review(prompt, instructions: nil) ⇒ String

Generate a review using the OpenAI Responses API.

Parameters:

  • prompt (String)

    the format-specific prompt to send as input

  • instructions (String, nil) (defaults to: nil)

    shared configuration prompt sent as the system-level instructions applied to every run

Returns:

  • (String)

    generated review text

Raises:

  • (ApiError)

    if the API request fails



97
98
99
100
# File 'lib/cleo_quality_review/llm_providers/open_ai.rb', line 97

def generate_review(prompt, instructions: nil)
  response = execute_request(request_body(prompt, instructions))
  parse_response(response)
end