FastAPI backend for TrendAI news application.
- Python 3.10+
- Virtual environment
- Clone the repository:
git clone https://github.com/TrendAiLab/TrendAi-FastApi.git
cd TrendAi-FastApi- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Configure environment variables:
cp .env.example .env
# Edit .env with your credentials- Run the application:
python main.pyThe API will be available at http://localhost:8088
trendai_py/
├── app/
│ ├── api/
│ │ └── v1/
│ │ ├── endpoints/
│ │ │ ├── articles.py
│ │ │ ├── chat.py
│ │ │ ├── recommendations.py
│ │ │ └── search.py
│ │ └── router.py
│ ├── core/
│ │ └── dependencies.py
│ ├── database/
│ │ ├── milvus_client.py
│ │ └── supabase_client.py
│ ├── models/
│ │ └── schemas.py
│ ├── services/
│ │ ├── chat/
│ │ │ └── chat_service.py
│ │ ├── news/
│ │ │ ├── article_service.py
│ │ │ └── search_service.py
│ │ └── recommendations/
│ │ └── recommendation_service.py
│ └── utils/
│ └── embedding_utils.py
├── config/
│ └── settings.py
├── main.py
├── requirements.txt
├── Dockerfile
├── docker-compose.yml
├── nginx.conf
└── .env.example
Required environment variables:
MILVUS_URI: Milvus cloud instance URIMILVUS_TOKEN: Milvus API tokenSUPABASE_URL: Supabase project URLSUPABASE_ANON_KEY: Supabase anonymous keyGROQ_API_KEY: Groq API key
Optional:
FORCE_CPU: Force CPU usageGPU_MEMORY_FRACTION: GPU memory fraction (0.0-1.0)USE_MIXED_PRECISION: Use mixed precision for inference
GET /health- Health checkGET /api/v1/articles- Get articlesPOST /api/v1/search- Semantic searchGET /api/v1/recommendations/{user_id}- Personalized recommendationsPOST /api/v1/chat- Chat with AI assistant