Class: LLM::OpenAI::Format::RespondFormat

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

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ RespondFormat

Returns a new instance of RespondFormat.



7
8
9
# File 'lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/respond_format.rb', line 7

def initialize(message)
  @message = message
end

Instance Method Details

#formatObject



11
12
13
14
15
16
17
18
19
# File 'lib/llm/shell/internal/llm.rb/lib/llm/providers/openai/format/respond_format.rb', line 11

def format
  catch(:abort) do
    if Hash === message
      {role: message[:role], content: format_content(message[:content])}
    else
      format_message
    end
  end
end