bstraehle commited on
Commit
e4c0f84
1 Parent(s): 0c5bd22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -38,7 +38,7 @@ def chat(message, history, openai_api_key):
38
 
39
  with lock:
40
  text_values, image_values = [], []
41
- download_link = ""
42
 
43
  try:
44
  if os.environ["OPENAI_API_KEY"] != openai_api_key:
@@ -59,14 +59,17 @@ def chat(message, history, openai_api_key):
59
  recurse_execute_tool_calls(get_thread(), run, run_steps, 0)
60
  messages = get_messages(get_thread())
61
  text_values, image_values = extract_content_values(messages)
 
 
 
62
 
63
- # TODO: Handle multiple images and other file types
64
- if len(image_values) > 0:
65
- download_link = f"<hr>[Download](https://platform.openai.com/storage/files/{image_values[0]})"
66
  except Exception as e:
67
  raise gr.Error(e)
68
 
69
- return f"{'<hr>'.join(list(reversed(text_values))[1:])}{download_link}"
 
70
 
71
  gr.ChatInterface(
72
  fn=chat,
 
38
 
39
  with lock:
40
  text_values, image_values = [], []
41
+ texts, images = "", ""
42
 
43
  try:
44
  if os.environ["OPENAI_API_KEY"] != openai_api_key:
 
59
  recurse_execute_tool_calls(get_thread(), run, run_steps, 0)
60
  messages = get_messages(get_thread())
61
  text_values, image_values = extract_content_values(messages)
62
+
63
+ for text_value in list(reversed(text_values)):
64
+ texts += f"{text_value})<br>"
65
 
66
+ for image_value in image_values:
67
+ images += f"[https://platform.openai.com/storage/files/{image_value}](https://platform.openai.com/storage/files/{image_value})<br>"
 
68
  except Exception as e:
69
  raise gr.Error(e)
70
 
71
+ return f"{texts}{images}"
72
+ #return f"{'<hr>'.join(list(reversed(text_values))[1:])}{images}"
73
 
74
  gr.ChatInterface(
75
  fn=chat,