Skip to content

Commit 0ab62a0

Browse files
Ark-kuncopybara-github
authored andcommitted
chore: LLM - Improved the typing of the from_pretrained method
PiperOrigin-RevId: 540099054
1 parent 1fda417 commit 0ab62a0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

vertexai/_model_garden/_model_garden_models.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"""Base class for working with Model Garden models."""
1717

1818
import dataclasses
19-
from typing import Dict, Optional, Type
19+
from typing import Dict, Optional, Type, TypeVar
2020

2121
from google.cloud import aiplatform
2222
from google.cloud.aiplatform import base
@@ -44,6 +44,8 @@
4444

4545
_LOGGER = base.Logger(__name__)
4646

47+
T = TypeVar("T", bound="_ModelGardenModel")
48+
4749

4850
@dataclasses.dataclass
4951
class _ModelInfo:
@@ -180,7 +182,7 @@ def __init__(self, model_id: str, endpoint_name: Optional[str] = None):
180182
)
181183

182184
@classmethod
183-
def from_pretrained(cls, model_name: str) -> "_ModelGardenModel":
185+
def from_pretrained(cls: Type[T], model_name: str) -> T:
184186
"""Loads a _ModelGardenModel.
185187
186188
Args:

0 commit comments

Comments
 (0)