Spaces:
Runtime error
Runtime error
Update routes.py
Browse files
routes.py
CHANGED
|
@@ -20,35 +20,39 @@ def initialize_bot(prompt_type: str):
|
|
| 20 |
trainer = get_trainer()
|
| 21 |
try:
|
| 22 |
bot_id = trainer.initialize_bot_id()
|
| 23 |
-
|
|
|
|
| 24 |
if prompt_type == "university":
|
| 25 |
-
|
| 26 |
elif prompt_type == "quiz_solving":
|
| 27 |
-
|
| 28 |
elif prompt_type == "assignment_solving":
|
| 29 |
-
|
| 30 |
elif prompt_type == "paper_solving":
|
| 31 |
-
|
| 32 |
elif prompt_type == "quiz_creation":
|
| 33 |
-
|
| 34 |
elif prompt_type == "assignment_creation":
|
| 35 |
-
|
| 36 |
elif prompt_type == "paper_creation":
|
| 37 |
-
|
| 38 |
elif prompt_type == "check_quiz":
|
| 39 |
-
|
| 40 |
elif prompt_type == "check_assignment":
|
| 41 |
-
|
| 42 |
elif prompt_type == "check_paper":
|
| 43 |
-
|
| 44 |
else:
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
return InitializeBotResponse(bot_id=bot_id)
|
| 49 |
except Exception as e:
|
| 50 |
raise HTTPException(status_code=500, detail=str(e))
|
| 51 |
|
|
|
|
| 52 |
@router.post("/upload_document")
|
| 53 |
async def upload_document(bot_id: str = Form(...), file: UploadFile = File(...)):
|
| 54 |
"""
|
|
|
|
| 20 |
trainer = get_trainer()
|
| 21 |
try:
|
| 22 |
bot_id = trainer.initialize_bot_id()
|
| 23 |
+
|
| 24 |
+
# Assign the prompt template based on the prompt type.
|
| 25 |
if prompt_type == "university":
|
| 26 |
+
prompt_template = PromptTemplates.get_university_chatbot_prompt()
|
| 27 |
elif prompt_type == "quiz_solving":
|
| 28 |
+
prompt_template = PromptTemplates.get_quiz_solving_prompt()
|
| 29 |
elif prompt_type == "assignment_solving":
|
| 30 |
+
prompt_template = PromptTemplates.get_assignment_solving_prompt()
|
| 31 |
elif prompt_type == "paper_solving":
|
| 32 |
+
prompt_template = PromptTemplates.get_paper_solving_prompt()
|
| 33 |
elif prompt_type == "quiz_creation":
|
| 34 |
+
prompt_template = PromptTemplates.get_quiz_creation_prompt()
|
| 35 |
elif prompt_type == "assignment_creation":
|
| 36 |
+
prompt_template = PromptTemplates.get_assignment_creation_prompt()
|
| 37 |
elif prompt_type == "paper_creation":
|
| 38 |
+
prompt_template = PromptTemplates.get_paper_creation_prompt()
|
| 39 |
elif prompt_type == "check_quiz":
|
| 40 |
+
prompt_template = PromptTemplates.get_check_quiz_prompt()
|
| 41 |
elif prompt_type == "check_assignment":
|
| 42 |
+
prompt_template = PromptTemplates.get_check_assignment_prompt()
|
| 43 |
elif prompt_type == "check_paper":
|
| 44 |
+
prompt_template = PromptTemplates.get_check_paper_prompt()
|
| 45 |
else:
|
| 46 |
+
# Default prompt template if prompt_type is not recognized.
|
| 47 |
+
prompt_template = PromptTemplates.get_quiz_solving_prompt()
|
| 48 |
+
|
| 49 |
+
# Pass the assigned prompt template to the bot.
|
| 50 |
+
trainer.set_custom_prompt_template(bot_id, prompt_template)
|
| 51 |
return InitializeBotResponse(bot_id=bot_id)
|
| 52 |
except Exception as e:
|
| 53 |
raise HTTPException(status_code=500, detail=str(e))
|
| 54 |
|
| 55 |
+
|
| 56 |
@router.post("/upload_document")
|
| 57 |
async def upload_document(bot_id: str = Form(...), file: UploadFile = File(...)):
|
| 58 |
"""
|