mouadenna commited on
Commit
8c98bdb
1 Parent(s): f103b06

Update pages/2_phonics.py

Browse files
Files changed (1) hide show
  1. pages/2_phonics.py +11 -3
pages/2_phonics.py CHANGED
@@ -164,11 +164,19 @@ def process_response(user_input: str, conversation_history: list) -> tuple:
164
  model_response, conversation_history = generate_response(initial_prompt, conversation_history)
165
  else:
166
  model_response, conversation_history = generate_response(user_input, conversation_history)
167
- lessonList = ast.literal_eval(model_response)
 
 
 
 
 
 
 
 
168
  return lessonList, conversation_history
169
 
170
  @st.cache_data
171
- def generate_image(prompt: str) -> str:
172
  try:
173
  return findImg(prompt)
174
  except:
@@ -405,7 +413,7 @@ def main():
405
 
406
  with col2:
407
  if 'img_prompt' in st.session_state:
408
- st.session_state['img_path']=generate_image(st.session_state['img_prompt'])
409
  del st.session_state['img_prompt']
410
 
411
  st.image(st.session_state['img_path'], caption="Generated Image")
 
164
  model_response, conversation_history = generate_response(initial_prompt, conversation_history)
165
  else:
166
  model_response, conversation_history = generate_response(user_input, conversation_history)
167
+
168
+ pattern = re.compile(r"\[(.*?)\]", re.DOTALL)
169
+
170
+ # Find the match
171
+ match = pattern.search(model_response)
172
+
173
+ list_content = f"[{match.group(1)}]"
174
+
175
+ lessonList = ast.literal_eval(list_content)
176
  return lessonList, conversation_history
177
 
178
  @st.cache_data
179
+ def get_image(prompt: str) -> str:
180
  try:
181
  return findImg(prompt)
182
  except:
 
413
 
414
  with col2:
415
  if 'img_prompt' in st.session_state:
416
+ st.session_state['img_path']=get_image(st.session_state['img_prompt'])
417
  del st.session_state['img_prompt']
418
 
419
  st.image(st.session_state['img_path'], caption="Generated Image")