sheikhDipta003's picture
add all files
9cdcfee

A newer version of the Gradio SDK is available: 6.14.0

Upgrade

API Documentation: Text Sentiment Analysis

This API uses a fine-tuned GPT-3.5-turbo model to predict the sentiment of a given text. It accepts a short paragraph and returns the predicted sentiment (positive, negative, or neutral). Run python .\test.py to start the FastAPI server in http://0.0.0.0:8000.


Base URL

http://0.0.0.0:8000

Endpoints

1. Predict Sentiment

This endpoint accepts a short paragraph of text and returns the predicted sentiment.

  • Endpoint: POST /predict-sentiment/
  • Request Body:
    {
      "text": "I absolutely loved the product! It exceeded all my expectations."
    }
    
  • Response:
    • Success (200 OK):
      {
        "sentiment": "positive"
      }
      
    • Error (500 Internal Server Error):
      {
        "detail": "Error message describing the issue."
      }
      

Example Usage

Request

curl -X POST "http://0.0.0.0:8000/predict-sentiment/" \
-H "Content-Type: application/json" \
-d '{"text": "I absolutely loved the product! It exceeded all my expectations."}'

Response

{
  "sentiment": "positive"
}

Notes

  • The API uses a fine-tuned GPT-3.5-turbo model for sentiment analysis.
  • The text field in the request body should contain a short paragraph.
  • The response will always include a sentiment field with one of the following values: positive, negative, or neutral.
  • Replace value of the api_key parameter with the actual OpenAI key