logeswari commited on
Commit
06b0444
·
1 Parent(s): 872d8bd
Files changed (1) hide show
  1. main.py +6 -6
main.py CHANGED
@@ -1,5 +1,5 @@
1
  from fastapi import FastAPI, HTTPException
2
- from services.sms_service import predict_label, compute_cosine_similarity, compute_embeddings
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 API"}
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("/predict_label")
22
  async def classify_message(input_data: MessageInput):
23
  try:
24
- return await predict_label(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("/compute_embeddings")
30
  async def get_embeddings(input_data: EmbeddingInput):
31
  try:
32
- return await compute_embeddings(input_data.message)
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)}")