Class: Journeybook::Ai::PromptBuilder
- Inherits:
-
Object
- Object
- Journeybook::Ai::PromptBuilder
- Defined in:
- app/services/journeybook/ai/prompt_builder.rb
Instance Method Summary collapse
- #build(user_prompt:) ⇒ Object
-
#initialize(components: Journeybook.components, site: nil, style_prompt: nil, template: nil, media_assets: MediaAsset.order(created_at: :desc).limit(25)) ⇒ PromptBuilder
constructor
A new instance of PromptBuilder.
Constructor Details
#initialize(components: Journeybook.components, site: nil, style_prompt: nil, template: nil, media_assets: MediaAsset.order(created_at: :desc).limit(25)) ⇒ PromptBuilder
Returns a new instance of PromptBuilder.
6 7 8 9 10 11 12 |
# File 'app/services/journeybook/ai/prompt_builder.rb', line 6 def initialize(components: Journeybook.components, site: nil, style_prompt: nil, template: nil, media_assets: MediaAsset.order(created_at: :desc).limit(25)) @components = components @site = site @style_prompt = style_prompt @template = template @media_assets = media_assets end |
Instance Method Details
#build(user_prompt:) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/services/journeybook/ai/prompt_builder.rb', line 14 def build(user_prompt:) <<~PROMPT You are designing a Journeybook CMS page for a Rails website. Return exactly one complete Markdown document. Do not wrap it in code fences. Do not explain the result. User request: #{user_prompt} Style instructions: #{style_instructions} Current Journeybook context: #{site_context} Template instructions: #{template_instructions} Available Journeybook components: #{component_reference} Available image library: #{image_library_reference} Rules: - Use component tags only for page content. - Do not write Markdown headings, paragraphs, lists, links, raw HTML, or standalone text outside component tags. - The only allowed non-component content is frontmatter, if frontmatter is needed. - Copy/text may appear inside component prop values. - Use only the registered components listed above. - Component syntax is: {{ component_name prop="value" other_prop="value" }} - Do not invent unsupported component names. - Use image library URLs only when a registered component has a suitable image prop. - Prefer matching alt text from the image library. - Do not invent image URLs. - Do not output raw Markdown image syntax. - Fill component props with concise production-ready copy. - Keep the page coherent and ready for a public website. PROMPT end |