Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Content Generator with Gemini AI

A TypeScript application that uses Google's Gemini AI to generate content based on configurable goals and guidelines, with automatic evaluation and retry logic to ensure quality.

Features

  • PromptOrchestrator: Converts goals and guidelines into structured LLM prompts
  • GeminiService: Handles communication with Google's Gemini AI API with unlimited token generation
  • Evaluator: Automatically evaluates generated content against guidelines using AI
  • Smart Retry System: Automatically retries generation with enhanced prompts when content doesn't meet quality standards
  • Manual Score Calculation: Calculates scores based on percentage of guidelines passed
  • TypeScript: Full type safety and modern development experience

Requirements

  • Node.js 16+
  • TypeScript 5+
  • Valid Gemini API key

Setup

  1. Install dependencies:

    npm install
  2. Get your Gemini API key:

  3. Set up environment variables: Create a .env file in the project root:

    GEMINI_API_KEY=your_actual_api_key_here
  4. Run the application:

    npm start

Usage

The application will:

  1. Generate a structured prompt from your goal and guidelines
  2. Send the prompt to Gemini AI for content generation
  3. Automatically evaluate the generated content against all guidelines
  4. Calculate a score based on the percentage of guidelines that passed
  5. If the score meets the threshold (100% by default), display the accepted content
  6. If not, retry with enhanced prompts focusing on failed guidelines (up to 3 attempts)
  7. Display the best result if all attempts fail to meet the threshold

Configuration

You can modify the following in main.ts:

  • Goal: The main objective for content generation (line 8)
  • Guidelines: Array of requirements the content must meet (lines 10-18)
  • MAX_ATTEMPTS: Number of retry attempts (default: 3)
  • SCORE_THRESHOLD: Minimum score percentage to accept content (default: 100%)

API Reference

PromptOrchestrator

  • generatePrompt(failedGuidelines?): Creates a formatted LLM prompt, optionally emphasizing previously failed guidelines
  • setGoal(goal): Updates the content generation goal
  • setGuidelines(guidelines): Updates the guidelines array
  • addGuideline(guideline): Adds a single guideline
  • getGoal(): Returns the current goal
  • getGuidelines(): Returns a copy of current guidelines

GeminiService

  • generateContent(prompt, temperature?): Generates content with optional temperature control (default: 0.7)

Evaluator

  • evaluateContent(content, goal, guidelines): Evaluates content against guidelines and returns score, feedback, and detailed results

How Evaluation Works

The application uses a sophisticated evaluation system:

  1. AI-Powered Assessment: Uses Gemini AI to evaluate each guideline individually
  2. Manual Score Calculation: Calculates the final score as (passed guidelines / total guidelines) * 100
  3. Detailed Feedback: Provides specific feedback on which guidelines were met or missed
  4. Smart Retry Logic: If content doesn't meet the threshold, retries with enhanced prompts that focus on previously failed guidelines
  5. Transparent Results: Shows detailed breakdown of which guidelines passed/failed for each attempt

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages