Class: PromptSchema::Prompt
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- PromptSchema::Prompt
- Defined in:
- lib/prompt_schema/prompt.rb
Overview
Generates a prompt for an LLM based on a compiled schema.
Instance Method Summary collapse
-
#initialize(schema) ⇒ String
constructor
The generated prompt.
- #view_template ⇒ Object
Constructor Details
#initialize(schema) ⇒ String
Returns The generated prompt.
11 12 13 14 |
# File 'lib/prompt_schema/prompt.rb', line 11 def initialize(schema) @compiled = SchemaCompiler.call(schema) @indentation = 0 end |
Instance Method Details
#view_template ⇒ Object
16 17 18 19 |
# File 'lib/prompt_schema/prompt.rb', line 16 def view_template text "Answer in JSON using this schema:" render_structure(@compiled[:keys]) end |