Class: Intelligence::XAi::Adapter
- Inherits:
-
Generic::Adapter
- Object
- Adapter::Base
- Generic::Adapter
- Intelligence::XAi::Adapter
- Defined in:
- lib/intelligence/adapters/x_ai.rb
Constant Summary collapse
- DEFAULT_BASE_URI =
"https://api.x.ai/v1"
Instance Method Summary collapse
- #chat_result_error_attributes(response) ⇒ Object (also: #stream_result_error_attributes)
Methods included from ChatResponseMethods
Methods included from ChatRequestMethods
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 |