Class: Purizumu::Engines::Xai::ResponseParser
- Inherits:
-
Object
- Object
- Purizumu::Engines::Xai::ResponseParser
- Defined in:
- lib/purizumu/engines/xai/response_parser.rb
Overview
Extracts the required tool payload from xAI responses.
Instance Method Summary collapse
-
#initialize(response:) ⇒ ResponseParser
constructor
A new instance of ResponseParser.
- #translated_text ⇒ Object
Constructor Details
#initialize(response:) ⇒ ResponseParser
Returns a new instance of ResponseParser.
8 9 10 |
# File 'lib/purizumu/engines/xai/response_parser.rb', line 8 def initialize(response:) @response = response end |
Instance Method Details
#translated_text ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/purizumu/engines/xai/response_parser.rb', line 12 def translated_text raise TranslationError, if response_error? extract_translation(parsed_body) rescue JSON::ParserError => e raise TranslationError, "Unable to parse xAI response: #{e.}" rescue KeyError => e raise TranslationError, "xAI response missing translation payload: #{e.}" end |