A FastAPI-based service that enhances prompts using Microsoft's Promptist model. This API helps improve the quality and effectiveness of text prompts for better AI model interactions.
- Prompt Enhancement: Transform basic prompts into more detailed, effective versions
- RESTful API: Clean, documented endpoints with proper error handling
- Health Monitoring: Built-in health check endpoint
- CORS Support: Ready for web frontend integration
- Logging: Comprehensive logging for debugging and monitoring
- Clone the repository:
git clone <repository-url>
cd Prompt-Enhancer- Install dependencies:
pip install -r requirements.txt- Run the application:
python main.pyThe API will be available at http://localhost:8000
Health check endpoint that confirms the API is running.
Response:
{
"message": "Prompt Enhancer API is running"
}Detailed health check that includes model status.
Response:
{
"status": "healthy",
"model_loaded": true
}Enhance a prompt using the Promptist model.
Request Body:
{
"text": "a cat sitting on a chair"
}Response:
{
"improved_prompt": "a beautiful cat sitting comfortably on a wooden chair",
"original_prompt": "a cat sitting on a chair"
}curl -X POST "http://localhost:8000/enhance" \
-H "Content-Type: application/json" \
-d '{"text": "a dog in a park"}'import requests
response = requests.post(
"http://localhost:8000/enhance",
json={"text": "a dog in a park"}
)
print(response.json())Once the server is running, you can access:
- Interactive API docs: http://localhost:8000/docs
- ReDoc documentation: http://localhost:8000/redoc
The API returns appropriate HTTP status codes:
200: Success400: Bad request (empty prompt)500: Internal server error503: Service unavailable (model not loaded)
uvicorn main:app --reload --host 0.0.0.0 --port 8000PORT: Server port (default: 8000)HOST: Server host (default: 0.0.0.0)
- FastAPI: Modern web framework for building APIs
- Pydantic: Data validation using Python type annotations
- Transformers: Hugging Face transformers library for the Promptist model
- PyTorch: Deep learning framework
- Uvicorn: ASGI server for running FastAPI applications
[Add your license information here]