A newer version of the Gradio SDK is available: 6.14.0
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." }
- Success (200 OK):
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
textfield in the request body should contain a short paragraph. - The response will always include a
sentimentfield with one of the following values:positive,negative, orneutral. - Replace value of the
api_keyparameter with the actual OpenAI key