bstraehle commited on
Commit
cbfb5b7
1 Parent(s): 708ce28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -37,7 +37,7 @@ def chat(message, history, openai_api_key):
37
  raise gr.Error("Message is required.")
38
 
39
  with lock:
40
- text_value, image_value = "", ""
41
 
42
  try:
43
  if os.environ["OPENAI_API_KEY"] != openai_api_key:
@@ -60,15 +60,14 @@ def chat(message, history, openai_api_key):
60
  text_values, image_values = extract_content_values(messages)
61
 
62
  if len(image_values) > 0:
63
- image_value = f"[https://platform.openai.com/storage/files/{image_values[0]}](https://platform.openai.com/storage/files/{image_values[0]})<br><br>"
64
 
65
  for text_value in list(reversed(text_values)):
66
- text_value += f"{text_value}<br><br>"
67
  except Exception as e:
68
  raise gr.Error(e)
69
 
70
- return f"{image_value}{text_value}"
71
- #return f"{'<hr>'.join(list(reversed(text_values))[1:])}{images}"
72
 
73
  gr.ChatInterface(
74
  fn=chat,
 
37
  raise gr.Error("Message is required.")
38
 
39
  with lock:
40
+ result_text, result_image = "", ""
41
 
42
  try:
43
  if os.environ["OPENAI_API_KEY"] != openai_api_key:
 
60
  text_values, image_values = extract_content_values(messages)
61
 
62
  if len(image_values) > 0:
63
+ result_image = f"[https://platform.openai.com/storage/files/{image_values[0]}](https://platform.openai.com/storage/files/{image_values[0]})<br><br>"
64
 
65
  for text_value in list(reversed(text_values)):
66
+ result_text += f"{text_value}<br><br>"
67
  except Exception as e:
68
  raise gr.Error(e)
69
 
70
+ return f"{result_image}{result_text}"
 
71
 
72
  gr.ChatInterface(
73
  fn=chat,