Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -33,16 +33,33 @@ def ovis_chat(message, history):
|
|
33 |
response = ""
|
34 |
text_input = message["text"]
|
35 |
for msg in history:
|
36 |
-
|
|
|
37 |
conversations.append({
|
38 |
"from": "human",
|
39 |
-
"value": msg[
|
40 |
})
|
41 |
-
elif msg["role"] == "assistant":
|
42 |
conversations.append({
|
43 |
"from": "gpt",
|
44 |
-
"value": msg[
|
45 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
text_input = text_input.replace(image_placeholder, '')
|
47 |
conversations.append({
|
48 |
"from": "human",
|
@@ -133,5 +150,5 @@ latex_delimiters_set = [{
|
|
133 |
# submit_event = text_input.submit(submit_chat, [chatbot, text_input], [chatbot, text_input]).then(ovis_chat,[chatbot, image_input],chatbot)
|
134 |
# clear_btn.click(clear_chat, outputs=[chatbot, image_input, text_input])
|
135 |
|
136 |
-
demo = gr.ChatInterface(fn=ovis_chat,
|
137 |
-
demo.launch(debug=True)
|
|
|
33 |
response = ""
|
34 |
text_input = message["text"]
|
35 |
for msg in history:
|
36 |
+
# case history entry pair only has text
|
37 |
+
if isinstance(msg[0],str):
|
38 |
conversations.append({
|
39 |
"from": "human",
|
40 |
+
"value": msg[0]
|
41 |
})
|
|
|
42 |
conversations.append({
|
43 |
"from": "gpt",
|
44 |
+
"value": msg[1]
|
45 |
})
|
46 |
+
# case history pair has an image
|
47 |
+
elif isinstance(msg[0],tuple):
|
48 |
+
# case user did not pass a new image
|
49 |
+
# we override the none with the new image
|
50 |
+
if image_input is None :
|
51 |
+
# if someone uploads a file and not an image this will break
|
52 |
+
image_input = Image.open(msg[0][0]).convert("RGB")
|
53 |
+
# we always process the text
|
54 |
+
conversations.append({
|
55 |
+
"from": "human",
|
56 |
+
"value": msg[1][0]
|
57 |
+
})
|
58 |
+
conversations.append({
|
59 |
+
"from": "gpt",
|
60 |
+
"value": msg[1][1]
|
61 |
+
})
|
62 |
+
|
63 |
text_input = text_input.replace(image_placeholder, '')
|
64 |
conversations.append({
|
65 |
"from": "human",
|
|
|
150 |
# submit_event = text_input.submit(submit_chat, [chatbot, text_input], [chatbot, text_input]).then(ovis_chat,[chatbot, image_input],chatbot)
|
151 |
# clear_btn.click(clear_chat, outputs=[chatbot, image_input, text_input])
|
152 |
|
153 |
+
demo = gr.ChatInterface(fn=ovis_chat, textbox=gr.MultimodalTextbox(),multimodal=True)
|
154 |
+
demo.launch(debug=True)
|