Spaces:
Running
Running
Update PCAgent/chat.py
Browse files- PCAgent/chat.py +13 -27
PCAgent/chat.py
CHANGED
@@ -53,7 +53,7 @@ def add_response_old(role, prompt, chat_history, image=None):
|
|
53 |
},
|
54 |
{
|
55 |
"type": "image",
|
56 |
-
"image":
|
57 |
},
|
58 |
]
|
59 |
else:
|
@@ -76,23 +76,13 @@ def add_response(role, prompt, chat_history, image=[], use_qwen=False):
|
|
76 |
},
|
77 |
]
|
78 |
for i in range(len(image)):
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
}
|
87 |
-
}
|
88 |
-
)
|
89 |
-
else:
|
90 |
-
content.append(
|
91 |
-
{
|
92 |
-
"type": "image",
|
93 |
-
"image": image[i]
|
94 |
-
}
|
95 |
-
)
|
96 |
new_chat_history.append([role, content])
|
97 |
return new_chat_history
|
98 |
|
@@ -108,17 +98,13 @@ def add_response_two_image(role, prompt, chat_history, image):
|
|
108 |
"text": prompt
|
109 |
},
|
110 |
{
|
111 |
-
"type": "
|
112 |
-
"
|
113 |
-
"url": f"data:image/jpeg;base64,{base64_image1}"
|
114 |
-
}
|
115 |
},
|
116 |
{
|
117 |
-
"type": "
|
118 |
-
"
|
119 |
-
|
120 |
-
}
|
121 |
-
},
|
122 |
]
|
123 |
|
124 |
new_chat_history.append([role, content])
|
|
|
53 |
},
|
54 |
{
|
55 |
"type": "image",
|
56 |
+
"image": image
|
57 |
},
|
58 |
]
|
59 |
else:
|
|
|
76 |
},
|
77 |
]
|
78 |
for i in range(len(image)):
|
79 |
+
base64_image = resize_encode_image(image[i])
|
80 |
+
content.append(
|
81 |
+
{
|
82 |
+
"type": "image_",
|
83 |
+
"image": image[i]
|
84 |
+
}
|
85 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
new_chat_history.append([role, content])
|
87 |
return new_chat_history
|
88 |
|
|
|
98 |
"text": prompt
|
99 |
},
|
100 |
{
|
101 |
+
"type": "image",
|
102 |
+
"image": image[0]
|
|
|
|
|
103 |
},
|
104 |
{
|
105 |
+
"type": "image",
|
106 |
+
"image": image[1]
|
107 |
+
}
|
|
|
|
|
108 |
]
|
109 |
|
110 |
new_chat_history.append([role, content])
|