Class: AIRecordFinder::AIAdapter
- Inherits:
-
Object
- Object
- AIRecordFinder::AIAdapter
- Defined in:
- lib/ai_record_finder/ai_adapter.rb
Overview
Converts natural language + schema prompt into parsed DSL JSON.
Instance Method Summary collapse
- #call(system_prompt:, user_prompt:) ⇒ Object
-
#initialize(client:) ⇒ AIAdapter
constructor
A new instance of AIAdapter.
Constructor Details
#initialize(client:) ⇒ AIAdapter
Returns a new instance of AIAdapter.
8 9 10 |
# File 'lib/ai_record_finder/ai_adapter.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#call(system_prompt:, user_prompt:) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/ai_record_finder/ai_adapter.rb', line 12 def call(system_prompt:, user_prompt:) raw_content = @client.chat_completion(system_prompt: system_prompt, user_prompt: user_prompt) parse_json(extract_json(raw_content)) rescue AIResponseError raise rescue StandardError => e raise AIResponseError, "Failed to parse AI response: #{e.}" end |