oracle-ads 2.12.11__py3-none-any.whl → 2.13.1rc0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. ads/aqua/app.py +23 -10
  2. ads/aqua/common/enums.py +19 -14
  3. ads/aqua/common/errors.py +3 -4
  4. ads/aqua/common/utils.py +2 -2
  5. ads/aqua/constants.py +1 -0
  6. ads/aqua/evaluation/constants.py +7 -7
  7. ads/aqua/evaluation/errors.py +3 -4
  8. ads/aqua/extension/model_handler.py +23 -0
  9. ads/aqua/extension/models/ws_models.py +5 -6
  10. ads/aqua/finetuning/constants.py +3 -3
  11. ads/aqua/model/constants.py +7 -7
  12. ads/aqua/model/enums.py +4 -5
  13. ads/aqua/model/model.py +22 -0
  14. ads/aqua/modeldeployment/entities.py +3 -1
  15. ads/common/auth.py +33 -20
  16. ads/common/extended_enum.py +52 -44
  17. ads/llm/__init__.py +11 -8
  18. ads/llm/langchain/plugins/embeddings/__init__.py +4 -0
  19. ads/llm/langchain/plugins/embeddings/oci_data_science_model_deployment_endpoint.py +184 -0
  20. ads/model/artifact_downloader.py +3 -4
  21. ads/model/datascience_model.py +84 -64
  22. ads/model/generic_model.py +3 -3
  23. ads/model/model_metadata.py +17 -11
  24. ads/model/service/oci_datascience_model.py +12 -14
  25. ads/opctl/anomaly_detection.py +11 -0
  26. ads/opctl/backend/marketplace/helm_helper.py +13 -14
  27. ads/opctl/cli.py +4 -5
  28. ads/opctl/cmds.py +28 -32
  29. ads/opctl/config/merger.py +8 -11
  30. ads/opctl/config/resolver.py +25 -30
  31. ads/opctl/forecast.py +11 -0
  32. ads/opctl/operator/cli.py +9 -9
  33. ads/opctl/operator/common/backend_factory.py +56 -60
  34. ads/opctl/operator/common/const.py +5 -5
  35. ads/opctl/operator/lowcode/anomaly/const.py +8 -9
  36. ads/opctl/operator/lowcode/feature_store_marketplace/operator_utils.py +43 -48
  37. ads/opctl/operator/lowcode/forecast/__main__.py +5 -5
  38. ads/opctl/operator/lowcode/forecast/const.py +6 -6
  39. ads/opctl/operator/lowcode/forecast/model/arima.py +6 -3
  40. ads/opctl/operator/lowcode/forecast/model/automlx.py +53 -31
  41. ads/opctl/operator/lowcode/forecast/model/base_model.py +57 -30
  42. ads/opctl/operator/lowcode/forecast/model/forecast_datasets.py +60 -2
  43. ads/opctl/operator/lowcode/forecast/model/neuralprophet.py +5 -2
  44. ads/opctl/operator/lowcode/forecast/model/prophet.py +28 -15
  45. ads/opctl/operator/lowcode/forecast/whatifserve/score.py +19 -11
  46. ads/opctl/operator/lowcode/pii/constant.py +6 -7
  47. ads/opctl/operator/lowcode/recommender/constant.py +12 -7
  48. ads/opctl/operator/runtime/marketplace_runtime.py +4 -10
  49. ads/opctl/operator/runtime/runtime.py +4 -6
  50. ads/pipeline/ads_pipeline_run.py +13 -25
  51. ads/pipeline/visualizer/graph_renderer.py +3 -4
  52. {oracle_ads-2.12.11.dist-info → oracle_ads-2.13.1rc0.dist-info}/METADATA +6 -6
  53. {oracle_ads-2.12.11.dist-info → oracle_ads-2.13.1rc0.dist-info}/RECORD +56 -52
  54. {oracle_ads-2.12.11.dist-info → oracle_ads-2.13.1rc0.dist-info}/LICENSE.txt +0 -0
  55. {oracle_ads-2.12.11.dist-info → oracle_ads-2.13.1rc0.dist-info}/WHEEL +0 -0
  56. {oracle_ads-2.12.11.dist-info → oracle_ads-2.13.1rc0.dist-info}/entry_points.txt +0 -0
