msg
Browse files
main.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
from fastapi import FastAPI, HTTPException
|
| 2 |
-
from services.sms_service import
|
| 3 |
from schemas.input_schemas import CosineSimilarityInput, MessageInput, EmbeddingInput
|
| 4 |
|
| 5 |
app = FastAPI()
|
|
@@ -7,7 +7,7 @@ app = FastAPI()
|
|
| 7 |
# 🚀 1️⃣ Homepage Endpoint
|
| 8 |
@app.get("/")
|
| 9 |
async def home():
|
| 10 |
-
return {"message": "Welcome to SMS Classification
|
| 11 |
|
| 12 |
# 🔢 2️⃣ Cosine Similarity Endpoint
|
| 13 |
@app.post("/cosine_similarity")
|
|
@@ -18,17 +18,17 @@ async def get_cosine_similarity(input_data: CosineSimilarityInput):
|
|
| 18 |
raise HTTPException(status_code=500, detail=f"Error computing similarity: {str(e)}")
|
| 19 |
|
| 20 |
# 📩 3️⃣ SMS Classification Endpoint
|
| 21 |
-
@app.post("/
|
| 22 |
async def classify_message(input_data: MessageInput):
|
| 23 |
try:
|
| 24 |
-
return await
|
| 25 |
except Exception as e:
|
| 26 |
raise HTTPException(status_code=500, detail=f"Error predicting label: {str(e)}")
|
| 27 |
|
| 28 |
# 📊 4️⃣ Text Embedding Endpoint
|
| 29 |
-
@app.post("/
|
| 30 |
async def get_embeddings(input_data: EmbeddingInput):
|
| 31 |
try:
|
| 32 |
-
return await
|
| 33 |
except Exception as e:
|
| 34 |
raise HTTPException(status_code=500, detail=f"Error computing embeddings: {str(e)}")
|
|
|
|
| 1 |
from fastapi import FastAPI, HTTPException
|
| 2 |
+
from services.sms_service import label_prediction, compute_cosine_similarity, embeddings
|
| 3 |
from schemas.input_schemas import CosineSimilarityInput, MessageInput, EmbeddingInput
|
| 4 |
|
| 5 |
app = FastAPI()
|
|
|
|
| 7 |
# 🚀 1️⃣ Homepage Endpoint
|
| 8 |
@app.get("/")
|
| 9 |
async def home():
|
| 10 |
+
return {"message": "Welcome to SMS Classification Dashboard"}
|
| 11 |
|
| 12 |
# 🔢 2️⃣ Cosine Similarity Endpoint
|
| 13 |
@app.post("/cosine_similarity")
|
|
|
|
| 18 |
raise HTTPException(status_code=500, detail=f"Error computing similarity: {str(e)}")
|
| 19 |
|
| 20 |
# 📩 3️⃣ SMS Classification Endpoint
|
| 21 |
+
@app.post("/label_prediction")
|
| 22 |
async def classify_message(input_data: MessageInput):
|
| 23 |
try:
|
| 24 |
+
return await label_prediction(input_data.message)
|
| 25 |
except Exception as e:
|
| 26 |
raise HTTPException(status_code=500, detail=f"Error predicting label: {str(e)}")
|
| 27 |
|
| 28 |
# 📊 4️⃣ Text Embedding Endpoint
|
| 29 |
+
@app.post("/embeddings")
|
| 30 |
async def get_embeddings(input_data: EmbeddingInput):
|
| 31 |
try:
|
| 32 |
+
return await embeddings(input_data.message)
|
| 33 |
except Exception as e:
|
| 34 |
raise HTTPException(status_code=500, detail=f"Error computing embeddings: {str(e)}")
|