mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
fix(typing): keep router fence visibility and py310-safe Self import
Bind the Protocol-narrowed routers in pass_through_endpoints and rag ingestion to router-named locals so router_surface_check still sees the aadapter_completion and aocr uses, and import Self from typing_extensions in prisma_client for check_py310_typing_imports.
This commit is contained in:
parent
c226a70b1d
commit
5815c092f0
3 changed files with 9 additions and 17 deletions
|
|
@ -37,11 +37,11 @@ from litellm.secret_managers.main import str_to_bool
|
|||
if TYPE_CHECKING:
|
||||
from collections.abc import Sequence
|
||||
from types import TracebackType
|
||||
from typing import Self
|
||||
|
||||
from prisma import Prisma
|
||||
from prisma import models as prisma_models
|
||||
from prisma.types import HttpConfig
|
||||
from typing_extensions import Self
|
||||
|
||||
from litellm.repositories.prisma_protocols import TableActions
|
||||
|
||||
|
|
|
|||
|
|
@ -374,11 +374,8 @@ async def chat_completion_pass_through_endpoint(
|
|||
and data["model"] is not None
|
||||
and llm_router.registry().resolve(data["model"], kind="recognized")
|
||||
):
|
||||
llm_response = asyncio.create_task(
|
||||
require_attributes(llm_router, _AdapterCompletionRouter, "aadapter_completion").aadapter_completion(
|
||||
**data
|
||||
)
|
||||
)
|
||||
adapter_router = require_attributes(llm_router, _AdapterCompletionRouter, "aadapter_completion")
|
||||
llm_response = asyncio.create_task(adapter_router.aadapter_completion(**data))
|
||||
elif (
|
||||
llm_router is not None
|
||||
and data["model"] not in router_model_names
|
||||
|
|
@ -387,19 +384,13 @@ async def chat_completion_pass_through_endpoint(
|
|||
or len(llm_router.registry().patterns().patterns) > 0
|
||||
)
|
||||
): # check for wildcard routes or default deployment before checking deployment_names
|
||||
llm_response = asyncio.create_task(
|
||||
require_attributes(llm_router, _AdapterCompletionRouter, "aadapter_completion").aadapter_completion(
|
||||
**data
|
||||
)
|
||||
)
|
||||
adapter_router = require_attributes(llm_router, _AdapterCompletionRouter, "aadapter_completion")
|
||||
llm_response = asyncio.create_task(adapter_router.aadapter_completion(**data))
|
||||
elif llm_router is not None and data["model"] in llm_router.registry().names(
|
||||
kind="deployment_names"
|
||||
): # model in router deployments, calling a specific deployment on the router (lowest priority)
|
||||
llm_response = asyncio.create_task(
|
||||
require_attributes(llm_router, _AdapterCompletionRouter, "aadapter_completion").aadapter_completion(
|
||||
**data, specific_deployment=True
|
||||
)
|
||||
)
|
||||
adapter_router = require_attributes(llm_router, _AdapterCompletionRouter, "aadapter_completion")
|
||||
llm_response = asyncio.create_task(adapter_router.aadapter_completion(**data, specific_deployment=True))
|
||||
elif user_model is not None: # `litellm --model <your-model-name>`
|
||||
llm_response = asyncio.create_task(litellm.aadapter_completion(**data))
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -186,7 +186,8 @@ class BaseRAGIngestion(ABC):
|
|||
|
||||
# Use router if available
|
||||
if self.router is not None:
|
||||
ocr_response = await require_attributes(self.router, _OcrRouter, "aocr").aocr(
|
||||
ocr_router: Final = require_attributes(self.router, _OcrRouter, "aocr")
|
||||
ocr_response = await ocr_router.aocr(
|
||||
model=ocr_model,
|
||||
document={"type": doc_type, url_key: data_url},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue