• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
toowired

toowired

Prompt_Improver

Unlisted
Like
Prompt_Improver
Home
Code
21
.github
1
backend
11
frontend
9
shared
1
workers
3
.vtignore
API_DOCUMENTATION.md
DEPLOY.md
DEPLOYMENT.md
README.md
VALTOWN_BENEFITS.md
deno.json
deploy.sh
H
index.http.ts
resource_example.html
test_all_endpoints.js
test_database.js
test_prompt_library.js
test_resources.js
test_ui_ux.js
val.json
Branches
3
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
9/5/2025
Viewing readonly version of main branch: v244
View latest version
README.md

Prompt Improver - Val Town Application

An AI-powered prompt optimization tool built on Val Town that iteratively improves prompts using multiple specialized AI workers.

Features

  • Multi-stage Optimization: Uses three specialized workers (Clarifier, Condenser, Includer) to improve prompts
  • Iterative Refinement: Processes prompts through multiple cycles until optimal results are achieved
  • Final Organization: Applies a final organization pass to structure the improved prompt
  • Modern UI: Clean, responsive interface built with TailwindCSS
  • Val Town Integration: Fully compatible with Val Town's serverless platform

Architecture

The application consists of:

  1. Main HTTP Handler (backend/index.http.ts): Serves the frontend and API endpoint
  2. Worker Functions: Three specialized prompt improvement functions
    • Clarifier: Makes prompts clearer and more specific
    • Condenser: Removes redundancy while maintaining meaning
    • Includer: Adds missing context and relevant details
  3. Frontend: Single-page application with real-time prompt improvement

Deployment to Val Town

Prerequisites

  • Val Town account (paid subscription recommended for API features)
  • OpenAI API key configured in Val Town environment variables

Step 1: Deploy the Main Val

  1. Go to Val Town
  2. Create a new HTTP val named prompt_improver
  3. Copy the contents of backend/index.http.ts to your val
  4. Save and deploy

Step 2: Configure Environment Variables

In your Val Town settings, ensure you have:

  • OPENAI_API_KEY - Your OpenAI API key
  • valtown or VAL_TOWN_API_KEY - Automatically set by Val Town

Step 3: Access Your Application

Your application will be available at:

https://[your-username]-prompt-improver.web.val.run

API Usage

Endpoint

POST https://[your-username]-prompt-improver.web.val.run/api/improve

Request Body

{ "prompt": "Your prompt to improve" }

Response

{ "result": "The improved prompt", "steps": 5, "history": [ { "step": 1, "worker": "Clarifier", "prompt": "Clarified version..." } ] }

Local Development

Using Deno

  1. Install Deno
  2. Run the application:
    deno run --allow-net --allow-env backend/index.http.ts
  3. Open http://localhost:8000

Environment Variables

Create a .env file:

OPENAI_API_KEY=your_openai_api_key
VAL_TOWN_API_KEY=your_valtown_api_key

How It Works

  1. Input: User provides a prompt to improve
  2. Processing: The prompt goes through multiple optimization cycles:
    • Each cycle applies three workers in sequence (Clarifier β†’ Condenser β†’ Includer)
    • Process continues until the prompt stabilizes or reaches maximum iterations
  3. Organization: A final pass organizes the improved prompt for clarity
  4. Output: Returns the optimized prompt with processing statistics

Configuration

Maximum Steps

The MAX_STEPS constant in the backend controls the maximum number of optimization cycles (default: 10).

AI Model

The application uses OpenAI's gpt-4o-mini model by default. You can change this in the worker functions.

Temperature Settings

Each worker has different temperature settings optimized for its task:

  • Clarifier: 0.3 (more focused)
  • Condenser: 0.2 (very focused)
  • Includer: 0.4 (slightly creative)
  • Organizer: 0 (deterministic)

Troubleshooting

Common Issues

  1. "Failed to improve prompt" error

    • Check your OpenAI API key is correctly configured
    • Ensure you have API credits available
    • Check Val Town logs for detailed error messages
  2. Val not found errors

    • Ensure the val is deployed with the correct name
    • Check that your Val Town account has the necessary permissions
  3. CORS errors

    • The application includes CORS headers by default
    • If issues persist, check your browser's security settings

Debugging

Enable detailed logging by checking the Val Town logs:

  1. Go to your val's page on Val Town
  2. Click on the "Logs" tab
  3. Review any error messages or console outputs

Contributing

Feel free to fork this project and submit improvements. Key areas for enhancement:

  • Additional worker types
  • Support for different AI models
  • Batch processing capabilities
  • Prompt history and favorites

License

MIT License - Feel free to use and modify as needed.

Support

For issues or questions:

  • Create an issue in this repository
  • Contact through Val Town community forums
  • Check Val Town documentation at https://docs.val.town
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2025 Val Town, Inc.