Class: RubyLLM::Prompt::Roots
- Inherits:
-
Object
- Object
- RubyLLM::Prompt::Roots
- Includes:
- Enumerable
- Defined in:
- lib/ruby_llm/prompt.rb
Overview
The ordered directories searched for prompt files. The application's prompt directory is always first, so an application can override any prompt an engine ships by placing a file at the same relative path. Engines append their own directory in an initializer:
initializer "my_engine.prompts" do
RubyLLM::Prompt.roots << MyEngine::Engine.root.join("app/prompts")
end
Instance Method Summary collapse
-
#<<(path) ⇒ Object
(also: #push)
Appends a prompt directory and returns
self. -
#each ⇒ Object
Yields each prompt directory in lookup order.
-
#initialize(&default) ⇒ Roots
constructor
:nodoc:.
Constructor Details
#initialize(&default) ⇒ Roots
:nodoc:
21 22 23 24 |
# File 'lib/ruby_llm/prompt.rb', line 21 def initialize(&default) # :nodoc: @default = default @registered = [] end |
Instance Method Details
#<<(path) ⇒ Object Also known as: push
Appends a prompt directory and returns self.
27 28 29 30 |
# File 'lib/ruby_llm/prompt.rb', line 27 def <<(path) @registered << Pathname.new(path) self end |
#each ⇒ Object
Yields each prompt directory in lookup order. Returns an Enumerator without a block.
34 35 36 |
# File 'lib/ruby_llm/prompt.rb', line 34 def each(&) [@default.call, *@registered].each(&) end |