mgbam commited on
Commit
72311f7
·
verified ·
1 Parent(s): ee72f5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -33,16 +33,17 @@ class QADataGenerator:
33
  self._setup_input_handlers()
34
  self._initialize_session_state()
35
  # This prompt instructs the LLM to generate three Q&A pairs.
 
36
  self.custom_prompt_template = (
37
  "You are an expert in extracting question and answer pairs from documents. "
38
  "Generate 3 Q&A pairs from the following data, formatted as a JSON list of dictionaries. "
39
  "Each dictionary must have keys 'question' and 'answer'. "
40
  "The questions should be clear and concise, and the answers must be based solely on the provided data with no external information. "
41
- "Do not hallucinate. \n\n"
42
  "Example JSON Output:\n"
43
- "[{'question': 'What is the capital of France?', 'answer': 'Paris'}, "
44
- "{'question': 'What is the highest mountain in the world?', 'answer': 'Mount Everest'}, "
45
- "{'question': 'What is the chemical symbol for gold?', 'answer': 'Au'}]\n\n"
46
  "Now, generate 3 Q&A pairs from this data:\n{data}"
47
  )
48
 
@@ -250,7 +251,7 @@ class QADataGenerator:
250
  self.log_error("Unexpected HuggingFace response format.")
251
  return []
252
  else:
253
- # For OpenAI (and similar providers) assume the response is similar to:
254
  # response.choices[0].message.content
255
  if response and hasattr(response, "choices") and response.choices:
256
  raw_text = response.choices[0].message.content
 
33
  self._setup_input_handlers()
34
  self._initialize_session_state()
35
  # This prompt instructs the LLM to generate three Q&A pairs.
36
+ # Note: Literal curly braces in the example are escaped with double braces.
37
  self.custom_prompt_template = (
38
  "You are an expert in extracting question and answer pairs from documents. "
39
  "Generate 3 Q&A pairs from the following data, formatted as a JSON list of dictionaries. "
40
  "Each dictionary must have keys 'question' and 'answer'. "
41
  "The questions should be clear and concise, and the answers must be based solely on the provided data with no external information. "
42
+ "Do not hallucinate.\n\n"
43
  "Example JSON Output:\n"
44
+ "[{{'question': 'What is the capital of France?', 'answer': 'Paris'}}, "
45
+ "{{'question': 'What is the highest mountain in the world?', 'answer': 'Mount Everest'}}, "
46
+ "{{'question': 'What is the chemical symbol for gold?', 'answer': 'Au'}}]\n\n"
47
  "Now, generate 3 Q&A pairs from this data:\n{data}"
48
  )
49
 
 
251
  self.log_error("Unexpected HuggingFace response format.")
252
  return []
253
  else:
254
+ # For OpenAI (and similar providers), assume the response is similar to:
255
  # response.choices[0].message.content
256
  if response and hasattr(response, "choices") and response.choices:
257
  raw_text = response.choices[0].message.content