Documentation: Prompt Engineering Studio

This document provides an overview and feature explanation for the prompt-engineering-studio project, a client-side tool for testing and designing prompts with Google Gemini.

The core features of this project are built by referencing principles from two Prompt Engineering documents:

Core Features

This application implements several Prompt Engineering techniques as practical features:

1. Prompt Editor & Role Prompting

The main UI (index.html) is designed to directly support the "Role Prompting" technique by separating input fields for System Prompt and User Prompt.

Reference: PDF 22365_3... (p. 18, 21-22) - Section: "Role prompting"

2. Gemini API Service & Configuration

The geminiService.js file acts as the app's "engine," featuring a callApi function that builds the payload for the Gemini API. It also includes a fetchWithRetry mechanism to retry requests upon network or API errors (e.g., 429, 5xx).

Reference: PDF 22365_3... (p. 8-12) - Section: "LLM output configuration"

3. Prompt Analysis

This is a key feature of the Studio (analyzePrompt in geminiService.js) that uses an LLM to analyze the user's prompt. The prompt instructing the analysis AI (ANALYSIS_PROMPT_TEMPLATE) directly cites pages from the 22365_3... PDF to check the user's prompt against principles like:

This feature uses the ANALYSIS_SCHEMA from config.js to force the AI to return its analysis in a clearly structured JSON format.

4. Prompt Templates (Few-Shot & JSON Mode)

The config.js file contains a PROMPT_TEMPLATES variable that helps users start quickly with different techniques.

Reference: PDF 22365_3... (p. 15-17) - "One-shot & few-shot" and (p. 60-62) - "Experiment with output formats (JSON)"

5. Security (Client-side & Encryption)

The project emphasizes privacy by running entirely in the user's browser (client-side), as stated in privacy.html. No API keys or prompts are sent to the app's server.

6. Advanced Prompting Techniques

The app supports advanced techniques described in both PDFs via the Configuration panel:

7. History & Comparison

(app.js) Every run's result and full configuration is saved to the "Run History" tab (using localStorage). The most critical feature is "Compare," which allows a user to select two different runs to see a side-by-side comparison of the Prompt, Config, and Output. This is essential for the iterative development and tuning of prompts.