Class: Ace::LLM::Molecules::FormatHandlers::Markdown

Inherits:
Base
  • Object
show all
Defined in:
lib/ace/llm/molecules/format_handlers.rb

Overview

Markdown format handler

Instance Method Summary collapse

Methods inherited from Base

#build_cost_summary, #format_cost, #generate_summary

Instance Method Details

#format(response, **_options) ⇒ String

Format response as Markdown with YAML front matter

Parameters:

  • response (Hash)

    Response with :text and normalized metadata

  • options (Hash)

    Additional formatting options

Returns:

  • (String)

    Markdown formatted output



131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/ace/llm/molecules/format_handlers.rb', line 131

def format(response, **_options)
  validate_response(response)

   = response[:metadata] || {}
  content = response[:text]

  if .empty?
    content
  else
    # Create YAML front matter
    yaml_front_matter = .to_yaml.chomp
    "#{yaml_front_matter}\n---\n\n#{content}"
  end
end