Skip to content

Latest commit

 

History

History
58 lines (46 loc) · 1.05 KB

File metadata and controls

58 lines (46 loc) · 1.05 KB

API Backend Setup

Installation

  1. Install Python dependencies:
pip install flask flask-restful flask-cors python-dotenv transformers torch
  1. Create .env file:
cp .env.example .env
  1. Run the API server:
python API_backend.py

API Endpoints

POST /classifyner

Parse a trading message using NER model.

Request:

{
  "data": "BUY RELIANCE ABOVE 2680 SL 2650 TARGET 2750"
}

Response:

{
  "sentence": "[\"BUY\", \"RELIANCE\", \"ABOVE\", \"2680\", \"SL\", \"2650\", \"TARGET\", \"2750\"]",
  "sentence_class": "[1, 10, 0, 3, 9, 3, 5, 3]",
  "sentence_class_name": "[\"btst\", \"symbol\", \"\", \"enter\", \"sl\", \"enter\", \"exit\", \"enter\"]"
}

GET /health

Check API status.

Response:

{
  "status": "healthy",
  "model": "loaded"
}

Configuration

Environment variables (.env):

  • FLASK_PORT - Flask server port (default: 3737)
  • FLASK_DEBUG - Debug mode (default: True)
  • HUGGINGFACE_MODEL_ID - HuggingFace model ID
  • HUGGINGFACE_TOKEN - HuggingFace token (optional)