A modular Python system designed to convert unstructured multi-modal inputs (text, documents, images) into a standardized, structured prompt suitable for downstream AI processing.
- Structured Output: Converts messy inputs into a strict JSON schema.
- Multi-Modal Logic: Handles Text, Document (PDF/DOCX), and Image (Stub) inputs via specialized extractors.
- Validation & Refinement: Rejects bad inputs and cleans up accepted ones.
- Confidence Scoring: Assigns a score (0.0-1.0) based on input completeness.
- Extensible API: Built with FastAPI.
- Ruthless Mode: Aggressively filters conversational noise for clean engineering data.
prompt-refinement-system/
├── src/ # Core Application Source
│ ├── api.py # FastAPI Entry Point
│ ├── extraction/ # Modular Extractors (Text, Doc, Image)
│ ├── refinement_engine/ # Business Logic (Normalization & Scoring)
│ └── validation/ # Input Gatekeepers
├── frontend/ # React + Vite UI
│ ├── src/
│ ├── public/
│ └── package.json
├── samples/ # Demo Data
│ ├── input_examples/ # Raw Inputs (Upload these!)
│ │ ├── enterprise_spec_v2.docx
│ │ ├── email_dump.txt
│ │ └── sample_mockup.png
│ └── output_examples/ # Refined JSON results (Added!)
│ ├── enterprise_spec_v2_refined.json
│ ├── email_dump_refined.json
│ └── ... (and more)
├── scripts/ # Utility Scripts
│ └── generate_samples.py
├── tests/ # Pytest Suite
│ └── test_backend.py
├── docs/ # Architectural Documentation
├── requirements.txt # Python Dependencies
└── README.md # You are here
pip install -r requirements.txtRun the end-to-end verification script:
python test_system.pyStart the FastAPI server:
uvicorn src.api:app --reloadThe API will be available at http://127.0.0.1:8000. You can access the interactive Swagger UI at http://127.0.0.1:8000/docs.
POST /refine
{
"inputs": [
{
"type": "text",
"content": "I need a website for my bakery. It must have a contact form and a gallery."
}
]
}The project includes a React-based demo interface.
- Navigate to the frontend directory:
cd frontend - Install dependencies:
npm install
- Run the dev server:
npm run dev
- Open http://localhost:5173 in your browser.
For a deep dive into the architectural decisions and schema design, check out:
