clarifai 11.8.1__tar.gz → 11.8.2__tar.gz

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 (153) hide show
  1. {clarifai-11.8.1/clarifai.egg-info → clarifai-11.8.2}/PKG-INFO +4 -3
  2. clarifai-11.8.2/clarifai/__init__.py +1 -0
  3. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/model.py +43 -14
  4. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/templates/model_templates.py +1 -1
  5. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/base.py +54 -16
  6. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/dataset.py +18 -6
  7. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/model.py +21 -12
  8. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/model_client.py +2 -0
  9. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/module.py +14 -13
  10. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/nodepool.py +3 -1
  11. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/pipeline.py +23 -23
  12. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/pipeline_step.py +20 -18
  13. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/search.py +35 -11
  14. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/user.py +180 -5
  15. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/workflow.py +18 -17
  16. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/model_builder.py +149 -17
  17. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/server.py +1 -0
  18. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/code_script.py +12 -1
  19. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/cli.py +62 -0
  20. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/constants.py +5 -3
  21. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/secrets.py +7 -2
  22. {clarifai-11.8.1 → clarifai-11.8.2/clarifai.egg-info}/PKG-INFO +4 -3
  23. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai.egg-info/requires.txt +3 -2
  24. {clarifai-11.8.1 → clarifai-11.8.2}/requirements.txt +3 -2
  25. clarifai-11.8.1/clarifai/__init__.py +0 -1
  26. {clarifai-11.8.1 → clarifai-11.8.2}/LICENSE +0 -0
  27. {clarifai-11.8.1 → clarifai-11.8.2}/MANIFEST.in +0 -0
  28. {clarifai-11.8.1 → clarifai-11.8.2}/README.md +0 -0
  29. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/README.md +0 -0
  30. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/__init__.py +0 -0
  31. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/__main__.py +0 -0
  32. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/base.py +0 -0
  33. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/compute_cluster.py +0 -0
  34. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/deployment.py +0 -0
  35. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/nodepool.py +0 -0
  36. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/pipeline.py +0 -0
  37. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/pipeline_step.py +0 -0
  38. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/templates/__init__.py +0 -0
  39. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/templates/pipeline_step_templates.py +0 -0
  40. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli/templates/pipeline_templates.py +0 -0
  41. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/cli.py +0 -0
  42. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/__init__.py +0 -0
  43. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/app.py +0 -0
  44. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/auth/__init__.py +0 -0
  45. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/auth/helper.py +0 -0
  46. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/auth/register.py +0 -0
  47. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/auth/stub.py +0 -0
  48. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/compute_cluster.py +0 -0
  49. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/deployment.py +0 -0
  50. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/input.py +0 -0
  51. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/lister.py +0 -0
  52. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/client/runner.py +0 -0
  53. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/constants/base.py +0 -0
  54. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/constants/dataset.py +0 -0
  55. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/constants/input.py +0 -0
  56. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/constants/model.py +0 -0
  57. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/constants/rag.py +0 -0
  58. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/constants/search.py +0 -0
  59. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/constants/workflow.py +0 -0
  60. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/__init__.py +0 -0
  61. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/export/__init__.py +0 -0
  62. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/export/inputs_annotations.py +0 -0
  63. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/__init__.py +0 -0
  64. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/base.py +0 -0
  65. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/features.py +0 -0
  66. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/image.py +0 -0
  67. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/loaders/README.md +0 -0
  68. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/loaders/__init__.py +0 -0
  69. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/loaders/coco_captions.py +0 -0
  70. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/loaders/coco_detection.py +0 -0
  71. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/loaders/imagenet_classification.py +0 -0
  72. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/loaders/xview_detection.py +0 -0
  73. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/multimodal.py +0 -0
  74. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/text.py +0 -0
  75. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/datasets/upload/utils.py +0 -0
  76. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/errors.py +0 -0
  77. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/models/__init__.py +0 -0
  78. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/models/api.py +0 -0
  79. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/modules/README.md +0 -0
  80. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/modules/__init__.py +0 -0
  81. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/modules/css.py +0 -0
  82. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/modules/pages.py +0 -0
  83. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/modules/style.css +0 -0
  84. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/rag/__init__.py +0 -0
  85. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/rag/rag.py +0 -0
  86. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/rag/utils.py +0 -0
  87. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/__init__.py +0 -0
  88. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/dockerfile_template/Dockerfile.template +0 -0
  89. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/__init__.py +0 -0
  90. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/dummy_openai_model.py +0 -0
  91. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/mcp_class.py +0 -0
  92. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/model_class.py +0 -0
  93. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/model_run_locally.py +0 -0
  94. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/model_runner.py +0 -0
  95. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/model_servicer.py +0 -0
  96. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/openai_class.py +0 -0
  97. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/visual_classifier_class.py +0 -0
  98. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/models/visual_detector_class.py +0 -0
  99. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/pipeline_steps/__init__.py +0 -0
  100. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/pipeline_steps/pipeline_step_builder.py +0 -0
  101. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/pipelines/__init__.py +0 -0
  102. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/pipelines/pipeline_builder.py +0 -0
  103. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/__init__.py +0 -0
  104. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/const.py +0 -0
  105. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/data_types/__init__.py +0 -0
  106. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/data_types/data_types.py +0 -0
  107. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/data_utils.py +0 -0
  108. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/loader.py +0 -0
  109. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/method_signatures.py +0 -0
  110. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/model_utils.py +0 -0
  111. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/openai_convertor.py +0 -0
  112. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/pipeline_validation.py +0 -0
  113. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/serializers.py +0 -0
  114. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/runners/utils/url_fetcher.py +0 -0
  115. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/schema/search.py +0 -0
  116. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/urls/helper.py +0 -0
  117. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/__init__.py +0 -0
  118. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/config.py +0 -0
  119. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/evaluation/__init__.py +0 -0
  120. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/evaluation/helpers.py +0 -0
  121. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/evaluation/main.py +0 -0
  122. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/evaluation/testset_annotation_parser.py +0 -0
  123. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/logging.py +0 -0
  124. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/misc.py +0 -0
  125. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/model_train.py +0 -0
  126. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/utils/protobuf.py +0 -0
  127. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/versions.py +0 -0
  128. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/workflows/__init__.py +0 -0
  129. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/workflows/export.py +0 -0
  130. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/workflows/utils.py +0 -0
  131. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai/workflows/validate.py +0 -0
  132. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai.egg-info/SOURCES.txt +0 -0
  133. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai.egg-info/dependency_links.txt +0 -0
  134. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai.egg-info/entry_points.txt +0 -0
  135. {clarifai-11.8.1 → clarifai-11.8.2}/clarifai.egg-info/top_level.txt +0 -0
  136. {clarifai-11.8.1 → clarifai-11.8.2}/pyproject.toml +0 -0
  137. {clarifai-11.8.1 → clarifai-11.8.2}/setup.cfg +0 -0
  138. {clarifai-11.8.1 → clarifai-11.8.2}/setup.py +0 -0
  139. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_app.py +0 -0
  140. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_async_stub.py +0 -0
  141. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_auth.py +0 -0
  142. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_data_upload.py +0 -0
  143. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_eval.py +0 -0
  144. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_list_models.py +0 -0
  145. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_misc.py +0 -0
  146. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_model_predict.py +0 -0
  147. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_model_train.py +0 -0
  148. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_modules.py +0 -0
  149. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_pipeline_client.py +0 -0
  150. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_rag.py +0 -0
  151. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_search.py +0 -0
  152. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_secrets.py +0 -0
  153. {clarifai-11.8.1 → clarifai-11.8.2}/tests/test_stub.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clarifai
