Class: RubyLLM::Registry::Importer

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_llm/registry/importer.rb

Overview

Deserializes prompt exports into Prompt objects.

Instance Method Summary collapse

Constructor Details

#initialize(payload, format: :auto, path: nil) ⇒ Importer

Returns a new instance of Importer.



11
12
13
14
15
# File 'lib/ruby_llm/registry/importer.rb', line 11

def initialize(payload, format: :auto, path: nil)
  @payload = payload
  @format = format
  @path = path
end

Instance Method Details

#to_promptObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ruby_llm/registry/importer.rb', line 17

def to_prompt
  data, body = case normalized_format
               when :hash
                 extract_hash(payload)
               when :json
                 extract_json(payload)
               when :yaml
                 extract_yaml(payload)
               when :markdown
                 extract_markdown(payload)
               else
                 infer_payload
               end

  build_prompt(data, body)
end