Class: LLM::DeepSeek::Format::CompletionFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format/completion_format.rb

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ CompletionFormat

Returns a new instance of CompletionFormat.

Parameters:



10
11
12
# File 'lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format/completion_format.rb', line 10

def initialize(message)
  @message = message
end

Instance Method Details

#formatHash

Formats the message for the DeepSeek chat completions API

Returns:

  • (Hash)


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/llm/shell/internal/llm.rb/lib/llm/providers/deepseek/format/completion_format.rb', line 17

def format
  catch(:abort) do
    if Hash === message
      {role: message[:role], content: format_content(message[:content])}
    elsif message.tool_call?
      {role: message.role, content: nil, tool_calls: message.extra[:original_tool_calls]}
    else
      format_message
    end
  end
end