Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prompt Enhancer API

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.

Features

  • 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

Installation

  1. Clone the repository:
git clone <repository-url>
cd Prompt-Enhancer
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the application:
python main.py

The API will be available at http://localhost:8000

API Endpoints

GET /

Health check endpoint that confirms the API is running.

Response:

{
  "message": "Prompt Enhancer API is running"
}

GET /health

Detailed health check that includes model status.

Response:

{
  "status": "healthy",
  "model_loaded": true
}

POST /enhance

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"
}

Usage Examples

Using curl

curl -X POST "http://localhost:8000/enhance" \
     -H "Content-Type: application/json" \
     -d '{"text": "a dog in a park"}'

Using Python requests

import requests

response = requests.post(
    "http://localhost:8000/enhance",
    json={"text": "a dog in a park"}
)
print(response.json())

API Documentation

Once the server is running, you can access:

Error Handling

The API returns appropriate HTTP status codes:

  • 200: Success
  • 400: Bad request (empty prompt)
  • 500: Internal server error
  • 503: Service unavailable (model not loaded)

Development

Running in Development Mode

uvicorn main:app --reload --host 0.0.0.0 --port 8000

Environment Variables

  • PORT: Server port (default: 8000)
  • HOST: Server host (default: 0.0.0.0)

Dependencies

  • 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

License

[Add your license information here]

About

Framework to evaluate, enhance, and optimize prompts before LLM API calls

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages