@@ -198,7 +198,7 @@ async def afile_delete(
198
198
199
199
def file_delete (
200
200
file_id : str ,
201
- custom_llm_provider : Literal ["openai" ] = "openai" ,
201
+ custom_llm_provider : Literal ["openai" , "azure" ] = "openai" ,
202
202
extra_headers : Optional [Dict [str , str ]] = None ,
203
203
extra_body : Optional [Dict [str , str ]] = None ,
204
204
** kwargs ,
@@ -210,6 +210,22 @@ def file_delete(
210
210
"""
211
211
try :
212
212
optional_params = GenericLiteLLMParams (** kwargs )
213
+ ### TIMEOUT LOGIC ###
214
+ timeout = optional_params .timeout or kwargs .get ("request_timeout" , 600 ) or 600
215
+ # set timeout for 10 minutes by default
216
+
217
+ if (
218
+ timeout is not None
219
+ and isinstance (timeout , httpx .Timeout )
220
+ and supports_httpx_timeout (custom_llm_provider ) == False
221
+ ):
222
+ read_timeout = timeout .read or 600
223
+ timeout = read_timeout # default 10 min timeout
224
+ elif timeout is not None and not isinstance (timeout , httpx .Timeout ):
225
+ timeout = float (timeout ) # type: ignore
226
+ elif timeout is None :
227
+ timeout = 600.0
228
+ _is_async = kwargs .pop ("is_async" , False ) is True
213
229
if custom_llm_provider == "openai" :
214
230
# for deepinfra/perplexity/anyscale/groq we check in get_llm_provider and pass in the api base from there
215
231
api_base = (
@@ -231,34 +247,46 @@ def file_delete(
231
247
or litellm .openai_key
232
248
or os .getenv ("OPENAI_API_KEY" )
233
249
)
234
- ### TIMEOUT LOGIC ###
235
- timeout = (
236
- optional_params .timeout or kwargs .get ("request_timeout" , 600 ) or 600
250
+ response = openai_files_instance .delete_file (
251
+ file_id = file_id ,
252
+ _is_async = _is_async ,
253
+ api_base = api_base ,
254
+ api_key = api_key ,
255
+ timeout = timeout ,
256
+ max_retries = optional_params .max_retries ,
257
+ organization = organization ,
237
258
)
238
- # set timeout for 10 minutes by default
259
+ elif custom_llm_provider == "azure" :
260
+ api_base = optional_params .api_base or litellm .api_base or get_secret ("AZURE_API_BASE" ) # type: ignore
261
+ api_version = (
262
+ optional_params .api_version
263
+ or litellm .api_version
264
+ or get_secret ("AZURE_API_VERSION" )
265
+ ) # type: ignore
239
266
240
- if (
241
- timeout is not None
242
- and isinstance (timeout , httpx .Timeout )
243
- and supports_httpx_timeout (custom_llm_provider ) == False
244
- ):
245
- read_timeout = timeout .read or 600
246
- timeout = read_timeout # default 10 min timeout
247
- elif timeout is not None and not isinstance (timeout , httpx .Timeout ):
248
- timeout = float (timeout ) # type: ignore
249
- elif timeout is None :
250
- timeout = 600.0
267
+ api_key = (
268
+ optional_params .api_key
269
+ or litellm .api_key
270
+ or litellm .azure_key
271
+ or get_secret ("AZURE_OPENAI_API_KEY" )
272
+ or get_secret ("AZURE_API_KEY" )
273
+ ) # type: ignore
251
274
252
- _is_async = kwargs .pop ("is_async" , False ) is True
275
+ extra_body = optional_params .get ("extra_body" , {})
276
+ azure_ad_token : Optional [str ] = None
277
+ if extra_body is not None :
278
+ azure_ad_token = extra_body .pop ("azure_ad_token" , None )
279
+ else :
280
+ azure_ad_token = get_secret ("AZURE_AD_TOKEN" ) # type: ignore
253
281
254
- response = openai_files_instance .delete_file (
255
- file_id = file_id ,
282
+ response = azure_files_instance .delete_file (
256
283
_is_async = _is_async ,
257
284
api_base = api_base ,
258
285
api_key = api_key ,
286
+ api_version = api_version ,
259
287
timeout = timeout ,
260
288
max_retries = optional_params .max_retries ,
261
- organization = organization ,
289
+ file_id = file_id ,
262
290
)
263
291
else :
264
292
raise litellm .exceptions .BadRequestError (
0 commit comments