Spaces:
Sleeping
Sleeping
from fastapi import APIRouter, Form, Request | |
from service import ChatService | |
from request import RequestChat | |
from typing import Optional | |
from fastapi.requests import Request | |
from function import support_function | |
from response import ResponseChat as res | |
router = APIRouter() | |
async def handle_query2_upgrade_old(request: Request, | |
user_id: str = Form(None), | |
text_all: str = Form(...), | |
question: Optional[str] = Form(None), | |
chat_name: Optional[str] = Form(None)): | |
check = support_function.check_value_user_id_controller(user_id) | |
if check is not True: | |
return check | |
request = RequestChat.RequestQuery2UpgradeOld(user_id=user_id, text_all=text_all, question=question, chat_name=chat_name) | |
return ChatService.query2_upgrade_old(request) | |
async def extract_file(user_id: str): | |
check = support_function.check_value_user_id_controller(user_id) | |
if check is not True: | |
return check | |
request = RequestChat.RequestExtractFile(user_id=user_id) | |
return ChatService.extract_file(request) | |
async def generate_question(user_id: str): | |
check = support_function.check_value_user_id_controller(user_id) | |
if check is not True: | |
return check | |
request = RequestChat.RequestGenerateQuestion(user_id=user_id) | |
return ChatService.generate_question(request) |