Class: Postnhost::Translation::OpenaiLlmClient

Inherits:
Object
  • Object
show all
Defined in:
app/services/postnhost/translation/openai_llm_client.rb

Constant Summary collapse

DEFAULT_MODEL =
"gpt-5.6-luna"
TIMEOUT =
1240

Instance Method Summary collapse

Constructor Details

#initialize(client: nil) ⇒ OpenaiLlmClient

Returns a new instance of OpenaiLlmClient.



7
8
9
# File 'app/services/postnhost/translation/openai_llm_client.rb', line 7

def initialize(client: nil)
  @client = client
end

Instance Method Details

#text_response(prompt, model: Postnhost.config.openai_gpt_model || DEFAULT_MODEL) ⇒ Object



11
12
13
14
15
16
17
18
# File 'app/services/postnhost/translation/openai_llm_client.rb', line 11

def text_response(prompt, model: Postnhost.config.openai_gpt_model || DEFAULT_MODEL)
  response = client.responses.create(
    model: model,
    input: prompt
  )

  response.output_text.strip
end