This project integrates sentiment analysis into Taranis AI, allowing for the classification of news items as positive, negative, or neutral using transformer models. The API intelligently chooses the appropriate model based on the text length, utilizing XLM-RoBERTa for shorter texts and Longformer for longer texts.
- Multi-language Support with XLM-RoBERTa and Longformer.
- Pre-trained Models for high-accuracy sentiment classification.
- Flask API for external calls to the sentiment analysis.
- Python 3.10+
To install dependencies:
uv venv
uv sync
To start the Flask API:
flask run
# or
granian run
# or
docker run -p 5000:5000 ghcr.io/taranis-ai/taranis-sentiment-bot:latest
To test the API with a POST request, use curl:
curl -X POST http://127.0.0.1:5000/ \
-H "Content-Type: application/json" \
-d '{"text": "This is an example sentence to analyze sentiment."}'
{
"sentiment": {
"label": "POSITIVE",
"score": 0.94
}
}
EUROPEAN UNION PUBLIC LICENCE v. 1.2