PraneetNS commited on
Commit
aa88a35
·
verified ·
1 Parent(s): ad3a0c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -63,26 +63,26 @@ def generate(message, history):
63
 
64
  # Convert Gradio history
65
  if history:
66
- for msg in history:
67
- role = msg.get("role")
68
 
69
- content = msg.get("content", "")
70
 
71
  # Gradio 6 sometimes stores content as a list
72
- if isinstance(content, list):
73
- text = ""
74
 
75
- for part in content:
76
- if isinstance(part, dict):
77
- if part.get("type") == "text":
78
- text += part.get("text", "")
79
- elif isinstance(part, str):
80
- text += part
81
 
82
- content = text
83
 
84
- messages.append(
85
- {
86
  "role": role,
87
  "content": content,
88
  }
 
63
 
64
  # Convert Gradio history
65
  if history:
66
+ for msg in history:
67
+ role = msg.get("role")
68
 
69
+ content = msg.get("content", "")
70
 
71
  # Gradio 6 sometimes stores content as a list
72
+ if isinstance(content, list):
73
+ text = ""
74
 
75
+ for part in content:
76
+ if isinstance(part, dict):
77
+ if part.get("type") == "text":
78
+ text += part.get("text", "")
79
+ elif isinstance(part, str):
80
+ text += part
81
 
82
+ content = text
83
 
84
+ messages.append(
85
+ {
86
  "role": role,
87
  "content": content,
88
  }