litellm_fix(mypy): fix remaining type errors (#20164)
- route_llm_request.py: add acancel_batch and afile_delete to route_type Literal - router.py: add SearchToolInfoTypedDict and search_tool_info to SearchToolTypedDict - gemini/files/transformation.py: fix validate_environment signature to match base class - responses transformation.py: fix Dict type annotations to use int instead of Optional[int] - vector_stores/endpoints.py: add team_id and user_id to LiteLLM_ManagedVectorStoresTable constructor Co-authored-by: shin-bot-litellm <shin-bot-litellm@users.noreply.github.com>
This commit is contained in:
parent
ea011633d7
commit
5434b66b9c
@ -282,6 +282,8 @@ async def get_vector_store_info(
|
||||
updated_at=vector_store.get("updated_at") or None,
|
||||
litellm_credential_name=vector_store.get("litellm_credential_name"),
|
||||
litellm_params=vector_store.get("litellm_params") or None,
|
||||
team_id=vector_store.get("team_id"),
|
||||
user_id=vector_store.get("user_id"),
|
||||
)
|
||||
return {"vector_store": vector_store_pydantic_obj}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ Supports writing files to Google AI Studio Files API.
|
||||
For vertex ai, check out the vertex_ai/files/handler.py file.
|
||||
"""
|
||||
import time
|
||||
from typing import List, Optional
|
||||
from typing import Any, List, Optional
|
||||
|
||||
import httpx
|
||||
from openai.types.file_deleted import FileDeleted
|
||||
@ -17,6 +17,7 @@ from litellm.llms.base_llm.files.transformation import (
|
||||
)
|
||||
from litellm.types.llms.gemini import GeminiCreateFilesResponseObject
|
||||
from litellm.types.llms.openai import (
|
||||
AllMessageValues,
|
||||
CreateFileRequest,
|
||||
HttpxBinaryResponseContent,
|
||||
OpenAICreateFileRequestOptionalParams,
|
||||
@ -37,22 +38,23 @@ class GoogleAIStudioFilesHandler(GeminiModelInfo, BaseFilesConfig):
|
||||
|
||||
def validate_environment(
|
||||
self,
|
||||
api_key: Optional[str],
|
||||
headers: dict,
|
||||
headers: dict[Any, Any],
|
||||
model: str,
|
||||
messages: list,
|
||||
optional_params: dict,
|
||||
litellm_params: dict,
|
||||
) -> dict:
|
||||
messages: List[AllMessageValues],
|
||||
optional_params: dict[Any, Any],
|
||||
litellm_params: dict[Any, Any],
|
||||
api_key: Optional[str] = None,
|
||||
api_base: Optional[str] = None,
|
||||
) -> dict[Any, Any]:
|
||||
"""
|
||||
Validate environment and add Gemini API key to headers.
|
||||
Google AI Studio uses x-goog-api-key header for authentication.
|
||||
"""
|
||||
api_key = self.get_api_key(api_key)
|
||||
if not api_key:
|
||||
resolved_api_key = self.get_api_key(api_key)
|
||||
if not resolved_api_key:
|
||||
raise ValueError("GEMINI_API_KEY is required for Google AI Studio file operations")
|
||||
|
||||
headers["x-goog-api-key"] = api_key
|
||||
headers["x-goog-api-key"] = resolved_api_key
|
||||
return headers
|
||||
|
||||
def get_complete_url(
|
||||
|
||||
@ -160,6 +160,8 @@ async def route_request(
|
||||
"aget_interaction",
|
||||
"adelete_interaction",
|
||||
"acancel_interaction",
|
||||
"acancel_batch",
|
||||
"afile_delete",
|
||||
],
|
||||
):
|
||||
"""
|
||||
|
||||
@ -1743,7 +1743,7 @@ class LiteLLMCompletionResponsesConfig:
|
||||
and usage.prompt_tokens_details is not None
|
||||
):
|
||||
prompt_details = usage.prompt_tokens_details
|
||||
input_details_dict: Dict[str, Optional[int]] = {}
|
||||
input_details_dict: Dict[str, int] = {}
|
||||
|
||||
if (
|
||||
hasattr(prompt_details, "cached_tokens")
|
||||
@ -1776,7 +1776,7 @@ class LiteLLMCompletionResponsesConfig:
|
||||
and usage.completion_tokens_details is not None
|
||||
):
|
||||
completion_details = usage.completion_tokens_details
|
||||
output_details_dict: Dict[str, Optional[int]] = {}
|
||||
output_details_dict: Dict[str, int] = {}
|
||||
if (
|
||||
hasattr(completion_details, "reasoning_tokens")
|
||||
and completion_details.reasoning_tokens is not None
|
||||
|
||||
@ -623,7 +623,13 @@ class SearchToolLiteLLMParams(TypedDict, total=False):
|
||||
max_retries: Optional[int]
|
||||
|
||||
|
||||
class SearchToolTypedDict(TypedDict):
|
||||
class SearchToolInfoTypedDict(TypedDict, total=False):
|
||||
"""Optional metadata about a search tool."""
|
||||
|
||||
description: str
|
||||
|
||||
|
||||
class SearchToolTypedDict(TypedDict, total=False):
|
||||
"""
|
||||
Configuration for a search tool in the router.
|
||||
|
||||
@ -639,6 +645,7 @@ class SearchToolTypedDict(TypedDict):
|
||||
|
||||
search_tool_name: Required[str]
|
||||
litellm_params: Required[SearchToolLiteLLMParams]
|
||||
search_tool_info: SearchToolInfoTypedDict
|
||||
|
||||
|
||||
class GuardrailLiteLLMParams(TypedDict, total=False):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user