Class: RubyLLM::Registry::Exporter
- Inherits:
-
Object
- Object
- RubyLLM::Registry::Exporter
- Defined in:
- lib/ruby_llm/registry/exporter.rb
Overview
Serializes prompt objects into portable formats.
Instance Method Summary collapse
-
#initialize(prompt) ⇒ Exporter
constructor
A new instance of Exporter.
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
- #to_markdown ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(prompt) ⇒ Exporter
Returns a new instance of Exporter.
10 11 12 |
# File 'lib/ruby_llm/registry/exporter.rb', line 10 def initialize(prompt) @prompt = prompt end |
Instance Method Details
#to_h ⇒ Object
14 15 16 |
# File 'lib/ruby_llm/registry/exporter.rb', line 14 def to_h prompt.to_h end |
#to_json(*args) ⇒ Object
22 23 24 |
# File 'lib/ruby_llm/registry/exporter.rb', line 22 def to_json(*args) JSON.pretty_generate(to_h, *args) end |
#to_markdown ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/ruby_llm/registry/exporter.rb', line 26 def to_markdown <<~MARKDOWN.chomp --- #{YAML.dump(front_matter).sub(/\A---\s*\n/, "").sub(/\n\z/, "")} --- #{prompt.body} MARKDOWN end |
#to_yaml ⇒ Object
18 19 20 |
# File 'lib/ruby_llm/registry/exporter.rb', line 18 def to_yaml YAML.dump(to_h) end |