Class: RubyLLM::Providers::DeepSeek::Responses
Overview
DeepSeek's dialect of the OpenAI Responses API.
Reasoning arrives as reasoning_text content parts
instead of summaries, both in responses and in the stream.
Constant Summary
collapse
- SERVER_TOOL_ALIASES =
{
apply_patch: { tool: { type: 'custom', name: 'apply_patch' } }
}.freeze
Instance Attribute Summary
#config, #connection, #model, #provider
Instance Method Summary
collapse
abstract, #animate_later, #apply_compaction, #apply_compaction_headers, #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
#stream_binary
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
Instance Method Details
#apply_end_user(payload, identifier) ⇒ Object
18
19
20
|
# File 'lib/ruby_llm/providers/deepseek/responses.rb', line 18
def apply_end_user(payload, identifier)
payload.merge(user_id: identifier)
end
|
#build_chunk(data) ⇒ Object
22
23
24
25
26
|
# File 'lib/ruby_llm/providers/deepseek/responses.rb', line 22
def build_chunk(data)
return chunk(thinking: Thinking.build(text: data['delta'])) if data['type'] == 'response.reasoning_text.delta'
super
end
|
36
37
38
39
40
41
|
# File 'lib/ruby_llm/providers/deepseek/responses.rb', line 36
def format_assistant_items(message)
items = super
return items if message.raw_content || message.thinking&.text.to_s.empty? || message.thinking.signature
items.unshift(format_reasoning_item(message.thinking))
end
|
61
62
63
|
# File 'lib/ruby_llm/providers/deepseek/responses.rb', line 61
def format_document(document)
raise UnsupportedAttachmentError, document.mime_type
end
|
55
56
57
58
59
|
# File 'lib/ruby_llm/providers/deepseek/responses.rb', line 55
def format_provider_file(file)
raise UnsupportedAttachmentError, file.mime_type unless file.image?
{ type: 'input_image', file_id: file.provider_file_id }
end
|
43
44
45
|
# File 'lib/ruby_llm/providers/deepseek/responses.rb', line 43
def format_reasoning_item(thinking)
{ type: 'reasoning', content: [{ type: 'reasoning_text', text: thinking.text }] }
end
|
47
48
49
50
51
52
53
|
# File 'lib/ruby_llm/providers/deepseek/responses.rb', line 47
def format_tool_items(message)
[{
type: 'function_call_output',
call_id: message.tool_call_id,
output: format_content(message.content, message.attachments)
}]
end
|
#parse_reasoning_summary(output) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/ruby_llm/providers/deepseek/responses.rb', line 28
def parse_reasoning_summary(output)
texts = output.select { |item| item['type'] == 'reasoning' }.flat_map do |item|
Array(item['content']).filter_map { |part| part['text'] if part['type'] == 'reasoning_text' }
end
texts.empty? ? super : texts.join("\n")
end
|
14
15
16
|
# File 'lib/ruby_llm/providers/deepseek/responses.rb', line 14
def server_tool_aliases
SERVER_TOOL_ALIASES
end
|