Class: Purizumu::Engines::Xai

Inherits:
Object
  • Object
show all
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

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