Spaces:
Sleeping
Sleeping
UPDATE: increased timeout
Browse files- Dockerfile +1 -1
- app.py +3 -16
Dockerfile
CHANGED
@@ -28,4 +28,4 @@ RUN mkdir -p /.EasyOCR && chmod -R 777 /.EasyOCR
|
|
28 |
|
29 |
EXPOSE 7860
|
30 |
|
31 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
28 |
|
29 |
EXPOSE 7860
|
30 |
|
31 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--timeout-keep-alive", "300", "--timeout-graceful-shutdown", "600"]
|
app.py
CHANGED
@@ -63,23 +63,11 @@ async def addPDFData(vectorstore: str, pdf: UploadFile = File(...)):
|
|
63 |
}
|
64 |
|
65 |
|
66 |
-
@app.post("/
|
67 |
-
async def
|
68 |
pdf = await pdf.read()
|
69 |
text = getTextFromImagePDF(pdfBytes = pdf)
|
70 |
-
|
71 |
-
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
72 |
-
currentCount = df[(df["username"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
73 |
-
limit = client.table("ConversAI_UserConfig").select("tokenLimit").eq("username", username).execute().data[0]["tokenLimit"]
|
74 |
-
newCount = currentCount + len(text)
|
75 |
-
if newCount < int(limit):
|
76 |
-
client.table("ConversAI_ChatbotInfo").update({"charactercount": str(newCount)}).eq("username", username).eq("chatbotname", chatbotname).execute()
|
77 |
-
return addDocuments(text = text, vectorstore = vectorstore)
|
78 |
-
else:
|
79 |
-
return {
|
80 |
-
"output": "DOCUMENT EXCEEDING LIMITS, PLEASE TRY WITH A SMALLER DOCUMENT."
|
81 |
-
}
|
82 |
-
|
83 |
|
84 |
|
85 |
@app.post("/addText")
|
@@ -98,7 +86,6 @@ async def addText(vectorstore: str, text: str):
|
|
98 |
}
|
99 |
|
100 |
|
101 |
-
|
102 |
class AddQAPair(BaseModel):
|
103 |
vectorstore: str
|
104 |
question: str
|
|
|
63 |
}
|
64 |
|
65 |
|
66 |
+
@app.post("/scanAndReturnText")
|
67 |
+
async def returnText(pdf: UploadFile = File(...)):
|
68 |
pdf = await pdf.read()
|
69 |
text = getTextFromImagePDF(pdfBytes = pdf)
|
70 |
+
return text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
|
73 |
@app.post("/addText")
|
|
|
86 |
}
|
87 |
|
88 |
|
|
|
89 |
class AddQAPair(BaseModel):
|
90 |
vectorstore: str
|
91 |
question: str
|