How thunderhead-exe/advanced-prompt-generator works
Project Type and Purpose
• This is an LLM-based Advanced Prompt Generator tool that offers:
• A core pipeline (prompt enhancement logic)
• A FastAPI microservice for scalable backend deployment (Docker-packaged).
• A Gradio UI for quick demos (Hugging Face Spaces).
• A local CLI/test script for development.
• Purpose: take a user’s input prompt, apply AI-agent-based prompt engineering via OpenAI APIs (gpt-4o/gpt-4o-mini), and return an enhanced prompt.
File Structure
• Root:
• Advancd_Prompt_Generator.py → local entrypoint calling pipeline.py
• pipeline.py → core logic (shared by all interfaces)
• requirements.txt → all dependencies
• Docker-FastAPI-app:
• Dockerfile → container build instructions
• requirements.txt → backend dependencies
• app/main.py → FastAPI server endpoints
• app/pipeline.py → imports/adapts core logic
• Gradio-app:
• app.py → Gradio UI endpoints
• pipeline.py → imports/adapts core logic
• requirements.txt
README for Insights
• Lists features: automated prompt engineering, OpenAI API usage, FastAPI + Docker, Gradio interface, Hugging Face deployment
• No database—external dependency is the OpenAI API
a. Main Components
• User Interfaces:
◦ CLI/Test Script (Advancd_Prompt_Generator.py)
◦ Gradio Frontend (Gradio-app/app.py)
• Backend Service:
◦ FastAPI API (Docker-FastAPI-app/app/main.py)
• Core Pipeline Module:
◦ pipeline.py (root, reused by both interfaces)
• External Services:
◦ OpenAI API (gpt-4o / gpt-4o-mini)
◦ Hugging Face Spaces hosting
• Infrastructure:
◦ Docker container for FastAPI
◦ Python runtime environments
b. Relationships and Data Flow
1. User → (CLI or Gradio UI) → Core Pipeline → OpenAI API → Core Pipeline → (CLI or FastAPI or Gradio) → User
2. For FastAPI: User → HTTP Request → FastAPI Endpoint → Core Pipeline → OpenAI → response → FastAPI → HTTP Response → User
3. For Gradio: User → Gradio Web UI → Core Pipeline → OpenAI → displayed result
c. Architectural Patterns & Principles
• Separation of Concerns: UI layers (CLI, Gradio, FastAPI) are thin wrappers around a shared core pipeline module.
• Modularity: Single pipeline.py holds logic; interfaces import/adapt it.
• Containerization: FastAPI service is isolated in a Docker container for consistency and scalability.
• Stateless Backend: No persistent storage; each request is independent, relying only on real-time OpenAI calls.
d. Key Technologies & Frameworks
• Python 3.x
• FastAPI (backend microservice)
• Docker (containerization)
• Gradio (demo UI)
• OpenAI Python SDK (LLM integration)
• Hugging Face Spaces (Gradio hosting)