Spaces:
Sleeping
Sleeping
UPDATE: New Endpoints
Browse files
app.py
CHANGED
|
@@ -45,7 +45,7 @@ async def addPDFData(vectorstore: str, pdf: UploadFile = File(...)):
|
|
| 45 |
text += page.extract_text()
|
| 46 |
username, chatbotname = vectorstore.split("-")[1], vectorstore.split("-")[2]
|
| 47 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 48 |
-
currentCount = df[(df["username"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"][0]
|
| 49 |
newCount = currentCount + len(text)
|
| 50 |
if newCount < 400000:
|
| 51 |
client.table("ConversAI_ChatbotInfo").update({"charactercount": str(newCount)}).eq("username", username).eq("chatbotname", chatbotname).execute()
|
|
@@ -60,7 +60,7 @@ async def addPDFData(vectorstore: str, pdf: UploadFile = File(...)):
|
|
| 60 |
async def addText(vectorstore: str, text: str):
|
| 61 |
username, chatbotname = vectorstore.split("-")[1], vectorstore.split("-")[2]
|
| 62 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 63 |
-
currentCount = df[(df["username"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"][0]
|
| 64 |
newCount = currentCount + len(text)
|
| 65 |
if newCount < 400000:
|
| 66 |
client.table("ConversAI_ChatbotInfo").update({"charactercount": str(newCount)}).eq("username", username).eq("chatbotname", chatbotname).execute()
|
|
@@ -79,7 +79,7 @@ async def addWebsite(vectorstore: str, websiteUrl: str):
|
|
| 79 |
text = "\n\n\n\n".join([f"Metadata:\n{docs[doc].metadata} \nPage Content:\n {docs[doc].page_content}" for doc in range(len(docs))])
|
| 80 |
username, chatbotname = vectorstore.split("-")[1], vectorstore.split("-")[2]
|
| 81 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 82 |
-
currentCount = df[(df["username"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"][0]
|
| 83 |
newCount = currentCount + len(text)
|
| 84 |
if newCount < 400000:
|
| 85 |
client.table("ConversAI_ChatbotInfo").update({"charactercount": str(newCount)}).eq("username", username).eq("chatbotname", chatbotname).execute()
|
|
@@ -115,5 +115,5 @@ async def getCount(vectorstore: str):
|
|
| 115 |
username, chatbotName = chatbotName.split("-")[1], chatbotName.split("-")[2]
|
| 116 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 117 |
return {
|
| 118 |
-
"currentCount": df[(df['username'] == username) & (df['chatbotname'] == chatbotName)]['charactercount'][0]
|
| 119 |
}
|
|
|
|
| 45 |
text += page.extract_text()
|
| 46 |
username, chatbotname = vectorstore.split("-")[1], vectorstore.split("-")[2]
|
| 47 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 48 |
+
currentCount = df[(df["username"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 49 |
newCount = currentCount + len(text)
|
| 50 |
if newCount < 400000:
|
| 51 |
client.table("ConversAI_ChatbotInfo").update({"charactercount": str(newCount)}).eq("username", username).eq("chatbotname", chatbotname).execute()
|
|
|
|
| 60 |
async def addText(vectorstore: str, text: str):
|
| 61 |
username, chatbotname = vectorstore.split("-")[1], vectorstore.split("-")[2]
|
| 62 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 63 |
+
currentCount = df[(df["username"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 64 |
newCount = currentCount + len(text)
|
| 65 |
if newCount < 400000:
|
| 66 |
client.table("ConversAI_ChatbotInfo").update({"charactercount": str(newCount)}).eq("username", username).eq("chatbotname", chatbotname).execute()
|
|
|
|
| 79 |
text = "\n\n\n\n".join([f"Metadata:\n{docs[doc].metadata} \nPage Content:\n {docs[doc].page_content}" for doc in range(len(docs))])
|
| 80 |
username, chatbotname = vectorstore.split("-")[1], vectorstore.split("-")[2]
|
| 81 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 82 |
+
currentCount = df[(df["username"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 83 |
newCount = currentCount + len(text)
|
| 84 |
if newCount < 400000:
|
| 85 |
client.table("ConversAI_ChatbotInfo").update({"charactercount": str(newCount)}).eq("username", username).eq("chatbotname", chatbotname).execute()
|
|
|
|
| 115 |
username, chatbotName = chatbotName.split("-")[1], chatbotName.split("-")[2]
|
| 116 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 117 |
return {
|
| 118 |
+
"currentCount": df[(df['username'] == username) & (df['chatbotname'] == chatbotName)]['charactercount'].iloc[0]
|
| 119 |
}
|