1
1
from collections .abc import Mapping , Sequence
2
- from os import path
3
2
from typing import Any
4
3
5
4
from sqlalchemy import select
@@ -180,7 +179,6 @@ def _extract_tool_response_binary(self, tool_response: list[ToolInvokeMessage])
180
179
for response in tool_response :
181
180
if response .type in {ToolInvokeMessage .MessageType .IMAGE_LINK , ToolInvokeMessage .MessageType .IMAGE }:
182
181
url = str (response .message ) if response .message else None
183
- ext = path .splitext (url )[1 ] if url else ".bin"
184
182
tool_file_id = str (url ).split ("/" )[- 1 ].split ("." )[0 ]
185
183
transfer_method = response .meta .get ("transfer_method" , FileTransferMethod .TOOL_FILE )
186
184
@@ -202,7 +200,6 @@ def _extract_tool_response_binary(self, tool_response: list[ToolInvokeMessage])
202
200
)
203
201
result .append (file )
204
202
elif response .type == ToolInvokeMessage .MessageType .BLOB :
205
- # get tool file id
206
203
tool_file_id = str (response .message ).split ("/" )[- 1 ].split ("." )[0 ]
207
204
with Session (db .engine ) as session :
208
205
stmt = select (ToolFile ).where (ToolFile .id == tool_file_id )
@@ -211,7 +208,6 @@ def _extract_tool_response_binary(self, tool_response: list[ToolInvokeMessage])
211
208
raise ValueError (f"tool file { tool_file_id } not exists" )
212
209
mapping = {
213
210
"tool_file_id" : tool_file_id ,
214
- "type" : FileType .IMAGE ,
215
211
"transfer_method" : FileTransferMethod .TOOL_FILE ,
216
212
}
217
213
file = file_factory .build_from_mapping (
@@ -228,13 +224,8 @@ def _extract_tool_response_binary(self, tool_response: list[ToolInvokeMessage])
228
224
tool_file = session .scalar (stmt )
229
225
if tool_file is None :
230
226
raise ToolFileError (f"Tool file { tool_file_id } does not exist" )
231
- if "." in url :
232
- extension = "." + url .split ("/" )[- 1 ].split ("." )[1 ]
233
- else :
234
- extension = ".bin"
235
227
mapping = {
236
228
"tool_file_id" : tool_file_id ,
237
- "type" : FileType .IMAGE ,
238
229
"transfer_method" : transfer_method ,
239
230
"url" : url ,
240
231
}
0 commit comments