Anne31415 commited on
Commit
6af8057
·
1 Parent(s): a81b864

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -55,13 +55,26 @@ elif hasattr(st.session_state.run, 'status') and st.session_state.run.status ==
55
  thread_id=st.session_state.thread.id
56
  )
57
 
 
58
  # Display messages
59
  for message in reversed(st.session_state.messages.data):
60
  if message.role in ["user", "assistant"]:
61
  with st.chat_message(message.role):
62
  for content_part in message.content:
63
- message_text = content_part.text.value
64
- st.markdown(message_text)
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  if prompt := st.chat_input("Wie kann ich dir helfen?"):
67
  with st.chat_message('user'):
 
55
  thread_id=st.session_state.thread.id
56
  )
57
 
58
+
59
  # Display messages
60
  for message in reversed(st.session_state.messages.data):
61
  if message.role in ["user", "assistant"]:
62
  with st.chat_message(message.role):
63
  for content_part in message.content:
64
+ if content_part.type == 'text': # For text responses
65
+ message_text = content_part.text.value
66
+ st.markdown(message_text)
67
+ elif content_part.type == 'image_url': # For image URLs
68
+ image_url = content_part.image_url # Adjust based on actual response structure
69
+ st.image(image_url)
70
+ elif content_part.type == 'base64_image': # For base64-encoded images
71
+ base64_data = content_part.base64_image # Adjust based on actual response structure
72
+ image_data = base64.b64decode(base64_data)
73
+ image = Image.open(io.BytesIO(image_data))
74
+ st.image(image)
75
+
76
+
77
+
78
 
79
  if prompt := st.chat_input("Wie kann ich dir helfen?"):
80
  with st.chat_message('user'):