|
27 | 27 | UsageFieldsResponse, |
28 | 28 | Balance, |
29 | 29 | BalancesResponse, |
| 30 | + ModelResponse, |
| 31 | + ModelsResponse, |
30 | 32 | ) |
31 | 33 | from .options import ( |
32 | 34 | ProjectOptions, |
| 35 | + ModelOptions, |
33 | 36 | KeyOptions, |
34 | 37 | ScopeOptions, |
35 | 38 | InviteOptions, |
|
41 | 44 |
|
42 | 45 | class AsyncManageClient( |
43 | 46 | AbstractAsyncRestClient |
44 | | -): # pylint: disable=too-many-public-methods |
| 47 | +): # pylint: disable=too-many-public-methods,too-many-lines |
45 | 48 | """ |
46 | 49 | A client for managing Deepgram projects and associated resources via the Deepgram API. |
47 | 50 |
|
@@ -239,6 +242,223 @@ async def delete_project( |
239 | 242 | self._logger.debug("ManageClient.delete_project LEAVE") |
240 | 243 | return res |
241 | 244 |
|
| 245 | + async def list_project_models( |
| 246 | + self, |
| 247 | + project_id: str, |
| 248 | + options: Optional[Union[Dict, ModelOptions]] = None, |
| 249 | + timeout: Optional[httpx.Timeout] = None, |
| 250 | + addons: Optional[Dict] = None, |
| 251 | + headers: Optional[Dict] = None, |
| 252 | + **kwargs, |
| 253 | + ) -> ModelsResponse: |
| 254 | + """ |
| 255 | + Please see get_project_models. |
| 256 | + """ |
| 257 | + return await self.get_project_models( |
| 258 | + project_id, |
| 259 | + options=options, |
| 260 | + timeout=timeout, |
| 261 | + addons=addons, |
| 262 | + headers=headers, |
| 263 | + **kwargs, |
| 264 | + ) |
| 265 | + |
| 266 | + async def get_project_models( |
| 267 | + self, |
| 268 | + project_id: str, |
| 269 | + options: Optional[Union[Dict, ModelOptions]] = None, |
| 270 | + timeout: Optional[httpx.Timeout] = None, |
| 271 | + addons: Optional[Dict] = None, |
| 272 | + headers: Optional[Dict] = None, |
| 273 | + **kwargs, |
| 274 | + ) -> ModelsResponse: |
| 275 | + """ |
| 276 | + Gets models for a specific project. |
| 277 | +
|
| 278 | + Reference: |
| 279 | + https://developers.deepgram.com/reference/get-project |
| 280 | + https://developers.deepgram.com/reference/get-model |
| 281 | +
|
| 282 | + Args: |
| 283 | + project_id (str): The ID of the project. |
| 284 | + timeout (Optional[httpx.Timeout]): The timeout setting for the request. |
| 285 | + addons (Optional[Dict]): Additional options for the request. |
| 286 | + headers (Optional[Dict]): Headers to include in the request. |
| 287 | + **kwargs: Additional keyword arguments. |
| 288 | +
|
| 289 | + Returns: |
| 290 | + ModelsResponse: A response object containing the model details. |
| 291 | + """ |
| 292 | + self._logger.debug("ManageClient.get_project_models ENTER") |
| 293 | + |
| 294 | + if options is None: |
| 295 | + options = ModelOptions() |
| 296 | + |
| 297 | + url = f"{self._config.url}/{self._endpoint}/{project_id}/models" |
| 298 | + self._logger.info("url: %s", url) |
| 299 | + self._logger.info("project_id: %s", project_id) |
| 300 | + if isinstance(options, ModelOptions): |
| 301 | + self._logger.info("ModelOptions switching class -> dict") |
| 302 | + options = options.to_dict() |
| 303 | + self._logger.info("options: %s", options) |
| 304 | + self._logger.info("addons: %s", addons) |
| 305 | + self._logger.info("headers: %s", headers) |
| 306 | + result = await self.get( |
| 307 | + url, json=options, timeout=timeout, addons=addons, headers=headers, **kwargs |
| 308 | + ) |
| 309 | + self._logger.info("json: %s", result) |
| 310 | + res = ModelsResponse.from_json(result) |
| 311 | + self._logger.verbose("result: %s", res) |
| 312 | + self._logger.notice("get_project_models succeeded") |
| 313 | + self._logger.debug("ManageClient.get_project_models LEAVE") |
| 314 | + return res |
| 315 | + |
| 316 | + async def get_project_model( |
| 317 | + self, |
| 318 | + project_id: str, |
| 319 | + model_id: str, |
| 320 | + timeout: Optional[httpx.Timeout] = None, |
| 321 | + addons: Optional[Dict] = None, |
| 322 | + headers: Optional[Dict] = None, |
| 323 | + **kwargs, |
| 324 | + ) -> ModelResponse: |
| 325 | + """ |
| 326 | + Gets a single model for a specific project. |
| 327 | +
|
| 328 | + Reference: |
| 329 | + https://developers.deepgram.com/reference/get-project |
| 330 | + https://developers.deepgram.com/reference/get-model |
| 331 | +
|
| 332 | + Args: |
| 333 | + project_id (str): The ID of the project. |
| 334 | + model_id (str): The ID of the model. |
| 335 | + timeout (Optional[httpx.Timeout]): The timeout setting for the request. |
| 336 | + addons (Optional[Dict]): Additional options for the request. |
| 337 | + headers (Optional[Dict]): Headers to include in the request. |
| 338 | + **kwargs: Additional keyword arguments. |
| 339 | +
|
| 340 | + Returns: |
| 341 | + ModelResponse: A response object containing the model details. |
| 342 | + """ |
| 343 | + self._logger.debug("ManageClient.get_project_model ENTER") |
| 344 | + url = f"{self._config.url}/{self._endpoint}/{project_id}/models/{model_id}" |
| 345 | + self._logger.info("url: %s", url) |
| 346 | + self._logger.info("project_id: %s", project_id) |
| 347 | + self._logger.info("model_id: %s", model_id) |
| 348 | + self._logger.info("addons: %s", addons) |
| 349 | + self._logger.info("headers: %s", headers) |
| 350 | + result = await self.get( |
| 351 | + url, timeout=timeout, addons=addons, headers=headers, **kwargs |
| 352 | + ) |
| 353 | + self._logger.info("json: %s", result) |
| 354 | + res = ModelResponse.from_json(result) |
| 355 | + self._logger.verbose("result: %s", res) |
| 356 | + self._logger.notice("get_project_model succeeded") |
| 357 | + self._logger.debug("ManageClient.get_project_model LEAVE") |
| 358 | + return res |
| 359 | + |
| 360 | + # models |
| 361 | + async def list_models( |
| 362 | + self, |
| 363 | + options: Optional[Union[Dict, ModelOptions]] = None, |
| 364 | + timeout: Optional[httpx.Timeout] = None, |
| 365 | + addons: Optional[Dict] = None, |
| 366 | + headers: Optional[Dict] = None, |
| 367 | + **kwargs, |
| 368 | + ) -> ModelsResponse: |
| 369 | + """ |
| 370 | + Please see get_models for more information. |
| 371 | + """ |
| 372 | + return await self.get_models( |
| 373 | + options=options, timeout=timeout, addons=addons, headers=headers, **kwargs |
| 374 | + ) |
| 375 | + |
| 376 | + async def get_models( |
| 377 | + self, |
| 378 | + options: Optional[Union[Dict, ModelOptions]] = None, |
| 379 | + timeout: Optional[httpx.Timeout] = None, |
| 380 | + addons: Optional[Dict] = None, |
| 381 | + headers: Optional[Dict] = None, |
| 382 | + **kwargs, |
| 383 | + ) -> ModelsResponse: |
| 384 | + """ |
| 385 | + Gets all models available. |
| 386 | +
|
| 387 | + Reference: |
| 388 | + https://developers.deepgram.com/reference/get-model |
| 389 | +
|
| 390 | + Args: |
| 391 | + timeout (Optional[httpx.Timeout]): The timeout setting for the request. |
| 392 | + addons (Optional[Dict]): Additional options for the request. |
| 393 | + headers (Optional[Dict]): Headers to include in the request. |
| 394 | + **kwargs: Additional keyword arguments. |
| 395 | +
|
| 396 | + Returns: |
| 397 | + ModelsResponse: A response object containing the model details. |
| 398 | + """ |
| 399 | + self._logger.debug("ManageClient.get_models ENTER") |
| 400 | + |
| 401 | + if options is None: |
| 402 | + options = ModelOptions() |
| 403 | + |
| 404 | + url = f"{self._config.url}/v1/models" |
| 405 | + self._logger.info("url: %s", url) |
| 406 | + if isinstance(options, ModelOptions): |
| 407 | + self._logger.info("ModelOptions switching class -> dict") |
| 408 | + options = options.to_dict() |
| 409 | + self._logger.info("options: %s", options) |
| 410 | + self._logger.info("addons: %s", addons) |
| 411 | + self._logger.info("headers: %s", headers) |
| 412 | + result = await self.get( |
| 413 | + url, json=options, timeout=timeout, addons=addons, headers=headers, **kwargs |
| 414 | + ) |
| 415 | + self._logger.info("result: %s", result) |
| 416 | + res = ModelsResponse.from_json(result) |
| 417 | + self._logger.verbose("result: %s", res) |
| 418 | + self._logger.notice("get_models succeeded") |
| 419 | + self._logger.debug("ManageClient.get_models LEAVE") |
| 420 | + return res |
| 421 | + |
| 422 | + async def get_model( |
| 423 | + self, |
| 424 | + model_id: str, |
| 425 | + timeout: Optional[httpx.Timeout] = None, |
| 426 | + addons: Optional[Dict] = None, |
| 427 | + headers: Optional[Dict] = None, |
| 428 | + **kwargs, |
| 429 | + ) -> ModelResponse: |
| 430 | + """ |
| 431 | + Gets information for a specific model. |
| 432 | +
|
| 433 | + Reference: |
| 434 | + https://developers.deepgram.com/reference/get-model |
| 435 | +
|
| 436 | + Args: |
| 437 | + model_id (str): The ID of the model. |
| 438 | + timeout (Optional[httpx.Timeout]): The timeout setting for the request. |
| 439 | + addons (Optional[Dict]): Additional options for the request. |
| 440 | + headers (Optional[Dict]): Headers to include in the request. |
| 441 | + **kwargs: Additional keyword arguments. |
| 442 | +
|
| 443 | + Returns: |
| 444 | + ModelResponse: A response object containing the model details. |
| 445 | + """ |
| 446 | + self._logger.debug("ManageClient.get_model ENTER") |
| 447 | + url = f"{self._config.url}/v1/models/{model_id}" |
| 448 | + self._logger.info("url: %s", url) |
| 449 | + self._logger.info("model_id: %s", model_id) |
| 450 | + self._logger.info("addons: %s", addons) |
| 451 | + self._logger.info("headers: %s", headers) |
| 452 | + result = await self.get( |
| 453 | + url, timeout=timeout, addons=addons, headers=headers, **kwargs |
| 454 | + ) |
| 455 | + self._logger.info("result: %s", result) |
| 456 | + res = ModelResponse.from_json(result) |
| 457 | + self._logger.verbose("result: %s", res) |
| 458 | + self._logger.notice("get_model succeeded") |
| 459 | + self._logger.debug("ManageClient.get_model LEAVE") |
| 460 | + return res |
| 461 | + |
242 | 462 | # keys |
243 | 463 | async def list_keys( |
244 | 464 | self, |
|
0 commit comments