A high-performance RESTful API for Natural Language Processing tasks and psychological response generation, built with FastAPI.
- Sentiment Analysis: Analyze the sentiment of input text
- Entity Recognition: Extract named entities from text
- Text Summarization: Generate concise summaries of text
- Psychological Responses: Access a database of psychologist-style responses
- Multi-language Support: Includes translation capabilities
- Filtering & Search: Filter responses by input/output text
- RESTful API: Fully documented OpenAPI/Swagger interface
- Python 3.8+
- pip (Python package manager)
-
Clone the repository:
git clone https://github.com/yourusername/advanced-nlp-api.git cd advanced-nlp-api -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Download the spaCy model:
python -m spacy download en_core_web_sm
-
Start the server:
uvicorn advanced_api:app --reload
The API will be available at http://localhost:8000
Once the server is running, access the interactive API documentation at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
GET /- Welcome messageGET /responses- Get all responses with optional filteringGET /responses/random- Get a random responseGET /responses/{response_id}- Get a specific response by IDGET /responses/happy- Get happy responsesGET /responses/sad- Get sad responses
POST /analyze/sentiment- Analyze sentiment of textPOST /analyze/entities- Extract named entities from textPOST /summarize- Generate a summary of textGET /translate- Translate text to another languagePOST /qa- Get answers to questions about text
# Get a random response
curl -X 'GET' \
'http://localhost:8000/responses/random' \
-H 'accept: application/json'
# Analyze sentiment
curl -X 'POST' \
'http://localhost:8000/analyze/sentiment' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"text": "I love this API! It's amazing!"}'import requests
# Get a random happy response
response = requests.get("http://localhost:8000/responses/random")
print(response.json())
# Analyze text sentiment
data = {"text": "I'm feeling great today!"}
response = requests.post("http://localhost:8000/analyze/sentiment", json=data)
print(response.json())# Run tests (add your test commands here)
# pytest tests/This project uses:
- Black for code formatting
- Flake8 for linting
- isort for import sorting
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or feedback, please open an issue on GitHub. Bhupesh Joshi https://www.linkedin.com/in/bhupesh-joshi-profile/