(
self,
model_type: Union[ModelType, str],
model_config_dict: Optional[Dict[str, Any]] = None,
api_key: Optional[str] = None,
url: Optional[str] = None,
token_counter: Optional[BaseTokenCounter] = None,
)
| 54 | """ |
| 55 | |
| 56 | def __init__( |
| 57 | self, |
| 58 | model_type: Union[ModelType, str], |
| 59 | model_config_dict: Optional[Dict[str, Any]] = None, |
| 60 | api_key: Optional[str] = None, |
| 61 | url: Optional[str] = None, |
| 62 | token_counter: Optional[BaseTokenCounter] = None, |
| 63 | ) -> None: |
| 64 | if model_config_dict is None: |
| 65 | model_config_dict = SGLangConfig().as_dict() |
| 66 | |
| 67 | self.server_process = None |
| 68 | self.last_run_time: Optional[float] = ( |
| 69 | None # Will be set when the server starts |
| 70 | ) |
| 71 | self._lock = threading.Lock() |
| 72 | self._inactivity_thread: Optional[threading.Thread] = None |
| 73 | |
| 74 | super().__init__( |
| 75 | model_type, model_config_dict, api_key, url, token_counter |
| 76 | ) |
| 77 | |
| 78 | self._client = None |
| 79 | |
| 80 | if self._url: |
| 81 | # Initialize the client if an existing URL is provided |
| 82 | self._client = OpenAI( |
| 83 | timeout=180, |
| 84 | max_retries=3, |
| 85 | api_key="Set-but-ignored", # required but ignored |
| 86 | base_url=self._url, |
| 87 | ) |
| 88 | |
| 89 | def _start_server(self) -> None: |
| 90 | from sglang.utils import ( # type: ignore[import-untyped] |
nothing calls this directly
no test coverage detected