File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
volcenginesdkarkruntime/resources Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 1010import json
1111import warnings
1212from copy import deepcopy
13+ from urllib .parse import urlparse
1314from typing import (
1415 Union ,
1516 Iterable ,
@@ -187,14 +188,21 @@ def _process_messages(
187188 if part .get ("type" , None ) == "text" :
188189 part ["text" ] = f (part ["text" ])
189190 elif part .get ("type" , None ) == "image_url" :
190- if part ["image_url" ]["url" ].startswith ("data:" ):
191+ parse_result = urlparse (part ["image_url" ]["url" ])
192+ if parse_result .scheme == 'data' :
191193 part ["image_url" ]["url" ] = f (
192194 part ["image_url" ]["url" ])
193- else :
195+ elif parse_result . scheme == 'http' or parse_result . scheme == 'https' :
194196 warnings .warn (
195197 "encryption is not supported for image url, "
196198 "please use base64 image if you want encryption"
197199 )
200+ else :
201+ raise TypeError (
202+ "encryption is not supported for image url scheme {}" .format (
203+ parse_result
204+ )
205+ )
198206 else :
199207 raise TypeError (
200208 "encryption is not supported for content type {}" .format (
You can’t perform that action at this time.
0 commit comments