mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-08 08:27:19 +00:00
fix: preserve adjacent inline data: URIs in OpenAPI tool results
process_tool_result() iterated over tool_result while calling tool_result.remove(item) inside the loop. list.remove() shifts every later element down by one, so the iterator skipped the item immediately after each extracted data: URI. When an OpenAPI tool returned two or more adjacent inline data: URIs, only the first became an attachment; the second survived into the text payload and was json.dumps()'d into the model context as a raw base64 blob. Collect the non-data items into a new list and assign back in place instead of mutating during iteration.
This commit is contained in:
parent
90bb94abf9
commit
aae99ff6f3
1 changed files with 4 additions and 1 deletions
|
|
@ -1049,6 +1049,7 @@ async def process_tool_result(
|
|||
tool_response.append(resource.get('uri'))
|
||||
tool_result = tool_response[0] if len(tool_response) == 1 else tool_response
|
||||
else: # OpenAPI
|
||||
kept_items = []
|
||||
for item in tool_result:
|
||||
if isinstance(item, str) and item.startswith('data:'):
|
||||
tool_result_files.append(
|
||||
|
|
@ -1057,7 +1058,9 @@ async def process_tool_result(
|
|||
'content': item,
|
||||
}
|
||||
)
|
||||
tool_result.remove(item)
|
||||
else:
|
||||
kept_items.append(item)
|
||||
tool_result[:] = kept_items
|
||||
|
||||
if isinstance(tool_result, list):
|
||||
tool_result = {'results': tool_result}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue