BtB-ExpC commited on
Commit
0bccf5d
·
1 Parent(s): 2899fe9

changed formatting templates

Browse files
chains/diagnoser_chain.py CHANGED
@@ -12,19 +12,64 @@ class DiagnoserChain(BaseModel):
12
  async def run(self, user_query: str, exercise_format: str) -> str:
13
  """
14
  Runs the composite chain:
15
- 1. Standardizes the exercise description (if exercise_format isn't Raw).
16
  2. Generates a diagnosis from the standardized format.
17
  """
18
- # --- Step 1: Standardize the exercise description ---
19
  if exercise_format == "Raw (original)":
20
  standardized_exercise = user_query
21
  else:
22
  mapping = {
23
- "Markdown": "Please format the exercise in Markdown.",
24
- "XML": "Please format the exercise in XML, using '",
25
- "Plaintext": "Please format the exercise in plain text."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  }
27
- formatting_instructions = mapping.get(exercise_format, "Please format the exercise in Markdown.")
28
  prompt_std = await self.template_standardize.aformat_prompt(
29
  user_input=user_query,
30
  formatting_instructions=formatting_instructions
 
12
  async def run(self, user_query: str, exercise_format: str) -> str:
13
  """
14
  Runs the composite chain:
15
+ 1. Standardizes the exercise formatting (if exercise_format isn't Raw).
16
  2. Generates a diagnosis from the standardized format.
17
  """
18
+ # --- Step 1: Standardize the exercise formatting ---
19
  if exercise_format == "Raw (original)":
20
  standardized_exercise = user_query
21
  else:
22
  mapping = {
23
+ "Markdown": (
24
+ "Please format the exercise in Markdown, similarly to this example:\n\n"
25
+ "**Theorie** \n"
26
+ "Eenzaamheid wordt door ieder persoon anders ervaren en is daarom subjectief.\n\n"
27
+ "---\n\n"
28
+ "**Vraag** \n"
29
+ "Wat is de meest passende definitie van eenzaamheid?\n\n"
30
+ "1. Het gevoel geen connectie te hebben met anderen \n"
31
+ "2. Regelmatig in je eentje zijn \n"
32
+ "3. Beide bovenstaande \n"
33
+ "4. Geen van bovenstaande \n\n"
34
+ "**Correct antwoord:** \n"
35
+ "1. Het gevoel geen connectie te hebben met anderen."
36
+ ),
37
+ "XML": (
38
+ "Please reformat in XML, following this example:\n"
39
+ "<exercise>\n"
40
+ " <content>\n"
41
+ " <question>Theorie:\n"
42
+ "Eenzaamheid wordt door ieder persoon anders ervaren en is daarom subjectief.\n\n"
43
+ "Vraag:\n"
44
+ "Wat is de meest passende definitie van eenzaamheid?</question>\n"
45
+ " <choices>\n"
46
+ " <choice id=\"1\">Het gevoel geen connectie te hebben met anderen</choice>\n"
47
+ " <choice id=\"2\">Regelmatig in je eentje zijn</choice>\n"
48
+ " <choice id=\"3\">Beide bovenstaande</choice>\n"
49
+ " <choice id=\"4\">Geen van bovenstaande</choice>\n"
50
+ " </choices>\n"
51
+ " </content>\n"
52
+ " <answer>\n"
53
+ " <correct-choice>1</correct-choice>\n"
54
+ " <explanation></explanation>\n"
55
+ " </answer>\n"
56
+ "</exercise>"
57
+ ),
58
+ "Plaintext": (
59
+ "Please reformat in plain text, following this example:\n\n"
60
+ "Theorie\n"
61
+ "Eenzaamheid wordt door ieder persoon anders ervaren en is daarom subjectief.\n\n"
62
+ "Vraag\n"
63
+ "Wat is de meest passende definitie van eenzaamheid?\n\n"
64
+ "1. Het gevoel geen connectie te hebben met anderen\n"
65
+ "2. Regelmatig in je eentje zijn\n"
66
+ "3. Beide bovenstaande\n"
67
+ "4. Geen van bovenstaande\n\n"
68
+ "Correct antwoord:\n"
69
+ "1. Het gevoel geen connectie te hebben met anderen."
70
+ )
71
  }
72
+ formatting_instructions = mapping.get(exercise_format, "Please reformat the given exercise to ease further processing.")
73
  prompt_std = await self.template_standardize.aformat_prompt(
74
  user_input=user_query,
75
  formatting_instructions=formatting_instructions
config/chain_configs.py CHANGED
@@ -10,12 +10,12 @@ chain_configs = {
10
  "class": DiagnoserChain,
11
  "template_standardize": standardize_template,
12
  "template_diagnose": diagnose_template,
13
- "llm_standardize": llms["gpt-4o-mini"], # Always fixed
14
- "llm_diagnose": llms["gpt-4o"], # Default; can be replaced in UI
15
  },
16
  "distractors": {
17
  "class": DistractorsChain,
18
  "template": distractors_template,
19
- "llm": llms["gpt-4o"],
20
  },
21
  }
 
10
  "class": DiagnoserChain,
11
  "template_standardize": standardize_template,
12
  "template_diagnose": diagnose_template,
13
+ "llm_standardize": llms["GPT-4o-mini"], # Always fixed
14
+ "llm_diagnose": llms["GPT-4o"], # Default; can be replaced in UI
15
  },
16
  "distractors": {
17
  "class": DistractorsChain,
18
  "template": distractors_template,
19
+ "llm": llms["GPT-4o"],
20
  },
21
  }