jeremierostan commited on
Commit
3e94b44
·
verified ·
1 Parent(s): 7837959

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -43,15 +43,11 @@ def chat_with_assistant(message, history):
43
  messages = client.beta.threads.messages.list(thread_id=thread.id)
44
  content_block = messages.data[0].content[0]
45
 
46
- # Print the attributes of content_block for debugging
47
- print("Content block attributes:", dir(content_block))
48
-
49
  if hasattr(content_block, 'text'):
50
  assistant_response = content_block.text.value
51
- elif hasattr(content_block, 'image'):
52
- assistant_response = f"<img src='{content_block.image.url}' alt='Image' />"
53
- elif hasattr(content_block, 'graph'):
54
- assistant_response = f"<div>{content_block.graph.url}</div>" # Assuming graph content
55
  else:
56
  assistant_response = "[Unknown content type]"
57
  break
 
43
  messages = client.beta.threads.messages.list(thread_id=thread.id)
44
  content_block = messages.data[0].content[0]
45
 
46
+ # Check if the response is text or an image
 
 
47
  if hasattr(content_block, 'text'):
48
  assistant_response = content_block.text.value
49
+ elif hasattr(content_block, 'image_file'):
50
+ assistant_response = f"<img src='{content_block.image_file.url}' alt='Image' />"
 
 
51
  else:
52
  assistant_response = "[Unknown content type]"
53
  break