Class: Purizumu::Engines::Xai
- Inherits:
-
Object
- Object
- Purizumu::Engines::Xai
- Defined in:
- lib/purizumu/engines/xai.rb,
lib/purizumu/engines/xai/payload_builder.rb,
lib/purizumu/engines/xai/response_parser.rb
Overview
Translation engine that uses xAI and forces a function tool response.
Defined Under Namespace
Classes: PayloadBuilder, ResponseParser
Constant Summary collapse
- TOOL_NAME =
'return_translation'
Instance Method Summary collapse
-
#initialize(configuration:) ⇒ Xai
constructor
A new instance of Xai.
- #translate(model_name:, attribute_name:, content:, locale:, source_locale:) ⇒ Object
Constructor Details
#initialize(configuration:) ⇒ Xai
Returns a new instance of Xai.
9 10 11 |
# File 'lib/purizumu/engines/xai.rb', line 9 def initialize(configuration:) @configuration = configuration end |
Instance Method Details
#translate(model_name:, attribute_name:, content:, locale:, source_locale:) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/purizumu/engines/xai.rb', line 13 def translate(model_name:, attribute_name:, content:, locale:, source_locale:) validate_configuration! response = transport.call( uri, request_headers, request_body(model_name:, attribute_name:, content:, locale:, source_locale:) ) ResponseParser.new(response:).translated_text end |