Class: Intelligence::XAi::Adapter

Inherits:
Generic::Adapter show all
Defined in:
lib/intelligence/adapters/x_ai.rb

Constant Summary collapse

DEFAULT_BASE_URI =
"https://api.x.ai/v1"

Instance Method Summary collapse

Methods included from ChatResponseMethods

#result

Methods included from ChatRequestMethods

#receive_result

Instance Method Details

#chat_result_error_attributes(response) ⇒ Object Also known as: stream_result_error_attributes



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/intelligence/adapters/x_ai.rb', line 41

def chat_result_error_attributes( response )
  error_type, error_description = to_error_response( response.status )
  error = error_type 

  parsed_body = JSON.parse( response.body, symbolize_names: true ) rescue nil 
  if parsed_body && parsed_body.respond_to?( :[] )
    error = parsed_body[ :code ] || error_type 
    error_description = parsed_body[ :error ] || error_description 
  end 

  { error_type: error_type.to_s, error: error.to_s, error_description: error_description }
end