3
- Version: 11.8.1
3
+ Version: 11.8.2
4
4
  Home-page: https://github.com/Clarifai/clarifai-python
5
5
  Author: Clarifai
6
6
  Author-email: support@clarifai.com
@@ -19,8 +19,8 @@ Classifier: Operating System :: OS Independent
19
19
  Requires-Python: >=3.8
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
- Requires-Dist: clarifai-grpc>=11.7.9
23
- Requires-Dist: clarifai-protocol>=0.0.30
22
+ Requires-Dist: clarifai-grpc>=11.8.2
23
+ Requires-Dist: clarifai-protocol>=0.0.32
24
24
  Requires-Dist: numpy>=1.22.0
25
25
  Requires-Dist: tqdm>=4.65.0
26
26
  Requires-Dist: PyYAML>=6.0.1
@@ -34,6 +34,7 @@ Requires-Dist: aiohttp>=3.10.0
34
34
  Requires-Dist: uv==0.7.12
35
35
  Requires-Dist: ruff==0.11.4
36
36
  Requires-Dist: psutil==7.0.0
37
+ Requires-Dist: pygments>=2.19.2
37
38
  Requires-Dist: pydantic_core==2.33.2
38
39
  Requires-Dist: packaging==25.0
39
40
  Provides-Extra: all
@@ -0,0 +1 @@
1
+ __version__ = "11.8.2"
@@ -7,13 +7,18 @@ import click
7
7
 
8
8
  from clarifai.cli.base import cli, pat_display
9
9
  from clarifai.utils.cli import (
10
+ check_lmstudio_installed,
10
11
  check_ollama_installed,
11
12
  check_requirements_installed,
13
+ customize_huggingface_model,
14
+ customize_lmstudio_model,
12
15
  customize_ollama_model,
13
16
  parse_requirements,
14
17
  validate_context,
15
18
  )
