Class: Foobara::Ai::OpenAiApi::CreateChatCompletion

Inherits:
BaseCommand show all
Defined in:
foobara-open-ai-api-1.0.2/src/foobara/ai/open_ai_api/create_chat_completion.rb

Constant Summary

Constants included from TruncatedInspect

TruncatedInspect::MAX_LENGTH

Instance Method Summary collapse

Methods inherited from BaseCommand

#api_token, #api_token_from_env, #build_request_headers, #issue_http_request

Methods inherited from Command

install!

Methods included from CommandPatternImplementation

install_state_machine_callback_methods

Methods included from TruncatedInspect

#inspect, truncating

Methods included from Concern

foobara_class_methods_module_for, foobara_concern?, included

Instance Method Details

#build_request_body ⇒ Object



21
22
23
# File 'src/foobara/ai/open_ai_api/create_chat_completion.rb', line 21

def build_request_body
  self.request_body = { model:, messages:, temperature: }
end

#build_result ⇒ Object



25
26
27
28
29
30
31
# File 'src/foobara/ai/open_ai_api/create_chat_completion.rb', line 25

def build_result
  Types::ChatCompletion.new(
    response_body,
    # Set to false and run test suite with new cassettes if trying to find new attributes
    ignore_unexpected_attributes: true
  )
end