Spaces:
Sleeping
Sleeping
Commit
·
718d910
1
Parent(s):
8c0f543
- changed to himBHs
Browse files
app.py
CHANGED
|
@@ -156,7 +156,7 @@ async def addPDFData(vectorstore: str, pdf: UploadFile = File(...)):
|
|
| 156 |
text = ""
|
| 157 |
for page in reader.pages:
|
| 158 |
text += page.extract_text()
|
| 159 |
-
username, chatbotname = vectorstore.split("
|
| 160 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 161 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 162 |
limit = client.table("ConversAI_UserConfig").select("tokenLimit").eq("user_id", username).execute().data[0][
|
|
@@ -181,7 +181,7 @@ async def returnText(pdf: UploadFile = File(...)):
|
|
| 181 |
|
| 182 |
@app.post("/addText")
|
| 183 |
async def addText(vectorstore: str, text: str):
|
| 184 |
-
username, chatbotname = vectorstore.split("
|
| 185 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 186 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 187 |
newCount = currentCount + len(text)
|
|
@@ -205,7 +205,7 @@ class AddQAPair(BaseModel):
|
|
| 205 |
|
| 206 |
@app.post("/addQAPair")
|
| 207 |
async def addText(addQaPair: AddQAPair):
|
| 208 |
-
username, chatbotname = addQaPair.vectorstore.split("
|
| 209 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 210 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 211 |
qa = f"QUESTION: {addQaPair.question}\tANSWER: {addQaPair.answer}"
|
|
@@ -229,7 +229,7 @@ async def addWebsite(vectorstore: str, websiteUrls: list[str]):
|
|
| 229 |
docs = loader.load()
|
| 230 |
text = "\n\n".join(
|
| 231 |
[f"Metadata:\n{docs[doc].metadata} \nPage Content:\n {docs[doc].page_content}" for doc in range(len(docs))])
|
| 232 |
-
username, chatbotname = vectorstore.split("
|
| 233 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 234 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 235 |
newCount = currentCount + len(text)
|
|
@@ -252,7 +252,7 @@ async def answerQuestion(query: str, vectorstore: str, llmModel: str = "llama3-7
|
|
| 252 |
|
| 253 |
@app.post("/deleteChatbot")
|
| 254 |
async def delete(chatbotName: str):
|
| 255 |
-
username, chatbotName = chatbotName.split("
|
| 256 |
client.table('ConversAI_ChatbotInfo').delete().eq('user_id', username).eq('chatbotname', chatbotName).execute()
|
| 257 |
return deleteTable(tableName=chatbotName)
|
| 258 |
|
|
@@ -271,7 +271,7 @@ async def crawlUrl(baseUrl: str):
|
|
| 271 |
|
| 272 |
@app.post("/getCurrentCount")
|
| 273 |
async def getCount(vectorstore: str):
|
| 274 |
-
username, chatbotName = vectorstore.split("
|
| 275 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 276 |
return {
|
| 277 |
"currentCount": df[(df['user_id'] == username) & (df['chatbotname'] == chatbotName)]['charactercount'].iloc[0]
|
|
|
|
| 156 |
text = ""
|
| 157 |
for page in reader.pages:
|
| 158 |
text += page.extract_text()
|
| 159 |
+
username, chatbotname = vectorstore.split("$")[1], vectorstore.split("$")[2]
|
| 160 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 161 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 162 |
limit = client.table("ConversAI_UserConfig").select("tokenLimit").eq("user_id", username).execute().data[0][
|
|
|
|
| 181 |
|
| 182 |
@app.post("/addText")
|
| 183 |
async def addText(vectorstore: str, text: str):
|
| 184 |
+
username, chatbotname = vectorstore.split("$")[1], vectorstore.split("$")[2]
|
| 185 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 186 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 187 |
newCount = currentCount + len(text)
|
|
|
|
| 205 |
|
| 206 |
@app.post("/addQAPair")
|
| 207 |
async def addText(addQaPair: AddQAPair):
|
| 208 |
+
username, chatbotname = addQaPair.vectorstore.split("$")[1], addQaPair.vectorstore.split("$")[2]
|
| 209 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 210 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 211 |
qa = f"QUESTION: {addQaPair.question}\tANSWER: {addQaPair.answer}"
|
|
|
|
| 229 |
docs = loader.load()
|
| 230 |
text = "\n\n".join(
|
| 231 |
[f"Metadata:\n{docs[doc].metadata} \nPage Content:\n {docs[doc].page_content}" for doc in range(len(docs))])
|
| 232 |
+
username, chatbotname = vectorstore.split("$")[1], vectorstore.split("$")[2]
|
| 233 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 234 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 235 |
newCount = currentCount + len(text)
|
|
|
|
| 252 |
|
| 253 |
@app.post("/deleteChatbot")
|
| 254 |
async def delete(chatbotName: str):
|
| 255 |
+
username, chatbotName = chatbotName.split("$")[1], chatbotName.split("$")[2]
|
| 256 |
client.table('ConversAI_ChatbotInfo').delete().eq('user_id', username).eq('chatbotname', chatbotName).execute()
|
| 257 |
return deleteTable(tableName=chatbotName)
|
| 258 |
|
|
|
|
| 271 |
|
| 272 |
@app.post("/getCurrentCount")
|
| 273 |
async def getCount(vectorstore: str):
|
| 274 |
+
username, chatbotName = vectorstore.split("$")[1], vectorstore.split("$")[2]
|
| 275 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 276 |
return {
|
| 277 |
"currentCount": df[(df['user_id'] == username) & (df['chatbotname'] == chatbotName)]['charactercount'].iloc[0]
|