TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: ActionPrompt – A Rails Plugin for Managing Your LLM Prompts

2 pointsby evtothedev8 months ago
Hi Everyone! I&#x27;ve just extracted this from our code base.<p>As LLMs have become ubiquitous in web applications, I&#x27;ve noticed that prompts intended for Claude or GPT have become scattered throughout our codebase or buried within objects. Often, these prompts were built inline through string manipulation. My thinking was two-fold, 1) Let&#x27;s come up with a simple pattern for organizing and rendering these prompts, and 2) Let&#x27;s make them easy to review.<p>This draws heavy inspiration from ActionMailer::Preview.

1 comment

graypegg8 months ago
From the codebase you extracted this from, how are you sending these prompt strings onward? I feel like it would really benefit from being inspired by all of ActionMailer, not just ActionMailer:::Preview. Being able to just fire these off in a job would be useful. Even better if you could act on those as part of the job, so kind of like a little controller&#x2F;agent thing?<p><pre><code> config.action_prompt.delivery_method = :chatgpt_api config.action_prompt.chatgpt_api_settings = { api_key: Rails.env[:OPENAI_API_KEY] } ... class ApplicationPrompt &lt; ActionPrompt::Base before_action :set_user def set_user @user = current_user || AnonUser.new end end class SupportAgentPrompt &lt; ApplicationPrompt def ask(question) @question = question.strip.downcase if result = prompt(question:) # renders `views&#x2F;prompts&#x2F;support_agent&#x2F;ask.text.erb`, # ideally handles recognizing JSON and stripping out whitespace in response broadcast_append_to @user, target: :support_chat, partial: &#x27;support_chat&#x2F;message&#x27;, locals: { message: result, from: SupportAgentUser.new } end end end ... SupportAgentPrompt.ask.prompt_later &quot;What&#x27;s the best menu item?&quot;</code></pre>