willn9 commited on
Commit
c8edcdd
·
verified ·
1 Parent(s): 789d1c8

downgraded to gradio 5

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -22,7 +22,7 @@ def make_system_message(system_message, demographics, occupation, psychographics
22
 
23
  def stream_chat(
24
  message,
25
- history, # In Gradio 6, this is a list of dicts: [{"role": "user", "content": "..."}]
26
  system_message,
27
  demographics,
28
  occupation,
@@ -34,14 +34,14 @@ def stream_chat(
34
  top_p,
35
  ):
36
  """
37
- Streaming generator that yields the progressively updated chat history using Gradio 6's message format.
38
  """
39
  # 1) Build system + conversation messages
40
  sys_msg = make_system_message(system_message, demographics, occupation, psychographics, buying_habits, critical_mode)
41
 
42
  messages = [{"role": "system", "content": sys_msg}]
43
 
44
- # Append past history (Gradio 6 format is already compatible with OpenAI's format!)
45
  for msg in (history or []):
46
  messages.append({"role": msg["role"], "content": msg["content"]})
47
 
@@ -88,8 +88,8 @@ with gr.Blocks(title="Virtual Consumer Persona – Live Focus Group!") as demo:
88
  *Powered by OpenAI GPT-4o-mini. Developed by wn.*
89
  """)
90
 
91
- # Explicitly set type="messages" for Gradio 6 compatibility
92
- chatbot = gr.Chatbot(height=450, type="messages")
93
 
94
  with gr.Column():
95
  instructions = gr.Textbox(
 
22
 
23
  def stream_chat(
24
  message,
25
+ history,
26
  system_message,
27
  demographics,
28
  occupation,
 
34
  top_p,
35
  ):
36
  """
37
+ Streaming generator that yields the progressively updated chat history.
38
  """
39
  # 1) Build system + conversation messages
40
  sys_msg = make_system_message(system_message, demographics, occupation, psychographics, buying_habits, critical_mode)
41
 
42
  messages = [{"role": "system", "content": sys_msg}]
43
 
44
+ # Append past history
45
  for msg in (history or []):
46
  messages.append({"role": msg["role"], "content": msg["content"]})
47
 
 
88
  *Powered by OpenAI GPT-4o-mini. Developed by wn.*
89
  """)
90
 
91
+ # Removed the type="messages" argument to prevent the initialization crash
92
+ chatbot = gr.Chatbot(height=450)
93
 
94
  with gr.Column():
95
  instructions = gr.Textbox(