Class: CoachZed::PromptBuilder
- Inherits:
-
Object
- Object
- CoachZed::PromptBuilder
- Defined in:
- lib/coach_zed/prompt_builder.rb,
sig/coach_zed.rbs
Instance Attribute Summary collapse
-
#catalog ⇒ Array[Catalog::Entry]
readonly
Returns the value of attribute catalog.
-
#consultation_prompt ⇒ String
readonly
Returns the value of attribute consultation_prompt.
-
#existing_feed_context ⇒ String?
readonly
Returns the value of attribute existing_feed_context.
-
#generation_days ⇒ Integer
readonly
Returns the value of attribute generation_days.
-
#schedule_key ⇒ String
readonly
Returns the value of attribute schedule_key.
-
#start_date ⇒ Date
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
- #build ⇒ String
-
#initialize(consultation_prompt:, catalog:, start_date:, schedule_key:, generation_days:, existing_feed_context: nil) ⇒ PromptBuilder
constructor
A new instance of PromptBuilder.
Constructor Details
#initialize(consultation_prompt:, catalog:, start_date:, schedule_key:, generation_days:, existing_feed_context: nil) ⇒ PromptBuilder
Returns a new instance of PromptBuilder.
8 9 10 11 12 13 14 15 |
# File 'lib/coach_zed/prompt_builder.rb', line 8 def initialize(consultation_prompt:, catalog:, start_date:, schedule_key:, generation_days:, existing_feed_context: nil) @consultation_prompt = consultation_prompt @catalog = catalog @start_date = start_date @schedule_key = schedule_key @generation_days = generation_days @existing_feed_context = existing_feed_context end |
Instance Attribute Details
#catalog ⇒ Array[Catalog::Entry] (readonly)
Returns the value of attribute catalog.
61 62 63 |
# File 'lib/coach_zed/prompt_builder.rb', line 61 def catalog @catalog end |
#consultation_prompt ⇒ String (readonly)
Returns the value of attribute consultation_prompt.
61 62 63 |
# File 'lib/coach_zed/prompt_builder.rb', line 61 def consultation_prompt @consultation_prompt end |
#existing_feed_context ⇒ String? (readonly)
Returns the value of attribute existing_feed_context.
61 62 63 |
# File 'lib/coach_zed/prompt_builder.rb', line 61 def existing_feed_context @existing_feed_context end |
#generation_days ⇒ Integer (readonly)
Returns the value of attribute generation_days.
61 62 63 |
# File 'lib/coach_zed/prompt_builder.rb', line 61 def generation_days @generation_days end |
#schedule_key ⇒ String (readonly)
Returns the value of attribute schedule_key.
61 62 63 |
# File 'lib/coach_zed/prompt_builder.rb', line 61 def schedule_key @schedule_key end |
#start_date ⇒ Date (readonly)
Returns the value of attribute start_date.
61 62 63 |
# File 'lib/coach_zed/prompt_builder.rb', line 61 def start_date @start_date end |
Instance Method Details
#build ⇒ String
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 54 55 56 57 |
# File 'lib/coach_zed/prompt_builder.rb', line 17 def build <<~PROMPT You are a training coach. Build a daily training schedule for the athlete using only the provided catalog. CoachZed manages the scheduling contract, so follow the rules below without requiring the end user to restate them. Return strict JSON only. Do not wrap it in markdown fences or commentary. Every string value must be valid JSON text on a single line. Do not emit literal newlines, tabs, or other control characters inside string values. Required JSON Schema: #{JSON.pretty_generate(CoachZed::ScheduleSchema.to_h)} Rules: - Produce exactly #{generation_days} entries for the requested time period. - Set `program_length_days` to exactly #{generation_days}. - Keep `program_length_days` equal to the number of entries in `days`. - Treat catalog entries marked `primary` as the main training sessions. - Aim for 5-6 primary workouts per 7-day week. - Use at most one primary workout per day. - A primary day may include one complementary workout. - On non-primary days, pair complementary workouts with other complementary work only. - Keep rest days to 1 or fewer per 7-day week. - Include rest days when appropriate. - Use only workouts that exist in the catalog. - Match the athlete's goals and the requested time period. - If existing feed context is provided, continue from the end of the prior feed and avoid changing earlier weeks. - Keep the JSON valid and complete. Schedule metadata: - Start date: #{@start_date.iso8601} - Schedule key: #{@schedule_key} Athlete consultation prompt: #{@consultation_prompt} Existing feed context (most recent weeks, if available): #{existing_feed_context || "none"} Catalog: #{JSON.pretty_generate(catalog.map(&:to_h))} PROMPT end |