text: #To start the server use the cmd to type: uvicorn main:app --reload
  
  #Import libraries
  import pickle
  import pandas as pd
  from fastapi import FastAPI
  from pydantic import BaseModel
  from preprocessing import clean_data
  
  #Import the the model and the label encoder
  model = pickle.load(open("model/finalized_model.sav", 'rb'))
  Encoder = pd.read_pickle(r"model/dialect_encoder.pkl")
  
  #Initial a FastAPI instance
  app = FastAPI()
  
  def inference(X, model=model, Encoder=Encoder):
      '''
      A function to do the inference
      '''
      X_processed = [clean_data(X)]
      pred = model.predict(X_processed)
      return Encoder.inverse_transform(pred)[0]
  
  # pydantic models
  class DataIn(BaseModel):
      #The input should be string
      text : str = "Input Text"
  
  class DataOut(BaseModel):
      #The forecast output will be the dialect of the text 
      forecast: str = "Dialect"
  
  #The Welcome page / get request
  @app.get("/")
  async def root():
      return {"Welcome": "to the model!!"}
  
  #The post request to get the prediction
  @app.post("/predict", response_model=DataOut, status_code=200)
  def get_prediction(payload: DataIn):
      #Reading the input data
      text = payload.text
      prediction_outcome = inference(text)
      
      #Building the response dictionary
      response_object = {"forecast": prediction_outcome}
      return response_object