File size: 881 Bytes
c82e328
 
 
 
 
e10ddaa
c82e328
 
 
 
 
6c2eaf8
c82e328
 
a0f1fda
 
c82e328
e10ddaa
95076c1
c82e328
e10ddaa
 
a0f1fda
 
 
 
60d1a5c
a0f1fda
 
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
from fastapi import FastAPI
import os
import sys
src_directory = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..", "src"))
sys.path.append(src_directory)
from modules import encoding_model

app = FastAPI()

@app.get("/")
def home():
    model = encoding_model.train_model()
    return {"message": "Welcome to Prediction Hub"}

@app.get("/dimention")
def display_dimention(message : str = "Hello World"):
    try:
        dimention  = encoding_model.get_label(message)
        return dimention
    except Exception as e:
        return f"Unable to fetch the data {e}"
    
@app.get("/prediction")
def display_prediction(message : str = "Give me a sms to predict"):
    try:
        prediction = encoding_model.get_prediction(message)
        return {"message" : f"Given sms is a {prediction}"}
    except Exception as e:
        return f"Unable to fetch the data {e}"