Class: Worklog::Standup
- Inherits:
-
Object
- Object
- Worklog::Standup
- Defined in:
- lib/standup.rb
Overview
Generates standup prompts based on log entries. The Standup class takes log entries and people information to create a standup message that summarizes the work done, work planned, and blockers.
Instance Method Summary collapse
-
#create_prompt ⇒ Array<String>
Create the system and user prompts for standup generation.
- #formatted_entries ⇒ Object
-
#generate ⇒ nil
Generate the standup message and print it to the console.
-
#initialize(entries, people) ⇒ Standup
constructor
Initialize the Standup generator with log entries and people information.
Constructor Details
#initialize(entries, people) ⇒ Standup
Initialize the Standup generator with log entries and people information. If no people information is provided, identifiers will not be resolved to names. These entries can be either of a single day or span multiple days, depending on the desired output. They are handled by the LLM to generate a standup message that summarizes the work done, work planned, and blockers.
34 35 36 37 |
# File 'lib/standup.rb', line 34 def initialize(entries, people) @entries = entries @people = people end |
Instance Method Details
#create_prompt ⇒ Array<String>
Create the system and user prompts for standup generation.
83 84 85 86 87 88 89 90 91 |
# File 'lib/standup.rb', line 83 def create_prompt system_prompt_template = File.read(File.join(__dir__, '..', 'assets', 'prompts', 'standup.system.md.erb')) system_prompt = ERB.new(system_prompt_template, trim_mode: '-<>').result(binding) user_prompt_template = File.read(File.join(__dir__, '..', 'assets', 'prompts', 'standup.user.md.erb')) user_prompt = ERB.new(user_prompt_template, trim_mode: '-<>').result(binding) [system_prompt, user_prompt] end |
#formatted_entries ⇒ Object
93 94 95 96 97 98 |
# File 'lib/standup.rb', line 93 def formatted_entries formatter = LogEntryFormatters::SimpleFormatter.new(@people) @entries.map do |entry| entry.to_hash.slice(:epic, :ticket, :url).merge(message: formatter.format(entry)) end end |
#generate ⇒ nil
Generate the standup message and print it to the console.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/standup.rb', line 41 def generate Langchain.logger.level = Logger::WARN system_prompt, user_prompt = create_prompt llm = Langchain::LLM::OpenAI.new(api_key: ENV.fetch('OPENAI_API_KEY', nil), default_options: { chat_model: 'gpt-5.2' # or any other supported model }) # Override the client to increase timeout def llm.client @client ||= Faraday.new(url: url, headers: auth_headers) do |conn| conn..timeout = 300 conn.request :json conn.response :json conn.response :raise_error conn.response :logger, Langchain.logger, { headers: true, bodies: true, errors: true } end end assistant = Langchain::Assistant.new( llm: llm, instructions: system_prompt ) assistant.(role: 'user', content: user_prompt) WorkLogger.debug('Starting standup generation') begin assistant.run(auto_tool_execution: true) rescue Faraday::ForbiddenError => e WorkLogger.error("LLM request failed: #{e.response}") raise end WorkLogger.debug('Finished standup generation') puts Rainbow('Standup generated successfully!').yellow puts assistant..last.content end |