akhaliq HF Staff commited on
Commit
a11dbaa
·
1 Parent(s): d7619e6

update fix

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -5738,6 +5738,14 @@ This will help me create a better design for you."""
5738
  chunk_content = chunk.choices[0].delta.content
5739
 
5740
  if chunk_content:
 
 
 
 
 
 
 
 
5741
  if _current_model["id"] == "gpt-5":
5742
  # If this chunk is only placeholder thinking, surface a status update without polluting content
5743
  if is_placeholder_thinking_only(chunk_content):
 
5738
  chunk_content = chunk.choices[0].delta.content
5739
 
5740
  if chunk_content:
5741
+ # Ensure chunk_content is always a string to avoid regex errors
5742
+ if not isinstance(chunk_content, str):
5743
+ # Handle structured thinking chunks (like ThinkChunk objects from magistral)
5744
+ chunk_str = str(chunk_content) if chunk_content is not None else ""
5745
+ if '[ThinkChunk(' in chunk_str:
5746
+ # This is a structured thinking chunk, skip it to avoid polluting output
5747
+ continue
5748
+ chunk_content = chunk_str
5749
  if _current_model["id"] == "gpt-5":
5750
  # If this chunk is only placeholder thinking, surface a status update without polluting content
5751
  if is_placeholder_thinking_only(chunk_content):