Spaces:
Sleeping
Sleeping
DEBUG: List Chatbots
Browse files- app.py +6 -6
- functions.py +1 -1
app.py
CHANGED
|
@@ -149,7 +149,7 @@ async def addPDFData(vectorstore: str, pdf: UploadFile = File(...)):
|
|
| 149 |
text = ""
|
| 150 |
for page in reader.pages:
|
| 151 |
text += page.extract_text()
|
| 152 |
-
username, chatbotname = vectorstore.split("
|
| 153 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 154 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 155 |
limit = client.table("ConversAI_UserConfig").select("tokenLimit").eq("user_id", username).execute().data[0][
|
|
@@ -174,7 +174,7 @@ async def returnText(pdf: UploadFile = File(...)):
|
|
| 174 |
|
| 175 |
@app.post("/addText")
|
| 176 |
async def addText(vectorstore: str, text: str):
|
| 177 |
-
username, chatbotname = vectorstore.split("
|
| 178 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 179 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 180 |
newCount = currentCount + len(text)
|
|
@@ -198,7 +198,7 @@ class AddQAPair(BaseModel):
|
|
| 198 |
|
| 199 |
@app.post("/addQAPair")
|
| 200 |
async def addText(addQaPair: AddQAPair):
|
| 201 |
-
username, chatbotname = addQaPair.vectorstore.split("
|
| 202 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 203 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 204 |
qa = f"QUESTION: {addQaPair.question}\tANSWER: {addQaPair.answer}"
|
|
@@ -222,7 +222,7 @@ async def addWebsite(vectorstore: str, websiteUrls: list[str]):
|
|
| 222 |
docs = loader.load()
|
| 223 |
text = "\n\n".join(
|
| 224 |
[f"Metadata:\n{docs[doc].metadata} \nPage Content:\n {docs[doc].page_content}" for doc in range(len(docs))])
|
| 225 |
-
username, chatbotname = vectorstore.split("
|
| 226 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 227 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 228 |
newCount = currentCount + len(text)
|
|
@@ -245,7 +245,7 @@ async def answerQuestion(query: str, vectorstore: str, llmModel: str = "llama3-7
|
|
| 245 |
|
| 246 |
@app.post("/deleteChatbot")
|
| 247 |
async def delete(chatbotName: str):
|
| 248 |
-
username, chatbotName = chatbotName.split("
|
| 249 |
client.table('ConversAI_ChatbotInfo').delete().eq('user_id', username).eq('chatbotname', chatbotName).execute()
|
| 250 |
return deleteTable(tableName=chatbotName)
|
| 251 |
|
|
@@ -264,7 +264,7 @@ async def crawlUrl(baseUrl: str):
|
|
| 264 |
|
| 265 |
@app.post("/getCurrentCount")
|
| 266 |
async def getCount(vectorstore: str):
|
| 267 |
-
username, chatbotName = vectorstore.split("
|
| 268 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 269 |
return {
|
| 270 |
"currentCount": df[(df['user_id'] == username) & (df['chatbotname'] == chatbotName)]['charactercount'].iloc[0]
|
|
|
|
| 149 |
text = ""
|
| 150 |
for page in reader.pages:
|
| 151 |
text += page.extract_text()
|
| 152 |
+
username, chatbotname = vectorstore.split("$")[1], vectorstore.split("$")[2]
|
| 153 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 154 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 155 |
limit = client.table("ConversAI_UserConfig").select("tokenLimit").eq("user_id", username).execute().data[0][
|
|
|
|
| 174 |
|
| 175 |
@app.post("/addText")
|
| 176 |
async def addText(vectorstore: str, text: str):
|
| 177 |
+
username, chatbotname = vectorstore.split("$")[1], vectorstore.split("$")[2]
|
| 178 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 179 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 180 |
newCount = currentCount + len(text)
|
|
|
|
| 198 |
|
| 199 |
@app.post("/addQAPair")
|
| 200 |
async def addText(addQaPair: AddQAPair):
|
| 201 |
+
username, chatbotname = addQaPair.vectorstore.split("$")[1], addQaPair.vectorstore.split("$")[2]
|
| 202 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 203 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 204 |
qa = f"QUESTION: {addQaPair.question}\tANSWER: {addQaPair.answer}"
|
|
|
|
| 222 |
docs = loader.load()
|
| 223 |
text = "\n\n".join(
|
| 224 |
[f"Metadata:\n{docs[doc].metadata} \nPage Content:\n {docs[doc].page_content}" for doc in range(len(docs))])
|
| 225 |
+
username, chatbotname = vectorstore.split("$")[1], vectorstore.split("$")[2]
|
| 226 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 227 |
currentCount = df[(df["user_id"] == username) & (df["chatbotname"] == chatbotname)]["charactercount"].iloc[0]
|
| 228 |
newCount = currentCount + len(text)
|
|
|
|
| 245 |
|
| 246 |
@app.post("/deleteChatbot")
|
| 247 |
async def delete(chatbotName: str):
|
| 248 |
+
username, chatbotName = chatbotName.split("$")[1], chatbotName.split("$")[2]
|
| 249 |
client.table('ConversAI_ChatbotInfo').delete().eq('user_id', username).eq('chatbotname', chatbotName).execute()
|
| 250 |
return deleteTable(tableName=chatbotName)
|
| 251 |
|
|
|
|
| 264 |
|
| 265 |
@app.post("/getCurrentCount")
|
| 266 |
async def getCount(vectorstore: str):
|
| 267 |
+
username, chatbotName = vectorstore.split("$")[1], vectorstore.split("$")[2]
|
| 268 |
df = pd.DataFrame(client.table("ConversAI_ChatbotInfo").select("*").execute().data)
|
| 269 |
return {
|
| 270 |
"currentCount": df[(df['user_id'] == username) & (df['chatbotname'] == chatbotName)]['charactercount'].iloc[0]
|
functions.py
CHANGED
|
@@ -261,7 +261,7 @@ def listTables(username: str):
|
|
| 261 |
global qdrantClient
|
| 262 |
qdrantCollections = qdrantClient.get_collections()
|
| 263 |
return {
|
| 264 |
-
"output": list(filter(lambda x: True if x.split("
|
| 265 |
[x.name for x in qdrantCollections.collections]))
|
| 266 |
}
|
| 267 |
except Exception as e:
|
|
|
|
| 261 |
global qdrantClient
|
| 262 |
qdrantCollections = qdrantClient.get_collections()
|
| 263 |
return {
|
| 264 |
+
"output": list(filter(lambda x: True if x.split("$")[1] == username else False,
|
| 265 |
[x.name for x in qdrantCollections.collections]))
|
| 266 |
}
|
| 267 |
except Exception as e:
|