You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Invalid 'messages[3]'. Image URLs are only allowed for messages with role 'user', but this message with role 'tool' contains an image URL.", 'type': 'invalid_request_error', 'param': 'messages[3]', 'code': 'invalid_value'}}
137
+
138
+
And:
139
+
140
+
An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'.
141
+
"""
142
+
return [
143
+
{
144
+
"tool_call_id": tool_call_id,
145
+
"role": "tool",
146
+
"name": tool_name,
147
+
"content": "",
148
+
},
149
+
{
150
+
"role": "user",
151
+
"content": [
152
+
{
153
+
"type": "text",
154
+
"text": f"{tool_name} returned the following response:",
logger.debug("merging multiple responses from MCP: {}", generated_responses)
195
+
# multiple response, probably from MCP, merge
196
+
return [
197
+
{
198
+
"tool_call_id": tool_call_id,
199
+
"role": "tool",
200
+
"name": tool_name,
201
+
"content": "\n".join(generated_responses),
202
+
}
203
+
]
204
+
else:
205
+
"""
206
+
Handle:
162
207
163
-
Invalid 'messages[3]'. Image URLs are only allowed for messages with role 'user', but this message with role 'tool' contains an image URL.", 'type': 'invalid_request_error', 'param': 'messages[3]', 'code': 'invalid_value'}}
208
+
Invalid 'messages[3]'. Image URLs are only allowed for messages with role 'user', but this message with role 'tool' contains an image URL.", 'type': 'invalid_request_error', 'param': 'messages[3]', 'code': 'invalid_value'}}
164
209
165
-
And:
210
+
And:
166
211
167
-
An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'.
168
-
"""
169
-
ret_responses.extend(
170
-
[
171
-
{
172
-
"tool_call_id": tool_call_id,
173
-
"role": "tool",
174
-
"name": tool_name,
175
-
"content": "",
176
-
},
212
+
An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'.
213
+
"""
214
+
return [
215
+
{
216
+
"tool_call_id": tool_call_id,
217
+
"role": "tool",
218
+
"name": tool_name,
219
+
"content": "",
220
+
},
221
+
{
222
+
"role": "user",
223
+
"content": [
177
224
{
178
-
"role": "user",
179
-
"content": [
180
-
{
181
-
"type": "text",
182
-
"text": f"{tool_name} returned the following response:",
183
-
},
184
-
generated_response,
185
-
],
225
+
"type": "text",
226
+
"text": f"{tool_name} returned the following response:",
0 commit comments