File size: 1,445 Bytes
80dbe44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from fastapi import FastAPI
from src.app.api.predict import router as transportation_router
from src.app.api.chat import router as chat_router
from src.config.logging_config import setup_logging, get_logger

# Setup logging trước khi khởi tạo app
setup_logging()
logger = get_logger(__name__)

app = FastAPI(
	title="Transportation Prediction API",
	description="API dự đoán phương thức vận chuyển dùng mô hình XGBoost với đầu vào đơn giản",
	version="2.0.0"
)

logger.info("Starting Transportation Prediction API v2.0")


# New simplified API endpoint
app.include_router(transportation_router, prefix="/api", tags=["transportation"])
app.include_router(chat_router, prefix="/api", tags=["chat"])

@app.get("/")
def root():
	return {
		"message": "Transportation Prediction API v2.0", 
		"docs": "/docs", 
		"endpoints": {
			"predict_transportation": "/api/predict-transportation",
			"transportation_options": "/api/transportation-options",
			"legacy_predict": "/api/predict",
			"chat": "/api/chat (streaming)"
		},
		"description": "Sử dụng /api/predict-transportation với đầu vào đơn giản để dự đoán phương thức vận chuyển, hoặc /api/chat để chat với AI (streaming response)"
	}

# Only run server if this file is executed directly
if __name__ == "__main__":
	import uvicorn
	logger.info("Starting server on localhost:3454")
	uvicorn.run(app, host="localhost", port=3454)