From 0a34a3b93557717028800129260f8a3928baaf40 Mon Sep 17 00:00:00 2001 From: Alex55 Date: Wed, 23 Apr 2025 16:27:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20routers/client.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/client.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/routers/client.py b/routers/client.py index 55ec8a7..2912053 100644 --- a/routers/client.py +++ b/routers/client.py @@ -341,3 +341,27 @@ async def jobs_delete(data: jobs_delete, x_api_key: str = Header(...), db: Sessi raise HTTPException(status_code=400, detail="Error processing data") return {"status": "ok", "message": "Data received", "user_id": user_id, "job_id": job_id} + + + + +class QuestionRequest(BaseModel): + question: str + client_name: str + token: str + +@router.post("/ask_question") +async def ask_question(data: QuestionRequest): + try: + response = requests.get( + f"https://devnet.turboapply.ai/api/qaRequest/?question={data.question}", + headers={"token": data.token} + ) + response.raise_for_status() + external_data = response.json() + content = external_data['result']['choices'][0]['message']['content'] + result = content.split(":")[-1].strip() + + except Exception as e: + raise HTTPException(status_code=502, detail=f"Error from external API: {str(e)}") + return {"answer": f"{result}"} \ No newline at end of file