Spaces:
Sleeping
Sleeping
UPDATE: trainChatbot
Browse files
app.py
CHANGED
|
@@ -510,13 +510,18 @@ async def listChatbotSources(vectorstore: str):
|
|
| 510 |
return result
|
| 511 |
|
| 512 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 513 |
|
| 514 |
@app.post("/trainChatbot")
|
| 515 |
-
async def trainChatbot(
|
|
|
|
| 516 |
texts = []
|
| 517 |
sources = []
|
| 518 |
-
fileTypes = [supabase.table("ConversAI_ChatbotDataSources").select("sourceEndpoint").eq("sourceContentURL", x).execute().data[0]["sourceEndpoint"] for x in
|
| 519 |
-
for source, fileType in zip(
|
| 520 |
if ((fileType == "/loadPDF") | (fileType == "/loadImagePDF")):
|
| 521 |
r = requests.get(source)
|
| 522 |
file = eval(r.content.decode("utf-8"))
|
|
|
|
| 510 |
return result
|
| 511 |
|
| 512 |
|
| 513 |
+
class TrainChatbot(BaseModel):
|
| 514 |
+
vectorstore: str
|
| 515 |
+
urls: list[str]
|
| 516 |
+
|
| 517 |
|
| 518 |
@app.post("/trainChatbot")
|
| 519 |
+
async def trainChatbot(trainChatbotConfig: TrainChatbot):
|
| 520 |
+
vectorstore, UrlSources = trainChatbotConfig.vectorstore, trainChatbotConfig.urls
|
| 521 |
texts = []
|
| 522 |
sources = []
|
| 523 |
+
fileTypes = [supabase.table("ConversAI_ChatbotDataSources").select("sourceEndpoint").eq("sourceContentURL", x).execute().data[0]["sourceEndpoint"] for x in UrlSources]
|
| 524 |
+
for source, fileType in zip(UrlSources, fileTypes):
|
| 525 |
if ((fileType == "/loadPDF") | (fileType == "/loadImagePDF")):
|
| 526 |
r = requests.get(source)
|
| 527 |
file = eval(r.content.decode("utf-8"))
|