Spaces:
Sleeping
Sleeping
UPDATE: listChatbot
Browse files
app.py
CHANGED
@@ -416,10 +416,10 @@ async def answerQuestion(request: Request, query: str, vectorstore: str, llmMode
|
|
416 |
|
417 |
|
418 |
@app.post("/deleteChatbot")
|
419 |
-
async def deleteChatbot(
|
420 |
-
username, chatbotName =
|
421 |
supabase.table('ConversAI_ChatbotInfo').delete().eq('user_id', username).eq('chatbotname', chatbotName).execute()
|
422 |
-
return deleteTable(tableName=
|
423 |
|
424 |
|
425 |
@app.post("/listChatbots")
|
@@ -513,6 +513,45 @@ async def listChatbotSources(vectorstore: str):
|
|
513 |
return result
|
514 |
|
515 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
class TrainChatbot(BaseModel):
|
517 |
vectorstore: str
|
518 |
urls: list[str]
|
|
|
416 |
|
417 |
|
418 |
@app.post("/deleteChatbot")
|
419 |
+
async def deleteChatbot(vectorstore: str):
|
420 |
+
username, chatbotName = vectorstore.split("$")[1], vectorstore.split("$")[2]
|
421 |
supabase.table('ConversAI_ChatbotInfo').delete().eq('user_id', username).eq('chatbotname', chatbotName).execute()
|
422 |
+
return deleteTable(tableName=vectorstore)
|
423 |
|
424 |
|
425 |
@app.post("/listChatbots")
|
|
|
513 |
return result
|
514 |
|
515 |
|
516 |
+
@app.post("/deleteChatbotSource")
|
517 |
+
async def deleteChatbotSource(dataSourceName: str):
|
518 |
+
response = supabase.table("ConversAI_ChatbotDataSources").delete().eq("dataSourceName", dataSourceName).execute()
|
519 |
+
response = supabase.storage.from_('ConversAI_ChatbotDataSources').remove(dataSourceName)
|
520 |
+
return {
|
521 |
+
"output": "SUCCESS"
|
522 |
+
}
|
523 |
+
|
524 |
+
|
525 |
+
class LoadEditedJson(BaseModel):
|
526 |
+
vectorstore: str
|
527 |
+
dataSourceName: str
|
528 |
+
sourceEndpoint: str
|
529 |
+
jsonData: dict[str, str]
|
530 |
+
|
531 |
+
|
532 |
+
@app.post("/loadEditedJson")
|
533 |
+
async def loadEditedJson(loadEditedJsonConfig: LoadEditedJson):
|
534 |
+
username, chatbotName = loadEditedJsonConfig.vectorstore.split("$")[1], loadEditedJsonConfig.vectorstore.split("$")[2]
|
535 |
+
jsonData = json.dumps(loadEditedJsonConfig.jsonData, indent = 1).encode("utf-8")
|
536 |
+
fileName = createDataSourceName(loadEditedJsonConfig.dataSourceName)
|
537 |
+
response = supabase.storage.from_("ConversAI").upload(file=jsonData, path=f"{fileName}_data.json")
|
538 |
+
response = (
|
539 |
+
supabase.table("ConversAI_ChatbotDataSources")
|
540 |
+
.insert({"username": username,
|
541 |
+
"chatbotName": chatbotName,
|
542 |
+
"dataSourceName": fileName,
|
543 |
+
"sourceEndpoint": loadEditedJsonConfig.sourceEndpoint,
|
544 |
+
"sourceContentURL": os.path.join(os.environ["SUPABASE_PUBLIC_BASE_URL"], f"{fileName}_data.json")})
|
545 |
+
.execute()
|
546 |
+
)
|
547 |
+
|
548 |
+
return {
|
549 |
+
"output": "SUCCESS"
|
550 |
+
}
|
551 |
+
|
552 |
+
|
553 |
+
|
554 |
+
|
555 |
class TrainChatbot(BaseModel):
|
556 |
vectorstore: str
|
557 |
urls: list[str]
|