mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-09 22:31:41 +00:00
Fix: mypy errors
This commit is contained in:
parent
fa2b065238
commit
d3b2afbbe4
7 changed files with 29 additions and 11 deletions
|
|
@ -868,7 +868,7 @@ async def acancel_batch(
|
|||
extra_headers: Optional[Dict[str, str]] = None,
|
||||
extra_body: Optional[Dict[str, str]] = None,
|
||||
**kwargs,
|
||||
) -> Batch:
|
||||
) -> LiteLLMBatch:
|
||||
"""
|
||||
Async: Cancels a batch.
|
||||
|
||||
|
|
@ -912,7 +912,7 @@ def cancel_batch(
|
|||
extra_headers: Optional[Dict[str, str]] = None,
|
||||
extra_body: Optional[Dict[str, str]] = None,
|
||||
**kwargs,
|
||||
) -> Union[Batch, Coroutine[Any, Any, Batch]]:
|
||||
) -> Union[LiteLLMBatch, Coroutine[Any, Any, LiteLLMBatch]]:
|
||||
"""
|
||||
Cancels a batch.
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from openai import AsyncOpenAI, OpenAI
|
|||
|
||||
from litellm.llms.azure.azure import AsyncAzureOpenAI, AzureOpenAI
|
||||
from litellm.types.llms.openai import (
|
||||
Batch,
|
||||
CancelBatchRequest,
|
||||
CreateBatchRequest,
|
||||
RetrieveBatchRequest,
|
||||
|
|
@ -159,6 +158,21 @@ class AzureBatchesAPI(BaseAzureLLM):
|
|||
raise ValueError(
|
||||
"OpenAI client is not initialized. Make sure api_key is passed or OPENAI_API_KEY is set in the environment."
|
||||
)
|
||||
|
||||
if _is_async is True:
|
||||
if not isinstance(azure_client, (AsyncAzureOpenAI, AsyncOpenAI)):
|
||||
raise ValueError(
|
||||
"Azure client is not an instance of AsyncAzureOpenAI or AsyncOpenAI. Make sure you passed an async client."
|
||||
)
|
||||
return self.acancel_batch( # type: ignore
|
||||
cancel_batch_data=cancel_batch_data, client=azure_client
|
||||
)
|
||||
|
||||
# At this point, azure_client is guaranteed to be a sync client
|
||||
if not isinstance(azure_client, (AzureOpenAI, OpenAI)):
|
||||
raise ValueError(
|
||||
"Azure client is not an instance of AzureOpenAI or OpenAI. Make sure you passed a sync client."
|
||||
)
|
||||
response = azure_client.batches.cancel(**cancel_batch_data)
|
||||
return LiteLLMBatch(**response.model_dump())
|
||||
|
||||
|
|
|
|||
|
|
@ -1962,6 +1962,11 @@ class OpenAIBatchesAPI(BaseLLM):
|
|||
cancel_batch_data=cancel_batch_data, openai_client=openai_client
|
||||
)
|
||||
|
||||
# At this point, openai_client is guaranteed to be a sync OpenAI client
|
||||
if not isinstance(openai_client, OpenAI):
|
||||
raise ValueError(
|
||||
"OpenAI client is not an instance of OpenAI. Make sure you passed a sync OpenAI client."
|
||||
)
|
||||
response = openai_client.batches.cancel(**cancel_batch_data)
|
||||
return LiteLLMBatch(**response.model_dump())
|
||||
|
||||
|
|
|
|||
|
|
@ -1239,9 +1239,6 @@ async def user_api_key_auth(
|
|||
request_data=request_data, request=request
|
||||
)
|
||||
route: str = get_request_route(request=request)
|
||||
print(f"🔥route: {route}")
|
||||
print(f"🔥request_data: {request_data}")
|
||||
print(f"🔥api_key: {api_key}")
|
||||
## CHECK IF ROUTE IS ALLOWED
|
||||
|
||||
user_api_key_auth_obj = await _user_api_key_auth_builder(
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ from litellm.proxy.openai_files_endpoints.common_utils import (
|
|||
_is_base64_encoded_unified_file_id,
|
||||
decode_model_from_file_id,
|
||||
encode_file_id_with_model,
|
||||
get_batch_id_from_unified_batch_id,
|
||||
get_credentials_for_model,
|
||||
get_model_id_from_unified_batch_id,
|
||||
get_models_from_unified_file_id,
|
||||
get_original_file_id,
|
||||
prepare_data_with_credentials,
|
||||
|
|
|
|||
|
|
@ -392,8 +392,10 @@ class ProxyBaseLLMRequestProcessing:
|
|||
"acreate_batch",
|
||||
"aretrieve_batch",
|
||||
"alist_batches",
|
||||
"acancel_batch",
|
||||
"afile_content",
|
||||
"afile_retrieve",
|
||||
"afile_delete",
|
||||
"atext_completion",
|
||||
"acreate_fine_tuning_job",
|
||||
"acancel_fine_tuning_job",
|
||||
|
|
@ -606,6 +608,8 @@ class ProxyBaseLLMRequestProcessing:
|
|||
"aget_interaction",
|
||||
"adelete_interaction",
|
||||
"acancel_interaction",
|
||||
"acancel_batch",
|
||||
"afile_delete",
|
||||
],
|
||||
proxy_logging_obj: ProxyLogging,
|
||||
general_settings: dict,
|
||||
|
|
|
|||
|
|
@ -296,9 +296,9 @@ class AnthropicMessagesDocumentParam(TypedDict, total=False):
|
|||
citations: Optional[CitationsObject]
|
||||
|
||||
|
||||
class AnthropicMessagesToolResultContent(TypedDict):
|
||||
type: Literal["text"]
|
||||
text: str
|
||||
class AnthropicMessagesToolResultContent(TypedDict, total=False):
|
||||
type: Required[Literal["text"]]
|
||||
text: Required[str]
|
||||
cache_control: Optional[Union[dict, ChatCompletionCachedContent]]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue