mominah commited on
Commit
4da099c
·
verified ·
1 Parent(s): 9808815

Update routes.py

Browse files
Files changed (1) hide show
  1. routes.py +18 -14
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
- PromptTemplates.get_university_chatbot_prompt()
26
  elif prompt_type == "quiz_solving":
27
- PromptTemplates.get_quiz_solving_prompt()
28
  elif prompt_type == "assignment_solving":
29
- PromptTemplates.get_assignment_solving_prompt()
30
  elif prompt_type == "paper_solving":
31
- PromptTemplates.get_paper_solving_prompt()
32
  elif prompt_type == "quiz_creation":
33
- PromptTemplates.get_quiz_creation_prompt()
34
  elif prompt_type == "assignment_creation":
35
- PromptTemplates.get_assignment_creation_prompt()
36
  elif prompt_type == "paper_creation":
37
- PromptTemplates.get_paper_creation_prompt()
38
  elif prompt_type == "check_quiz":
39
- PromptTemplates.get_check_quiz_prompt()
40
  elif prompt_type == "check_assignment":
41
- PromptTemplates.get_check_assignment_prompt()
42
  elif prompt_type == "check_paper":
43
- PromptTemplates.get_check_paper_prompt()
44
  else:
45
- prompt_type=PromptTemplates.get_quiz_solving_prompt()
46
-
47
- trainer.set_custom_prompt_template(bot_id, prompt_type)
 
 
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
  """