@@ -120,28 +120,14 @@ async def _generate_payload(
120120 "Template: {template}\n "
121121 "User topic: {user_topic}\n "
122122 "Preference: {preference}\n "
123- "Previously generated questions (do not repeat): \n {history_context}\n "
123+ "Conversation context: {history_context}\n "
124124 "Knowledge context: {knowledge_context}\n "
125125 "Enabled tools: {available_tools}\n \n "
126126 'Return JSON {{"question_type":"","question":"","options":{{}},"correct_answer":"","explanation":""}}'
127127 )
128128
129- # Serialize the template without the bulky knowledge_context in metadata —
130- # it is already included via the dedicated {knowledge_context} placeholder
131- # and its presence inside the template JSON would cause it to appear twice,
132- # dominating the prompt and making the LLM generate identical questions for
133- # every template regardless of their individual concentrations.
134- template_dict = template .__dict__ .copy ()
135- if isinstance (template_dict .get ("metadata" ), dict ):
136- stripped_metadata = {
137- k : v
138- for k , v in template_dict ["metadata" ].items ()
139- if k != "knowledge_context"
140- }
141- template_dict ["metadata" ] = stripped_metadata
142-
143129 user_prompt = user_prompt_template .format (
144- template = json .dumps (template_dict , ensure_ascii = False , indent = 2 ),
130+ template = json .dumps (template . __dict__ , ensure_ascii = False , indent = 2 ),
145131 user_topic = user_topic ,
146132 preference = preference or "(none)" ,
147133 history_context = history_context or "(none)" ,
0 commit comments