ads/aqua/app.py CHANGED
@@ -6,14 +6,14 @@ import json
6
6
  import os
7
7
  import traceback
8
8
  from dataclasses import fields
9
- from typing import Dict, Union
9
+ from typing import Dict, Optional, Union
10
10
 
11
11
  import oci
12
12
  from oci.data_science.models import UpdateModelDetails, UpdateModelProvenanceDetails
13
13
 
14
14
  from ads import set_auth
15
15
  from ads.aqua import logger
16
- from ads.aqua.common.enums import Tags
16
+ from ads.aqua.common.enums import ConfigFolder, Tags
17
17
  from ads.aqua.common.errors import AquaRuntimeError, AquaValueError
18
18
  from ads.aqua.common.utils import (
19
19
  _is_valid_mvs,
@@ -268,7 +268,12 @@ class AquaApp:
268
268
  logger.info(f"Artifact not found in model {model_id}.")
269
269
  return False
270
270
 
271
- def get_config(self, model_id: str, config_file_name: str) -> Dict:
271
+ def get_config(
272
+ self,
273
+ model_id: str,
274
+ config_file_name: str,
275
+ config_folder: Optional[str] = ConfigFolder.CONFIG,
276
+ ) -> Dict:
272
277
  """Gets the config for the given Aqua model.
273
278
 
274
279
  Parameters
@@ -277,12 +282,17 @@ class AquaApp:
277
282
  The OCID of the Aqua model.
278
283
  config_file_name: str
279
284
  name of the config file
285
+ config_folder: (str, optional):
286
+ subfolder path where config_file_name needs to be searched
287
+ Defaults to `ConfigFolder.CONFIG`.
288
+ When searching inside model artifact directory , the value is ConfigFolder.ARTIFACT`
280
289
 
281
290
  Returns
282
291
  -------
283
292
  Dict:
284
293
  A dict of allowed configs.
285
294
  """
295
+ config_folder = config_folder or ConfigFolder.CONFIG
286
296
  oci_model = self.ds_client.get_model(model_id).data
287
297
  oci_aqua = (
288
298
  (
@@ -304,23 +314,26 @@ class AquaApp:
304
314
  f"Base model found for the model: {oci_model.id}. "
305
315
  f"Loading {config_file_name} for base model {base_model_ocid}."
306
316
  )
307
- base_model = self.ds_client.get_model(base_model_ocid).data
308
- artifact_path = get_artifact_path(base_model.custom_metadata_list)
317
+ if config_folder == ConfigFolder.ARTIFACT:
318
+ artifact_path = get_artifact_path(oci_model.custom_metadata_list)
319
+ else:
320
+ base_model = self.ds_client.get_model(base_model_ocid).data
321
+ artifact_path = get_artifact_path(base_model.custom_metadata_list)
309
322
  else:
310
323
  logger.info(f"Loading {config_file_name} for model {oci_model.id}...")
311
324
  artifact_path = get_artifact_path(oci_model.custom_metadata_list)
312
-
313
325
  if not artifact_path:
314
326
  logger.debug(
315
327
  f"Failed to get artifact path from custom metadata for the model: {model_id}"
316
328
  )
317
329
  return config
318
330
 
319
- config_path = f"{os.path.dirname(artifact_path)}/config/"
331
+ config_path = os.path.join(os.path.dirname(artifact_path), config_folder)
320
332
  if not is_path_exists(config_path):
321
- config_path = f"{artifact_path.rstrip('/')}/config/"
322
-
323
- config_file_path = f"{config_path}{config_file_name}"
333
+ config_path = os.path.join(artifact_path.rstrip("/"), config_folder)
334
+ if not is_path_exists(config_path):
335
+ config_path = f"{artifact_path.rstrip('/')}/"
336
+ config_file_path = os.path.join(config_path, config_file_name)
324
337
  if is_path_exists(config_file_path):
325
338
  try:
326
339
  config = load_config(
ads/aqua/common/enums.py CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python
2
- # Copyright (c) 2024 Oracle and/or its affiliates.
2
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
3
3
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4
4
 
5
5
  """
@@ -8,15 +8,15 @@ aqua.common.enums
8
8
  This module contains the set of enums used in AQUA.
9
9
  """
10
10
 
11
- from ads.common.extended_enum import ExtendedEnumMeta
11
+ from ads.common.extended_enum import ExtendedEnum
12
12
 
13
13
 
14
- class DataScienceResource(str, metaclass=ExtendedEnumMeta):
14
+ class DataScienceResource(ExtendedEnum):
15
15
  MODEL_DEPLOYMENT = "datasciencemodeldeployment"
16
16
  MODEL = "datasciencemodel"
17
17
 
18
18
 
19
- class Resource(str, metaclass=ExtendedEnumMeta):
19
+ class Resource(ExtendedEnum):
20
20
  JOB = "jobs"
21
21
  JOBRUN = "jobruns"
22
22
  MODEL = "models"
@@ -24,7 +24,7 @@ class Resource(str, metaclass=ExtendedEnumMeta):
24
24
  MODEL_VERSION_SET = "model-version-sets"
25
25
 
26
26
 
27
- class Tags(str, metaclass=ExtendedEnumMeta):
27
+ class Tags(ExtendedEnum):
28
28
  TASK = "task"
29
29
  LICENSE = "license"
30
30
  ORGANIZATION = "organization"
@@ -42,41 +42,41 @@ class Tags(str, metaclass=ExtendedEnumMeta):
42
42
  MODEL_ARTIFACT_FILE = "model_file"
43
43
 
44
44
 
45
- class InferenceContainerType(str, metaclass=ExtendedEnumMeta):
45
+ class InferenceContainerType(ExtendedEnum):
46
46
  CONTAINER_TYPE_VLLM = "vllm"
47
47
  CONTAINER_TYPE_TGI = "tgi"
48
48
  CONTAINER_TYPE_LLAMA_CPP = "llama-cpp"
49
49
 
50
50
 
51
- class InferenceContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
51
+ class InferenceContainerTypeFamily(ExtendedEnum):
52
52
  AQUA_VLLM_CONTAINER_FAMILY = "odsc-vllm-serving"
53
53
  AQUA_TGI_CONTAINER_FAMILY = "odsc-tgi-serving"
54
54
  AQUA_LLAMA_CPP_CONTAINER_FAMILY = "odsc-llama-cpp-serving"
55
55
 
56
56
 
57
- class CustomInferenceContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
57
+ class CustomInferenceContainerTypeFamily(ExtendedEnum):
58
58
  AQUA_TEI_CONTAINER_FAMILY = "odsc-tei-serving"
59
59
 
60
60
 
61
- class InferenceContainerParamType(str, metaclass=ExtendedEnumMeta):
61
+ class InferenceContainerParamType(ExtendedEnum):
62
62
  PARAM_TYPE_VLLM = "VLLM_PARAMS"
63
63
  PARAM_TYPE_TGI = "TGI_PARAMS"
64
64
  PARAM_TYPE_LLAMA_CPP = "LLAMA_CPP_PARAMS"
65
65
 
66
66
 
67
- class EvaluationContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
67
+ class EvaluationContainerTypeFamily(ExtendedEnum):
68
68
  AQUA_EVALUATION_CONTAINER_FAMILY = "odsc-llm-evaluate"
69
69
 
70
70
 
71
- class FineTuningContainerTypeFamily(str, metaclass=ExtendedEnumMeta):
71
+ class FineTuningContainerTypeFamily(ExtendedEnum):
72
72
  AQUA_FINETUNING_CONTAINER_FAMILY = "odsc-llm-fine-tuning"
73
73
 
74
74
 
75
- class HuggingFaceTags(str, metaclass=ExtendedEnumMeta):
75
+ class HuggingFaceTags(ExtendedEnum):
76
76
  TEXT_GENERATION_INFERENCE = "text-generation-inference"
77
77
 
78
78
 
79
- class RqsAdditionalDetails(str, metaclass=ExtendedEnumMeta):
79
+ class RqsAdditionalDetails(ExtendedEnum):
80
80
  METADATA = "metadata"
81
81
  CREATED_BY = "createdBy"
82
82
  DESCRIPTION = "description"
@@ -86,9 +86,14 @@ class RqsAdditionalDetails(str, metaclass=ExtendedEnumMeta):
86
86
  VERSION_LABEL = "versionLabel"
87
87
 
88
88
 
89
- class TextEmbeddingInferenceContainerParams(str, metaclass=ExtendedEnumMeta):
89
+ class TextEmbeddingInferenceContainerParams(ExtendedEnum):
90
90
  """Contains a subset of params that are required for enabling model deployment in OCI Data Science. More options
91
91
  are available at https://huggingface.co/docs/text-embeddings-inference/en/cli_arguments"""
92
92
 
93
93
  MODEL_ID = "model-id"
94
94
  PORT = "port"
95
+
96
+
97
+ class ConfigFolder(ExtendedEnum):
98
+ CONFIG = "config"
99
+ ARTIFACT = "artifact"
ads/aqua/common/errors.py CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # Copyright (c) 2024 Oracle and/or its affiliates.
2
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
4
3
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
4
 
6
5
  """
@@ -10,10 +9,10 @@ aqua.exception
10
9
  This module contains the set of Aqua exceptions.
11
10
  """
12
11
 
13
- from ads.common.extended_enum import ExtendedEnumMeta
12
+ from ads.common.extended_enum import ExtendedEnum
14
13
 
15
14
 
16
- class ExitCode(str, metaclass=ExtendedEnumMeta):
15
+ class ExitCode(ExtendedEnum):
17
16
  SUCCESS = 0
18
17
  COMMON_ERROR = 1
19
18
  INVALID_CONFIG = 10
ads/aqua/common/utils.py CHANGED
@@ -65,7 +65,7 @@ from ads.aqua.constants import (
65
65
  from ads.aqua.data import AquaResourceIdentifier
66
66
  from ads.common.auth import AuthState, default_signer
67
67
  from ads.common.decorator.threaded import threaded
68
- from ads.common.extended_enum import ExtendedEnumMeta
68
+ from ads.common.extended_enum import ExtendedEnum
69
69
  from ads.common.object_storage_details import ObjectStorageDetails
70
70
  from ads.common.oci_resource import SEARCH_TYPE, OCIResource
71
71
  from ads.common.utils import copy_file, get_console_link, upload_to_os
@@ -80,7 +80,7 @@ from ads.model import DataScienceModel, ModelVersionSet
80
80
  logger = logging.getLogger("ads.aqua")
81
81
 
82
82
 
83
- class LifecycleStatus(str, metaclass=ExtendedEnumMeta):
83
+ class LifecycleStatus(ExtendedEnum):
84
84
  UNKNOWN = ""
85
85
 
86
86
  @property
ads/aqua/constants.py CHANGED
@@ -10,6 +10,7 @@ UNKNOWN_DICT = {}
10
10
  README = "README.md"
11
11
  LICENSE_TXT = "config/LICENSE.txt"
12
12
  DEPLOYMENT_CONFIG = "deployment_config.json"
13
+ AQUA_MODEL_TOKENIZER_CONFIG = "tokenizer_config.json"
13
14
  COMPARTMENT_MAPPING_KEY = "service-model-compartment"
14
15
  CONTAINER_INDEX = "container_index.json"
15
16
  EVALUATION_REPORT_JSON = "report.json"
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # Copyright (c) 2024 Oracle and/or its affiliates.
2
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
4
3
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
4
 
6
5
  """
@@ -9,9 +8,10 @@ aqua.evaluation.const
9
8
 
10
9
  This module contains constants/enums used in Aqua Evaluation.
11
10
  """
11
+
12
12
  from oci.data_science.models import JobRun
13
13
 
14
- from ads.common.extended_enum import ExtendedEnumMeta
14
+ from ads.common.extended_enum import ExtendedEnum
15
15
 
16
16
  EVAL_TERMINATION_STATE = [
17
17
  JobRun.LIFECYCLE_STATE_SUCCEEDED,
@@ -19,7 +19,7 @@ EVAL_TERMINATION_STATE = [
19
19
  ]
20
20
 
21
21
 
22
- class EvaluationCustomMetadata(str, metaclass=ExtendedEnumMeta):
22
+ class EvaluationCustomMetadata(ExtendedEnum):
23
23
  EVALUATION_SOURCE = "evaluation_source"
24
24
  EVALUATION_JOB_ID = "evaluation_job_id"
25
25
  EVALUATION_JOB_RUN_ID = "evaluation_job_run_id"
@@ -28,11 +28,11 @@ class EvaluationCustomMetadata(str, metaclass=ExtendedEnumMeta):
28
28
  EVALUATION_ERROR = "aqua_evaluate_error"
29
29
 
30
30
 
31
- class EvaluationConfig(str, metaclass=ExtendedEnumMeta):
31
+ class EvaluationConfig(ExtendedEnum):
32
32
  PARAMS = "model_params"
33
33
 
34
34
 
35
- class EvaluationReportJson(str, metaclass=ExtendedEnumMeta):
35
+ class EvaluationReportJson(ExtendedEnum):
36
36
  """Contains evaluation report.json fields name."""
37
37
 
38
38
  METRIC_SUMMARY_RESULT = "metric_summary_result"
@@ -43,7 +43,7 @@ class EvaluationReportJson(str, metaclass=ExtendedEnumMeta):
43
43
  DATASET = "dataset"
44
44
 
45
45
 
46
- class EvaluationMetricResult(str, metaclass=ExtendedEnumMeta):
46
+ class EvaluationMetricResult(ExtendedEnum):
47
47
  """Contains metric result's fields name in report.json."""
48
48
 
49
49
  SHORT_NAME = "key"
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # Copyright (c) 2024 Oracle and/or its affiliates.
2
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
4
3
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
4
  """
6
5
  aqua.evaluation.errors
@@ -9,10 +8,10 @@ aqua.evaluation.errors
9
8
  This module contains errors in Aqua Evaluation.
10
9
  """
11
10
 
12
- from ads.common.extended_enum import ExtendedEnumMeta
11
+ from ads.common.extended_enum import ExtendedEnum
13
12
 
14
13
 
15
- class EvaluationJobExitCode(str, metaclass=ExtendedEnumMeta):
14
+ class EvaluationJobExitCode(ExtendedEnum):
16
15
  SUCCESS = 0
17
16
  COMMON_ERROR = 1
18
17
 
@@ -14,6 +14,7 @@ from ads.aqua.common.enums import (
14
14
  from ads.aqua.common.errors import AquaRuntimeError, AquaValueError
15
15
  from ads.aqua.common.utils import (
16
16
  get_hf_model_info,
17
+ is_valid_ocid,
17
18
  list_hf_models,
18
19
  )
19
20
  from ads.aqua.extension.base_handler import AquaAPIhandler
@@ -316,8 +317,30 @@ class AquaHuggingFaceHandler(AquaAPIhandler):
316
317
  )
317
318
 
318
319
 
320
+ class AquaModelTokenizerConfigHandler(AquaAPIhandler):
321
+ def get(self, model_id):
322
+ """
323
+ Handles requests for retrieving the Hugging Face tokenizer configuration of a specified model.
324
+ Expected request format: GET /aqua/models/<model-ocid>/tokenizer
325
+
326
+ """
327
+
328
+ path_list = urlparse(self.request.path).path.strip("/").split("/")
329
+ # Path should be /aqua/models/ocid1.iad.ahdxxx/tokenizer
330
+ # path_list=['aqua','models','<model-ocid>','tokenizer']
331
+ if (
332
+ len(path_list) == 4
333
+ and is_valid_ocid(path_list[2])
334
+ and path_list[3] == "tokenizer"
335
+ ):
336
+ return self.finish(AquaModelApp().get_hf_tokenizer_config(model_id))
337
+
338
+ raise HTTPError(400, f"The request {self.request.path} is invalid.")
339
+
340
+
319
341
  __handlers__ = [
320
342
  ("model/?([^/]*)", AquaModelHandler),
321
343
  ("model/?([^/]*)/license", AquaModelLicenseHandler),
344
+ ("model/?([^/]*)/tokenizer", AquaModelTokenizerConfigHandler),
322
345
  ("model/hf/search/?([^/]*)", AquaHuggingFaceHandler),
323
346
  ]
@@ -1,20 +1,19 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*--
3
2
 
4
- # Copyright (c) 2024 Oracle and/or its affiliates.
3
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
5
4
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6
5
 
7
6
  from dataclasses import dataclass
8
7
  from typing import List, Optional
9
8
 
10
- from ads.aqua.evaluation.entities import AquaEvaluationSummary, AquaEvaluationDetail
11
- from ads.aqua.model.entities import AquaModelSummary, AquaModel
9
+ from ads.aqua.evaluation.entities import AquaEvaluationDetail, AquaEvaluationSummary
10
+ from ads.aqua.model.entities import AquaModel, AquaModelSummary
12
11
  from ads.aqua.modeldeployment.entities import AquaDeployment, AquaDeploymentDetail
13
- from ads.common.extended_enum import ExtendedEnumMeta
12
+ from ads.common.extended_enum import ExtendedEnum
14
13
  from ads.common.serializer import DataClassSerializable
15
14
 
16
15
 
17
- class RequestResponseType(str, metaclass=ExtendedEnumMeta):
16
+ class RequestResponseType(ExtendedEnum):
18
17
  ListEvaluations = "ListEvaluations"
19
18
  EvaluationDetails = "EvaluationDetails"
20
19
  ListDeployments = "ListDeployments"
@@ -2,10 +2,10 @@
2
2
  # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
3
3
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4
4
 
5
- from ads.common.extended_enum import ExtendedEnumMeta
5
+ from ads.common.extended_enum import ExtendedEnum
6
6
 
7
7
 
8
- class FineTuneCustomMetadata(str, metaclass=ExtendedEnumMeta):
8
+ class FineTuneCustomMetadata(ExtendedEnum):
9
9
  FINE_TUNE_SOURCE = "fine_tune_source"
10
10
  FINE_TUNE_SOURCE_NAME = "fine_tune_source_name"
11
11
  FINE_TUNE_OUTPUT_PATH = "fine_tune_output_path"
@@ -16,7 +16,7 @@ class FineTuneCustomMetadata(str, metaclass=ExtendedEnumMeta):
16
16
  SERVICE_MODEL_FINE_TUNE_CONTAINER = "finetune-container"
17
17
 
18
18
 
19
- class FineTuningRestrictedParams(str, metaclass=ExtendedEnumMeta):
19
+ class FineTuningRestrictedParams(ExtendedEnum):
20
20
  OPTIMIZER = "optimizer"
21
21
 
22
22
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python
2
- # Copyright (c) 2024 Oracle and/or its affiliates.
2
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
3
3
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
4
4
 
5
5
  """
@@ -9,10 +9,10 @@ aqua.model.constants
9
9
  This module contains constants/enums used in Aqua Model.
10
10
  """
11
11
 
12
- from ads.common.extended_enum import ExtendedEnumMeta
12
+ from ads.common.extended_enum import ExtendedEnum
13
13
 
14
14
 
15
- class ModelCustomMetadataFields(str, metaclass=ExtendedEnumMeta):
15
+ class ModelCustomMetadataFields(ExtendedEnum):
16
16
  ARTIFACT_LOCATION = "artifact_location"
17
17
  DEPLOYMENT_CONTAINER = "deployment-container"
18
18
  EVALUATION_CONTAINER = "evaluation-container"
@@ -20,24 +20,24 @@ class ModelCustomMetadataFields(str, metaclass=ExtendedEnumMeta):
20
20
  DEPLOYMENT_CONTAINER_URI = "deployment-container-uri"
21
21
 
22
22
 
23
- class ModelTask(str, metaclass=ExtendedEnumMeta):
23
+ class ModelTask(ExtendedEnum):
24
24
  TEXT_GENERATION = "text-generation"
25
25
  IMAGE_TEXT_TO_TEXT = "image-text-to-text"
26
26
  IMAGE_TO_TEXT = "image-to-text"
27
27
 
28
28
 
29
- class FineTuningMetricCategories(str, metaclass=ExtendedEnumMeta):
29
+ class FineTuningMetricCategories(ExtendedEnum):
30
30
  VALIDATION = "validation"
31
31
  TRAINING = "training"
32
32
 
33
33
 
34
- class ModelType(str, metaclass=ExtendedEnumMeta):
34
+ class ModelType(ExtendedEnum):
35
35
  FT = "FT" # Fine Tuned Model
36
36
  BASE = "BASE" # Base model
37
37
 
38
38
 
39
39
  # TODO: merge metadata key used in create FT
40
- class FineTuningCustomMetadata(str, metaclass=ExtendedEnumMeta):
40
+ class FineTuningCustomMetadata(ExtendedEnum):
41
41
  FT_SOURCE = "fine_tune_source"
42
42
  FT_SOURCE_NAME = "fine_tune_source_name"
43
43
  FT_OUTPUT_PATH = "fine_tune_output_path"
ads/aqua/model/enums.py CHANGED
@@ -1,18 +1,17 @@
1
1
  #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # Copyright (c) 2024 Oracle and/or its affiliates.
2
+ # Copyright (c) 2024, 2025 Oracle and/or its affiliates.
4
3
  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
5
- from ads.common.extended_enum import ExtendedEnumMeta
4
+ from ads.common.extended_enum import ExtendedEnum
6
5
 
7
6
 
8
- class FineTuningDefinedMetadata(str, metaclass=ExtendedEnumMeta):
7
+ class FineTuningDefinedMetadata(ExtendedEnum):
9
8
  """Represents the defined metadata keys used in Fine Tuning."""
10
9
 
11
10
  VAL_SET_SIZE = "val_set_size"
12
11
  TRAINING_DATA = "training_data"
13
12
 
14
13
 
15
- class FineTuningCustomMetadata(str, metaclass=ExtendedEnumMeta):
14
+ class FineTuningCustomMetadata(ExtendedEnum):
16
15
  """Represents the custom metadata keys used in Fine Tuning."""
17
16
 
18
17
  FT_SOURCE = "fine_tune_source"
ads/aqua/model/model.py CHANGED
@@ -15,6 +15,7 @@ from oci.data_science.models import JobRun, Metadata, Model, UpdateModelDetails
15
15
  from ads.aqua import ODSC_MODEL_COMPARTMENT_OCID, logger
16
16
  from ads.aqua.app import AquaApp
17
17
  from ads.aqua.common.enums import (
18
+ ConfigFolder,
18
19
  CustomInferenceContainerTypeFamily,
19
20
  FineTuningContainerTypeFamily,
20
21
  InferenceContainerTypeFamily,
@@ -44,6 +45,7 @@ from ads.aqua.constants import (
44
45
  AQUA_MODEL_ARTIFACT_CONFIG_MODEL_NAME,
45
46
  AQUA_MODEL_ARTIFACT_CONFIG_MODEL_TYPE,
46
47
  AQUA_MODEL_ARTIFACT_FILE,
48
+ AQUA_MODEL_TOKENIZER_CONFIG,
47
49
  AQUA_MODEL_TYPE_CUSTOM,
48
50
  HF_METADATA_FOLDER,
49
51
  LICENSE_TXT,
@@ -568,6 +570,26 @@ class AquaModelApp(AquaApp):
568
570
  training_final,
569
571
  ]
570
572
 
573
+ def get_hf_tokenizer_config(self, model_id):
574
+ """Gets the default chat template for the given Aqua model.
575
+
576
+ Parameters
577
+ ----------
578
+ model_id: str
579
+ The OCID of the Aqua model.
580
+
581
+ Returns
582
+ -------
583
+ str:
584
+ Chat template string.
585
+ """
586
+ config = self.get_config(
587
+ model_id, AQUA_MODEL_TOKENIZER_CONFIG, ConfigFolder.ARTIFACT
588
+ )
589
+ if not config:
590
+ logger.debug(f"Tokenizer config for model: {model_id} is not available.")
591
+ return config
592
+
571
593
  @staticmethod
572
594
  def to_aqua_model(
573
595
  model: Union[
@@ -41,6 +41,7 @@ class AquaDeployment(DataClassSerializable):
41
41
  id: str = None
42
42
  display_name: str = None
43
43
  aqua_service_model: bool = None
44
+ model_id: str = None
44
45
  aqua_model_name: str = None
45
46
  state: str = None
46
47
  description: str = None
@@ -97,7 +98,7 @@ class AquaDeployment(DataClassSerializable):
97
98
  else None
98
99
  ),
99
100
  )
100
-
101
+ model_id = oci_model_deployment._model_deployment_configuration_details.model_configuration_details.model_id
101
102
  tags = {}
102
103
  tags.update(oci_model_deployment.freeform_tags or UNKNOWN_DICT)
103
104
  tags.update(oci_model_deployment.defined_tags or UNKNOWN_DICT)
@@ -110,6 +111,7 @@ class AquaDeployment(DataClassSerializable):
110
111
 
111
112
  return AquaDeployment(
112
113
  id=oci_model_deployment.id,
114
+ model_id=model_id,
113
115
  display_name=oci_model_deployment.display_name,
114
116
  aqua_service_model=aqua_service_model_tag is not None,
115
117
  aqua_model_name=aqua_model_name,