16
19
  from clarifai.utils.constants import (
20
+ DEFAULT_HF_MODEL_REPO_BRANCH,
21
+ DEFAULT_LMSTUDIO_MODEL_REPO_BRANCH,
17
22
  DEFAULT_LOCAL_RUNNER_APP_ID,
18
23
  DEFAULT_LOCAL_RUNNER_COMPUTE_CLUSTER_CONFIG,
19
24
  DEFAULT_LOCAL_RUNNER_COMPUTE_CLUSTER_ID,
@@ -22,8 +27,9 @@ from clarifai.utils.constants import (
22
27
  DEFAULT_LOCAL_RUNNER_MODEL_TYPE,
23
28
  DEFAULT_LOCAL_RUNNER_NODEPOOL_CONFIG,
24
29
  DEFAULT_LOCAL_RUNNER_NODEPOOL_ID,
25
- DEFAULT_OLLAMA_MODEL_REPO,
26
30
  DEFAULT_OLLAMA_MODEL_REPO_BRANCH,
31
+ DEFAULT_TOOLKIT_MODEL_REPO,
32
+ DEFAULT_VLLM_MODEL_REPO_BRANCH,
27
33
  )
28
34
  from clarifai.utils.logging import logger
29
35
  from clarifai.utils.misc import (
@@ -68,14 +74,14 @@ def model():
68
74
  )
69
75
  @click.option(
70
76
  '--toolkit',
71
- type=click.Choice(['ollama'], case_sensitive=False),
77
+ type=click.Choice(['ollama', 'huggingface', 'lmstudio', 'vllm'], case_sensitive=False),
72
78
  required=False,
73
- help='Toolkit to use for model initialization. Currently supports "ollama".',
79
+ help='Toolkit to use for model initialization. Currently supports "ollama", "huggingface", "lmstudio" and "vllm".',
74
80
  )
75
81
  @click.option(
76
82
  '--model-name',
77
83
  required=False,
78
- help='Model name to configure when using --toolkit. For ollama toolkit, this sets the Ollama model to use (e.g., "llama3.1", "mistral", etc.).',
84
+ help='Model name to configure when using --toolkit. For ollama toolkit, this sets the Ollama model to use (e.g., "llama3.1", "mistral", etc.). For vllm & huggingface toolkit, this sets the Hugging Face model repo_id (e.g., "unsloth/Llama-3.2-1B-Instruct").\n For lmstudio toolkit, this sets the LM Studio model name (e.g., "qwen/qwen3-4b-thinking-2507").\n',
79
85
  )
80
86
  @click.option(
81
87
  '--port',
@@ -112,14 +118,16 @@ def init(
112
118
  when cloning private repositories. The --branch option can be used to specify a specific
113
119
  branch to clone from.
114
120
 
115
- MODEL_PATH: Path where to create the model directory structure. If not specified, the current directory is used by default.
116
- MODEL_TYPE_ID: Type of model to create. If not specified, defaults to "text-to-text" for text models.
117
- GITHUB_PAT: GitHub Personal Access Token for authentication when cloning private repositories.
118
- GITHUB_URL: GitHub repository URL or "repo" format to clone a repository from. If provided, the entire repository contents will be copied to the target directory instead of using default templates.
119
- TOOLKIT: Toolkit to use for model initialization. Currently supports "ollama".
120
- MODEL_NAME: Model name to configure when using --toolkit. For ollama toolkit, this sets the Ollama model to use (e.g., "llama3.1", "mistral", etc.).
121
- PORT: Port to run the Ollama server on. Defaults to 23333.
122
- CONTEXT_LENGTH: Context length for the Ollama model. Defaults to 8192.
121
+ MODEL_PATH: Path where to create the model directory structure. If not specified, the current directory is used by default.\n
122
+
123
+ OPTIONS:\n
124
+ MODEL_TYPE_ID: Type of model to create. If not specified, defaults to "text-to-text" for text models.\n
125
+ GITHUB_PAT: GitHub Personal Access Token for authentication when cloning private repositories.\n
126
+ GITHUB_URL: GitHub repository URL or "repo" format to clone a repository from. If provided, the entire repository contents will be copied to the target directory instead of using default templates.\n
127
+ TOOLKIT: Toolkit to use for model initialization. Currently supports "ollama", "huggingface", "lmstudio" and "vllm".\n
128
+ MODEL_NAME: Model name to configure when using --toolkit. For ollama toolkit, this sets the Ollama model to use (e.g., "llama3.1", "mistral", etc.). For vllm & huggingface toolkit, this sets the Hugging Face model repo_id (e.g., "Qwen/Qwen3-4B-Instruct-2507"). For lmstudio toolkit, this sets the LM Studio model name (e.g., "qwen/qwen3-4b-thinking-2507").\n
129
+ PORT: Port to run the (Ollama/lmstudio) server on. Defaults to 23333.\n
130
+ CONTEXT_LENGTH: Context length for the (Ollama/lmstudio) model. Defaults to 8192.\n
123
131
  """
124
132
  # Resolve the absolute path
125
133
  model_path = os.path.abspath(model_path)
@@ -152,8 +160,22 @@ def init(
152
160
  "Ollama is not installed. Please install it from `https://ollama.com/` to use the Ollama toolkit."
153
161
  )
154
162
  raise click.Abort()
155
- github_url = DEFAULT_OLLAMA_MODEL_REPO
163
+ github_url = DEFAULT_TOOLKIT_MODEL_REPO
156
164
  branch = DEFAULT_OLLAMA_MODEL_REPO_BRANCH
165
+ elif toolkit == 'huggingface':
166
+ github_url = DEFAULT_TOOLKIT_MODEL_REPO
167
+ branch = DEFAULT_HF_MODEL_REPO_BRANCH
168
+ elif toolkit == 'lmstudio':
169
+ if not check_lmstudio_installed():
170
+ logger.error(
171
+ "LM Studio is not installed. Please install it from `https://lmstudio.com/` to use the LM Studio toolkit."
172
+ )
173
+ raise click.Abort()
174
+ github_url = DEFAULT_TOOLKIT_MODEL_REPO
175
+ branch = DEFAULT_LMSTUDIO_MODEL_REPO_BRANCH
176
+ elif toolkit == 'vllm':
177
+ github_url = DEFAULT_TOOLKIT_MODEL_REPO
178
+ branch = DEFAULT_VLLM_MODEL_REPO_BRANCH
157
179
 
158
180
  if github_url:
159
181
  downloader = GitHubDownloader(
@@ -247,6 +269,13 @@ def init(
247
269
  if (model_name or port or context_length) and (toolkit == 'ollama'):
248
270
  customize_ollama_model(model_path, model_name, port, context_length)
249
271
 
272
+ if (model_name or port or context_length) and (toolkit == 'lmstudio'):
273
+ customize_lmstudio_model(model_path, model_name, port, context_length)
274
+
275
+ if model_name and (toolkit == 'huggingface' or toolkit == 'vllm'):
276
+ # Update the config.yaml file with the provided model name
277
+ customize_huggingface_model(model_path, model_name)
278
+
250
279
  if github_url:
251
280
  logger.info("Model initialization complete with GitHub repository")
252
281
  logger.info("Next steps:")
@@ -294,7 +323,7 @@ def init(
294
323
  if os.path.exists(config_path):
295
324
  logger.warning(f"File {config_path} already exists, skipping...")
296
325
  else:
297
- config_model_type_id = "text-to-text" # default
326
+ config_model_type_id = DEFAULT_LOCAL_RUNNER_MODEL_TYPE # default
298
327
 
299
328
  config_template = get_config_template(config_model_type_id)
300
329
  with open(config_path, 'w') as f:
@@ -178,7 +178,7 @@ class MyModel(OpenAIModelClass):
178
178
  '''
179
179
 
180
180
 
181
- def get_config_template(model_type_id: str = "text-to-text") -> str:
181
+ def get_config_template(model_type_id: str = "any-to-any") -> str:
182
182
  """Return the template for config.yaml."""
183
183
  return f'''# Configuration file for your Clarifai model
184
184
 
@@ -1,5 +1,5 @@
1
1
  from datetime import datetime
2
- from typing import Any, Callable
2
+ from typing import Any, Callable, Dict, Optional
3
3
 
4
4
  from clarifai_grpc.grpc.api import resources_pb2
5
5
  from google.protobuf import struct_pb2
@@ -88,20 +88,46 @@ class BaseClient:
88
88
  self.root_certificates_path = self.auth_helper._root_certificates_path
89
89
 
90
90
  @property
91
- def async_stub(self):
91
+ def async_stub(self) -> Any:
92
92
  """Returns the asynchronous gRPC stub for the API interaction.
93
- Lazy initialization of async stub"""
93
+
94
+ Returns:
95
+ Any: The async gRPC stub object for making asynchronous API calls.
96
+
97
+ Note:
98
+ Uses lazy initialization - stub is created on first access.
99
+ """
94
100
  if self._async_stub is None:
95
101
  self._async_stub = create_stub(self.auth_helper, is_async=True)
96
102
  return self._async_stub
97
103
 
98
104
  @classmethod
99
- def from_env(cls, validate: bool = False):
105
+ def from_env(cls, validate: bool = False) -> 'BaseClient':
106
+ """Creates a BaseClient instance from environment variables.
107
+
108
+ Args:
109
+ validate (bool): Whether to validate the authentication credentials.
110
+ Defaults to False.
111
+
112
+ Returns:
113
+ BaseClient: A new BaseClient instance configured from environment variables.
114
+ """
100
115
  auth = ClarifaiAuthHelper.from_env(validate=validate)
101
116
  return cls.from_auth_helper(auth)
102
117
 
103
118
  @classmethod
104
- def from_auth_helper(cls, auth: ClarifaiAuthHelper, **kwargs):
119
+ def from_auth_helper(cls, auth: ClarifaiAuthHelper, **kwargs) -> 'BaseClient':
120
+ """Creates a BaseClient instance from a ClarifaiAuthHelper.
121
+
122
+ Args:
123
+ auth (ClarifaiAuthHelper): The authentication helper containing credentials.
124
+ **kwargs: Additional keyword arguments to override auth helper values.
125
+ Supported keys: user_id, app_id, pat, token, root_certificates_path,
126
+ base, ui, url.
127
+
128
+ Returns:
129
+ BaseClient: A new BaseClient instance configured from the auth helper.
130
+ """
105
131
  default_kwargs = {
106
132
  "user_id": kwargs.get("user_id", None) or auth.user_id,
107
133
  "app_id": kwargs.get("app_id", None) or auth.app_id,
@@ -132,15 +158,18 @@ class BaseClient:
132
158
 
133
159
  return cls(**kwargs)
134
160
 
135
- def _grpc_request(self, method: Callable, argument: Any):
161
+ def _grpc_request(self, method: Callable[..., Any], argument: Any) -> Any:
136
162
  """Makes a gRPC request to the API.
137
163
 
138
164
  Args:
139
- method (Callable): The gRPC method to call.
140
- argument (Any): The argument to pass to the gRPC method.
165
+ method (Callable[..., Any]): The gRPC stub method to call.
166
+ argument (Any): The protobuf request object to pass to the gRPC method.
141
167
 
142
168
  Returns:
143
- res (Any): The result of the gRPC method call.
169
+ Any: The protobuf response object from the gRPC method call.
170
+
171
+ Raises:
172
+ Exception: If the API request fails.
144
173
  """
145
174
 
146
175
  try:
@@ -150,14 +179,16 @@ class BaseClient:
150
179
  except ApiError:
151
180
  raise Exception("ApiError")
152
181
 
153
- def convert_string_to_timestamp(self, date_str) -> Timestamp:
182
+ def convert_string_to_timestamp(self, date_str: str) -> Timestamp:
154
183
  """Converts a string to a Timestamp object.
155
184
 
156
185
  Args:
157
- date_str (str): The string to convert.
186
+ date_str (str): The date string to convert. Accepts formats like
187
+ '%Y-%m-%dT%H:%M:%S.%fZ' or '%Y-%m-%dT%H:%M:%SZ'.
158
188
 
159
189
  Returns:
160
- Timestamp: The converted Timestamp object.
190
+ Timestamp: The converted protobuf Timestamp object. Returns empty Timestamp
191
+ if the date string format is invalid.
161
192
  """
162
193
  # Parse the string into a Python datetime object
163
194
  try:
@@ -174,15 +205,22 @@ class BaseClient:
174
205
 
175
206
  return timestamp_obj
176
207
 
177
- def process_response_keys(self, old_dict, listing_resource=None):
208
+ def process_response_keys(
209
+ self, old_dict: Dict[str, Any], listing_resource: Optional[str] = None
210
+ ) -> Dict[str, Any]:
178
211
  """Converts keys in a response dictionary to resource proto format.
179
212
 
213
+ This method processes dictionary keys to match protobuf resource naming conventions,
214
+ particularly for converting 'id' to '{resource}_id' format.
215
+
180
216
  Args:
181
- old_dict (dict): The dictionary to convert.
182
- listing_resource (str, optional): The resource type for which the keys are being processed.
217
+ old_dict (Dict[str, Any]): The dictionary to convert with keys to process.
218
+ listing_resource (Optional[str]): The resource type for which the keys are being
219
+ processed (e.g., 'model', 'workflow'). If provided,
220
+ renames 'id' to '{listing_resource}_id'.
183
221
 
184
222
  Returns:
185
- new_dict (dict): The dictionary with processed keys.
223
+ Dict[str, Any]: The dictionary with processed keys and converted values.
186
224
  """
187
225
  if listing_resource:
188
226
  old_dict[f'{listing_resource}_id'] = old_dict['id']
@@ -4,7 +4,16 @@ import uuid
4
4
  from concurrent.futures import ThreadPoolExecutor, as_completed
5
5
  from datetime import datetime
6
6
  from multiprocessing import cpu_count
7
- from typing import Dict, Generator, List, Optional, Tuple, Type, TypeVar, Union
7
+ from typing import (
8
+ Dict,
9
+ Generator,
10
+ List,
11
+ Optional,
12
+ Tuple,
13
+ Type,
14
+ TypeVar,
15
+ Union,
16
+ )
8
17
 
9
18
  import requests
10
19
  from clarifai_grpc.grpc.api import resources_pb2, service_pb2
@@ -122,10 +131,13 @@ class Dataset(Lister, BaseClient):
122
131
  Args:
123
132
  **kwargs: Additional keyword arguments to be passed to Dataset Version.
124
133
  - description (str): The description of the dataset version.
125
- - metadata (dict): The metadata of the dataset version.
134
+ - metadata (Dict[str, Any]): The metadata dictionary for the dataset version.
126
135
 
127
136
  Returns:
128
- Dataset: A Dataset object for the specified dataset ID.
137
+ Dataset: A Dataset object for the newly created dataset version.
138
+
139
+ Raises:
140
+ Exception: If the dataset version creation fails.
129
141
 
130
142
  Example:
131
143
  >>> from clarifai.client.dataset import Dataset
@@ -172,13 +184,13 @@ class Dataset(Lister, BaseClient):
172
184
  self.logger.info("\nDataset Version Deleted\n%s", response.status)
173
185
 
174
186
  def list_versions(
175
- self, page_no: int = None, per_page: int = None
187
+ self, page_no: Optional[int] = None, per_page: Optional[int] = None
176
188
  ) -> Generator['Dataset', None, None]:
177
189
  """Lists all the versions for the dataset.
178
190
 
179
191
  Args:
180
- page_no (int): The page number to list.
181
- per_page (int): The number of items per page.
192
+ page_no (Optional[int]): The page number to list. If None, lists all pages.
193
+ per_page (Optional[int]): The number of items per page. If None, uses default.
182
194
 
183
195
  Yields:
184
196
  Dataset: Dataset objects for the versions of the dataset.
@@ -2,7 +2,7 @@ import itertools
2
2
  import json
3
3
  import os
4
4
  import time
5
- from typing import Any, Dict, Generator, Iterable, Iterator, List, Tuple, Union
5
+ from typing import Any, Dict, Generator, Iterable, Iterator, List, Optional, Tuple, Union
6
6
 
7
7
  import numpy as np
8
8
  import requests
@@ -178,20 +178,26 @@ class Model(Lister, BaseClient):
178
178
 
179
179
  return templates
180
180
 
181
- def get_params(self, template: str = None, save_to: str = 'params.yaml') -> Dict[str, Any]:
182
- """Returns the model params for the model type and yaml file.
181
+ def get_params(
182
+ self, template: Optional[str] = None, save_to: str = 'params.yaml'
183
+ ) -> Dict[str, Any]:
184
+ """Returns the model params for the model type and saves them to a yaml file.
183
185
 
184
186
  Args:
185
- template (str): The template to use for the model type.
186
- yaml_file (str): The yaml file to save the model params.
187
+ template (Optional[str]): The template to use for the model type. Required for most
188
+ model types except 'clusterer' and 'embedding-classifier'.
189
+ save_to (str): The yaml file path to save the model params. Defaults to 'params.yaml'.
187
190
 
188
191
  Returns:
189
- params (Dict): Dictionary of model params for the model type.
192
+ Dict[str, Any]: Dictionary of model params for the model type.
193
+
194
+ Raises:
195
+ UserError: If the model type is not trainable, or if template is required but not provided.
190
196
 
191
197
  Example:
192
198
  >>> from clarifai.client.model import Model
193
199
  >>> model = Model(model_id='model_id', user_id='user_id', app_id='app_id')
194
- >>> model_params = model.get_params(template='template', yaml_file='model_params.yaml')
200
+ >>> model_params = model.get_params(template='template', save_to='model_params.yaml')
195
201
  """
196
202
  if not self.model_info.model_type_id:
197
203
  self.load_info()
@@ -260,19 +266,22 @@ class Model(Lister, BaseClient):
260
266
  find_and_replace_key(self.training_params, key, value)
261
267
 
262
268
  def get_param_info(self, param: str) -> Dict[str, Any]:
263
- """Returns the param info for the param.
269
+ """Returns the parameter info for the specified parameter.
264
270
 
265
271
  Args:
266
- param (str): The param to get the info for.
272
+ param (str): The parameter name to get information for.
267
273
 
268
274
  Returns:
269
- param_info (Dict): Dictionary of model param info for the param.
275
+ Dict[str, Any]: Dictionary containing model parameter info for the specified param.
276
+
277
+ Raises:
278
+ UserError: If the model type is not trainable or if training params are not loaded.
270
279
 
271
280
  Example:
272
281
  >>> from clarifai.client.model import Model
273
282
  >>> model = Model(model_id='model_id', user_id='user_id', app_id='app_id')
274
- >>> model_params = model.get_params(template='template', yaml_file='model_params.yaml')
275
- >>> model.get_param_info('param')
283
+ >>> model_params = model.get_params(template='template', save_to='model_params.yaml')
284
+ >>> param_info = model.get_param_info('learning_rate')
276
285
  """
277
286
  if self.model_info.model_type_id not in TRAINABLE_MODEL_TYPES:
278
287
  raise UserError(f"Model type {self.model_info.model_type_id} is not trainable")
@@ -314,6 +314,7 @@ class ModelClient:
314
314
  self,
315
315
  base_url: str = None,
316
316
  use_ctx: bool = False,
317
+ colorize: bool = False,
317
318
  ) -> str:
318
319
  """Generate a client script for this model.
319
320
 
@@ -335,6 +336,7 @@ class ModelClient:
335
336
  compute_cluster_id=self.request_template.runner_selector.nodepool.compute_cluster.id,
336
337
  nodepool_id=self.request_template.runner_selector.nodepool.id,
337
338
  use_ctx=use_ctx,
339
+ colorize=colorize,
338
340
  )
339
341
 
340
342
  def _define_compatability_functions(self):
@@ -1,4 +1,4 @@
1
- from typing import Dict, Generator
1
+ from typing import Dict, Generator, Optional
2
2
 
3
3
  from clarifai_grpc.grpc.api import resources_pb2, service_pb2
4
4
 
@@ -15,25 +15,26 @@ class Module(Lister, BaseClient):
15
15
 
16
16
  def __init__(
17
17
  self,
18
- url: str = None,
19
- module_id: str = None,
20
- module_version: Dict = {'id': ""},
18
+ url: Optional[str] = None,
19
+ module_id: Optional[str] = None,
20
+ module_version: Dict[str, str] = {'id': ""},
21
21
  base_url: str = DEFAULT_BASE,
22
- pat: str = None,
23
- token: str = None,
24
- root_certificates_path: str = None,
22
+ pat: Optional[str] = None,
23
+ token: Optional[str] = None,
24
+ root_certificates_path: Optional[str] = None,
25
25
  **kwargs,
26
26
  ):
27
27
  """Initializes a Module object.
28
28
 
29
29
  Args:
30
- url (str): The URL to initialize the module object.
31
- module_id (str): The Module ID to interact with.
32
- module_version (dict): The Module Version to interact with.
30
+ url (Optional[str]): The URL to initialize the module object.
31
+ module_id (Optional[str]): The Module ID to interact with.
32
+ module_version (Dict[str, str]): The Module Version to interact with.
33
+ Defaults to {'id': ""} for latest version.
33
34
  base_url (str): Base API url. Default "https://api.clarifai.com"
34
- pat (str): A personal access token for authentication. Can be set as env var CLARIFAI_PAT.
35
- token (str): A session token for authentication. Accepts either a session token or a pat. Can be set as env var CLARIFAI_SESSION_TOKEN.
36
- root_certificates_path (str): Path to the SSL root certificates file, used to establish secure gRPC connections.
35
+ pat (Optional[str]): A personal access token for authentication. Can be set as env var CLARIFAI_PAT.
36
+ token (Optional[str]): A session token for authentication. Accepts either a session token or a pat. Can be set as env var CLARIFAI_SESSION_TOKEN.
37
+ root_certificates_path (Optional[str]): Path to the SSL root certificates file, used to establish secure gRPC connections.
37
38
  **kwargs: Additional keyword arguments to be passed to the Module.
38
39
  """
39
40
  if url and module_id:
@@ -334,7 +334,9 @@ class Nodepool(Lister, BaseClient):
334
334
  f"Runner with ID '{response.runners[0].id}' is created:\n{response.status}"
335
335
  )
336
336
 
337
- dict_response = MessageToDict(response.runners[0], preserving_proto_field_name=True)
337
+ dict_response = MessageToDict(
338
+ response.runners[0], preserving_proto_field_name=True, use_integers_for_enums=True
339
+ )
338
340
  kwargs = self.process_response_keys(dict_response, 'runner')
339
341
  return Runner.from_auth_helper(auth=self.auth_helper, **kwargs)
340
342
 
@@ -1,6 +1,6 @@
1
1
  import time
2
2
  import uuid
3
- from typing import Dict, List
3
+ from typing import Dict, List, Optional
4
4
 
5
5
  from clarifai_grpc.grpc.api import resources_pb2, service_pb2
6
6
  from clarifai_grpc.grpc.api.status import status_code_pb2
@@ -19,35 +19,35 @@ class Pipeline(Lister, BaseClient):
19
19
 
20
20
  def __init__(
21
21
  self,
22
- url: str = None,
23
- pipeline_id: str = None,
24
- pipeline_version_id: str = None,
25
- pipeline_version_run_id: str = None,
26
- user_id: str = None,
27
- app_id: str = None,
28
- nodepool_id: str = None,
29
- compute_cluster_id: str = None,
30
- log_file: str = None,
22
+ url: Optional[str] = None,
23
+ pipeline_id: Optional[str] = None,
24
+ pipeline_version_id: Optional[str] = None,
25
+ pipeline_version_run_id: Optional[str] = None,
26
+ user_id: Optional[str] = None,
27
+ app_id: Optional[str] = None,
28
+ nodepool_id: Optional[str] = None,
29
+ compute_cluster_id: Optional[str] = None,
30
+ log_file: Optional[str] = None,
31
31
  base_url: str = DEFAULT_BASE,
32
- pat: str = None,
33
- token: str = None,
34
- root_certificates_path: str = None,
32
+ pat: Optional[str] = None,
33
+ token: Optional[str] = None,
34
+ root_certificates_path: Optional[str] = None,
35
35
  **kwargs,
36
36
  ):
37
37
  """Initializes a Pipeline object.
38
38
 
39
39
  Args:
40
- url (str): The URL to initialize the pipeline object.
41
- pipeline_id (str): The Pipeline ID to interact with.
42
- pipeline_version_id (str): The Pipeline Version ID to interact with.
43
- pipeline_version_run_id (str): The Pipeline Version Run ID. If not provided, a UUID will be generated.
44
- user_id (str): The User ID that owns the pipeline.
45
- app_id (str): The App ID that contains the pipeline.
46
- nodepool_id (str): The Nodepool ID to run the pipeline on.
47
- compute_cluster_id (str): The Compute Cluster ID to run the pipeline on.
48
- log_file (str): Path to file where logs should be written. If not provided, logs are displayed on console.
40
+ url (Optional[str]): The URL to initialize the pipeline object.
41
+ pipeline_id (Optional[str]): The Pipeline ID to interact with.
42
+ pipeline_version_id (Optional[str]): The Pipeline Version ID to interact with.
43
+ pipeline_version_run_id (Optional[str]): The Pipeline Version Run ID. If not provided, a UUID will be generated.
44
+ user_id (Optional[str]): The User ID that owns the pipeline.
45
+ app_id (Optional[str]): The App ID that contains the pipeline.
46
+ nodepool_id (Optional[str]): The Nodepool ID to run the pipeline on.
47
+ compute_cluster_id (Optional[str]): The Compute Cluster ID to run the pipeline on.
48
+ log_file (Optional[str]): Path to file where logs should be written. If not provided, logs are displayed on console.
49
49
  base_url (str): Base API url. Default "https://api.clarifai.com"
50
- pat (str): A personal access token for authentication. Can be set as env var CLARIFAI_PAT
50
+ pat (Optional[str]): A personal access token for authentication. Can be set as env var CLARIFAI_PAT
51
51
  token (str): A session token for authentication. Accepts either a session token or a pat. Can be set as env var CLARIFAI_SESSION_TOKEN
52
52
  root_certificates_path (str): Path to the SSL root certificates file, used to establish secure gRPC connections.
53
53
  **kwargs: Additional keyword arguments to be passed to the Pipeline.
@@ -1,3 +1,5 @@
1
+ from typing import Optional
2
+
1
3
  from clarifai.client.base import BaseClient
2
4
  from clarifai.client.lister import Lister
3
5
  from clarifai.urls.helper import ClarifaiUrlHelper
@@ -9,31 +11,31 @@ class PipelineStep(Lister, BaseClient):
9
11
 
10
12
  def __init__(
11
13
  self,
12
- url: str = None,
13
- pipeline_step_id: str = None,
14
- pipeline_step_version_id: str = None,
15
- user_id: str = None,
16
- app_id: str = None,
17
- pipeline_id: str = None,
14
+ url: Optional[str] = None,
15
+ pipeline_step_id: Optional[str] = None,
16
+ pipeline_step_version_id: Optional[str] = None,
17
+ user_id: Optional[str] = None,
18
+ app_id: Optional[str] = None,
19
+ pipeline_id: Optional[str] = None,
18
20
  base_url: str = DEFAULT_BASE,
19
- pat: str = None,
20
- token: str = None,
21
- root_certificates_path: str = None,
21
+ pat: Optional[str] = None,
22
+ token: Optional[str] = None,
23
+ root_certificates_path: Optional[str] = None,
22
24
  **kwargs,
23
25
  ):
24
26
  """Initializes a PipelineStep object.
25
27
 
26
28
  Args:
27
- url (str): The URL to initialize the pipeline step object.
28
- pipeline_step_id (str): The PipelineStep ID for the PipelineStep to interact with.
29
- pipeline_step_version_id (str): The PipelineStep version ID for the PipelineStep to interact with.
30
- user_id (str): The User ID for the PipelineStep to interact with.
31
- app_id (str): The App ID for the PipelineStep to interact with.
32
- pipeline_id (str): The Pipeline ID for the PipelineStep to interact with.
29
+ url (Optional[str]): The URL to initialize the pipeline step object.
30
+ pipeline_step_id (Optional[str]): The PipelineStep ID for the PipelineStep to interact with.
31
+ pipeline_step_version_id (Optional[str]): The PipelineStep version ID for the PipelineStep to interact with.
32
+ user_id (Optional[str]): The User ID for the PipelineStep to interact with.
33
+ app_id (Optional[str]): The App ID for the PipelineStep to interact with.
34
+ pipeline_id (Optional[str]): The Pipeline ID for the PipelineStep to interact with.
33
35
  base_url (str): Base API url. Default "https://api.clarifai.com"
34
- pat (str): A personal access token for authentication.
35
- token (str): A session token for authentication.
36
- root_certificates_path (str): Path to the SSL root certificates file.
36
+ pat (Optional[str]): A personal access token for authentication.
37
+ token (Optional[str]): A session token for authentication.
38
+ root_certificates_path (Optional[str]): Path to the SSL root certificates file.
37
39
  **kwargs: Additional keyword arguments to be passed to the BaseClient.
38
40
  """
39
41
  if url: