Class: RubyLLM::Providers::XAI::Responses
- Inherits:
-
RubyLLM::Protocols::Responses
- Object
- RubyLLM::Protocol
- RubyLLM::Protocols::ChatCompletions
- RubyLLM::Protocols::Responses
- RubyLLM::Providers::XAI::Responses
- Includes:
- RubyLLM::Protocols::Responses::Compaction, RubyLLM::Protocols::XAI::StreamingTranscription, RubyLLM::Protocols::XAI::Tokenization, Images, Models, ReportedCost, Speech, Transcription, Videos
- Defined in:
- lib/ruby_llm/providers/xai/responses.rb
Overview
xAI's dialect of the OpenAI Responses API, the primary protocol for Grok models. Usage counts agentic tool activity.
Constant Summary collapse
- SERVER_TOOL_ALIASES =
{ web_search: { tool: { type: 'web_search' } }, x_search: { tool: { type: 'x_search' } }, code_execution: { tool: { type: 'code_execution' } }, code_interpreter: { tool: { type: 'code_interpreter' } }, file_search: { tool: { type: 'file_search' } }, collections_search: { tool: { type: 'file_search' } }, image_generation: { tool: { type: 'image_generation' } }, mcp: Protocols::Responses::SERVER_TOOL_ALIASES.fetch(:mcp) }.freeze
- SERVER_TOOL_USAGE_COUNTERS =
%w[num_sources_used num_server_side_tools_used].freeze
Constants included from RubyLLM::Protocols::XAI::StreamingTranscription
RubyLLM::Protocols::XAI::StreamingTranscription::ENCODINGS, RubyLLM::Protocols::XAI::StreamingTranscription::SAMPLE_RATES
Constants included from Models
Constants included from ReportedCost
RubyLLM::Providers::XAI::ReportedCost::USD_PER_TICK
Instance Attribute Summary
Attributes inherited from RubyLLM::Protocol
#config, #connection, #model, #provider
Instance Method Summary collapse
Methods included from RubyLLM::Protocols::XAI::StreamingTranscription
#build_streamed_transcription, #duplicate_transcription_segment?, #parse_transcription_segment, #process_transcription_event, #process_transcription_segment, #receive_streamed_transcription, #send_transcription_audio, #stream_transcription, #streaming_transcription_url
Methods included from RubyLLM::Protocols::Responses::Compaction
#compaction_url, #parse_compaction_response, #render_compaction_payload
Methods included from RubyLLM::Protocols::XAI::Tokenization
#parse_tokenization_response, #render_tokenization_payload, #tokenization_url
Methods included from Videos
#download_video, #parse_video_job, #parse_video_job_status, #render_video_extension_payload, #render_video_payload, #video_extension_url, #video_job_url, #video_request_url, #video_url
Methods included from Transcription
parse_transcription_response, #render_transcription_options, render_transcription_payload, transcription_url
Methods included from Speech
parse_speech_response, render_speech_payload, speech_url, stream_speech
Methods included from Models
audio_models, parse_list_models_response
Methods included from Images
blank_attachment?, editing?, image_reference_url, image_references, images_url, parse_image_response, parse_image_responses, render_edit_payload, render_image_payload, validate_paint_inputs!
Methods inherited from RubyLLM::Protocol
abstract, #animate_later, #apply_compaction, #apply_compaction_headers, #apply_end_user, #cache_content, #compact, #complete, #count_tokens, #delete_cache, #embed, #extend_cache, #find_cache, #initialize, #list_models, #moderate, #ocr, #paint, #parse_error, #parse_image_responses, #post_image, #post_video, #preprocess_message, #raise_transcription_streaming_unsupported, #refresh_video_job, #render, #render_embedding, #render_transcription_options, #render_video_extension_payload, #rerank, #speak, #stream_speech, #stream_speech_response, #stream_transcription, #supports_embedding_media?, #tokenize, #tool_approval_response, #transcribe, #video_extension_attachment, #video_extension_url, #video_request_url
Methods included from RubyLLM::Protocol::BinaryStreaming
Methods included from RubyLLM::Protocol::Streaming
build_on_data_handler, build_stream_error_response, error_chunk?, failed_http_status, faraday_1?, handle_data, handle_error_chunk, handle_error_event, handle_failed_response, handle_json_error_chunk, handle_sse, handle_stream, json_error_payload?, parse_error_from_json, parse_streaming_error, process_stream_chunk, raise_stream_error, stream_events, stream_response, stream_state
Constructor Details
This class inherits a constructor from RubyLLM::Protocol
Instance Method Details
#parse_usage(usage) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/ruby_llm/providers/xai/responses.rb', line 36 def parse_usage(usage) super.merge( server_tool_use: server_side_tool_usage(usage), reported_cost: reported_cost(usage) ) end |
#server_tool_aliases ⇒ Object
32 33 34 |
# File 'lib/ruby_llm/providers/xai/responses.rb', line 32 def server_tool_aliases SERVER_TOOL_ALIASES end |