Spaces:
Runtime error
Runtime error
from fastapi import FastAPI, Request | |
from fastapi.responses import HTMLResponse | |
from fastapi.templating import Jinja2Templates | |
from chat import chat_conversations, create_new_session | |
import spacy | |
import os | |
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): | |
print(request) | |
form_data = await request.json() | |
query = form_data.get('query') | |
user_id = form_data.get("user_id") | |
response_text = chat_conversations(query,user_id) | |
return response_text | |
async def start_session(request: Request): | |
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(response) | |
return response |