A sentiment analysis tool powered by Claude (claude-sonnet-4-6). Classify text as positive, negative, or neutral with a confidence score — via a web UI or the command line.
- Single-text analysis — paste any text and get an instant sentiment result
- CSV batch processing — upload a CSV and analyze every row in one go
- Streamlit UI — color-coded result cards with confidence progress bars
- CLI — scriptable via
main.pyfor pipeline use
1. Clone and install dependencies
git clone <repo-url>
cd SentiBot
pip install -r requirements.txt2. Configure your API key
cp .env.example .env
# Open .env and set your key:
# ANTHROPIC_API_KEY=sk-ant-...Get a key at console.anthropic.com.
streamlit run app.pyOpen the URL printed in the terminal (usually http://localhost:8501).
- Analyze Text tab — type or paste text, click Analyze
- Batch CSV tab — upload a CSV (first column = text), click Analyze Batch, download results
Single text:
python main.py --text "This is absolutely fantastic!"{
"text": "This is absolutely fantastic!",
"label": "positive",
"confidence": 0.99,
"tokens_used": 268,
"model": "claude-sonnet-4-6"
}Batch CSV:
python main.py --file data/sample.csv --output results.csvThe input CSV must have a header row; text is read from the first column. The output CSV contains all five fields: text, label, confidence, tokens_used, model.
Every result — from the UI, CLI, or API — has the same shape:
| Field | Type | Description |
|---|---|---|
text |
string | Original input text |
label |
string | positive, negative, or neutral |
confidence |
float | 0.0 – 1.0 |
tokens_used |
int | Total tokens consumed by the API call |
model |
string | Model used (claude-sonnet-4-6) |
SentiBot/
├── analyzer.py # All Anthropic API interaction
├── main.py # CLI entry point (argparse)
├── app.py # Streamlit UI
├── data/
│ └── sample.csv # 10 sample texts for testing
├── tests/
│ ├── test_main.py # CLI tests (8 cases, all mocked)
│ └── test_app.py # UI tests (6 cases, AppTest)
├── .env.example # API key template
└── requirements.txt
pytestAll tests mock the Anthropic API — no real calls are made and no key is required.
┌─────────────┐
│ analyzer.py │ ← all Claude API calls live here
└──────┬──────┘
│
┌────────────┴────────────┐
│ │
┌──────▼──────┐ ┌────────▼──────┐
│ main.py │ │ app.py │
│ (CLI) │ │ (Streamlit) │
└─────────────┘ └───────────────┘
analyzer.py is the only file that talks to the Anthropic API. main.py and app.py are thin layers that handle input/output and delegate everything else.