Spaces:
Build error
Build error
from fastapi import FastAPI, Request | |
from fastapi.responses import HTMLResponse | |
from fastapi.templating import Jinja2Templates | |
from chat import chat_conversations | |
from database_functions import create_new_session,save_mood_summary | |
import spacy | |
import os | |
import time | |
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE" | |
app = FastAPI() | |
templates = Jinja2Templates(directory="templates") | |
async def read_root(request: Request): | |
return templates.TemplateResponse("chatwidget.html", {"request": request}) | |
async def read_root(request: Request): | |
return templates.TemplateResponse("chatwidget.html", {"request": request}) | |
async def read_root(request: Request): | |
start = time.time_ns() | |
form_data = await request.json() | |
query = form_data.get('query') | |
user_id = form_data.get("user_id") | |
response_text = chat_conversations(query,user_id) | |
print("message is send after : ",time.time()- start) | |
return response_text | |
async def start_session(request: Request): | |
start = time.time_ns() | |
form_data = await request.json() | |
# print("form data",form_data) | |
user_id = form_data.get("user_id") | |
# print("save user id ",user_id) | |
response = create_new_session(user_id) | |
print("session is created after : ",time.time()- start) | |
return response | |
async def mood_summary(request:Request): | |
form_data = await request.json() | |
user_id = form_data.get("user_id") | |
save_mood_summary(form_data,user_id) | |
return "mood saved successfully..." |