Class: AIRecordFinder::Providers::Base
- Inherits:
-
Object
- Object
- AIRecordFinder::Providers::Base
- Defined in:
- lib/ai_record_finder/providers/base.rb
Overview
Shared HTTP transport for chat-style LLM providers.
Subclasses implement the provider-specific contract:
#endpoint_path, #request_headers, #request_payload, #extract_content
Endpoint paths MUST be relative (no leading slash) so they append to the configured base URL’s path (e.g. “…/v1”) instead of replacing it.
Instance Method Summary collapse
- #chat_completion(system_prompt:, user_prompt:) ⇒ Object
-
#initialize(configuration:, connection: nil) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(configuration:, connection: nil) ⇒ Base
Returns a new instance of Base.
16 17 18 19 20 |
# File 'lib/ai_record_finder/providers/base.rb', line 16 def initialize(configuration:, connection: nil) @configuration = configuration @connection = connection validate_configuration! end |
Instance Method Details
#chat_completion(system_prompt:, user_prompt:) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/ai_record_finder/providers/base.rb', line 22 def chat_completion(system_prompt:, user_prompt:) response = post_request(system_prompt, user_prompt) ensure_success!(response) extract_content(parse_body(response)) rescue Faraday::Error => e raise AIResponseError, "AI request failed: #{e.}" end |