dantedgp commited on
Commit
589481f
·
1 Parent(s): ca7a5b1

Verify question and answer

Browse files
Files changed (1) hide show
  1. app.py +17 -15
app.py CHANGED
@@ -7,22 +7,21 @@ nltk.download('punkt')
7
  # Instantiate the model
8
  model = pipeline(model="dantedgp/question-generator", tokenizer="google-t5/t5-small")
9
 
 
 
 
 
 
 
 
 
 
 
 
10
  st.set_page_config(page_title='AI Quiz Generator')
11
  st.title('AI Quiz Generator')
12
 
13
- text_input = st.text_area(
14
- 'Enter your text',
15
- value="""Algae cells can be used to synthesize lipids for the production of biofuels and foods.
16
- Integral transmembrane proteins shuttle nutrients in and out of the cell.
17
- Liver cells can metabolize poisons and alcohol.
18
- Chocolate helps the brain stay focused.
19
- Cellular respiration is the inverse of photosynthesis.
20
- Caffeine blocks adenosine receptors.
21
- Adenosine Triphosphate (ATP) is the ernergy currency of the cell.
22
- The mitochondria is the powerhouse of the cell.""",
23
- height=200
24
- )
25
-
26
  generate_button = st.button("Generate")
27
 
28
  if generate_button:
@@ -31,7 +30,10 @@ if generate_button:
31
  st.warning('Please enter some text.')
32
  for sentence in sentences:
33
  try:
34
- question = model(f"ask: {sentence}")[0]['generated_text']
35
- st.write(question)
 
 
 
36
  except:
37
  st.warning('An error occurred while generating the question.')
 
7
  # Instantiate the model
8
  model = pipeline(model="dantedgp/question-generator", tokenizer="google-t5/t5-small")
9
 
10
+ placeholder = """
11
+ Algae cells can be used to synthesize lipids for the production of biofuels and foods.
12
+ Integral transmembrane proteins shuttle nutrients in and out of the cell.
13
+ Liver cells can metabolize poisons and alcohol.
14
+ Chocolate helps the brain stay focused.
15
+ Cellular respiration is the inverse of photosynthesis.
16
+ Caffeine blocks adenosine receptors.
17
+ Adenosine Triphosphate (ATP) is the ernergy currency of the cell.
18
+ The mitochondria is the powerhouse of the cell.
19
+ """
20
+
21
  st.set_page_config(page_title='AI Quiz Generator')
22
  st.title('AI Quiz Generator')
23
 
24
+ text_input = st.text_area('Enter your text', value=placeholder, height=200)
 
 
 
 
 
 
 
 
 
 
 
 
25
  generate_button = st.button("Generate")
26
 
27
  if generate_button:
 
30
  st.warning('Please enter some text.')
31
  for sentence in sentences:
32
  try:
33
+ output = model(f"ask: {sentence}")[0]['generated_text']
34
+ question, answer = output.split("?")
35
+
36
+ if question and answer and answer not in question:
37
+ st.write(output)
38
  except:
39
  st.warning('An error occurred while generating the question.')