clarifai 11.4.5__py3-none-any.whl → 11.4.6__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.
clarifai/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "11.4.5"
1
+ __version__ = "11.4.6"
@@ -144,8 +144,8 @@ class MockCompletionStream:
144
144
  class DummyOpenAIModel(OpenAIModelClass):
145
145
  """Dummy OpenAI model implementation for testing."""
146
146
 
147
- openai_client = MockOpenAIClient()
148
- model_name = "dummy-model"
147
+ client = MockOpenAIClient()
148
+ model = "dummy-model"
149
149
 
150
150
  def _process_request(self, **kwargs) -> Dict[str, Any]:
151
151
  """Process a request for non-streaming responses."""
@@ -6,6 +6,7 @@ import traceback
6
6
  from abc import ABC
7
7
  from collections import abc
8
8
  from typing import Any, Dict, Iterator, List
9
+ from unittest.mock import MagicMock
9
10
 
10
11
  from clarifai_grpc.grpc.api import resources_pb2, service_pb2
11
12
  from clarifai_grpc.grpc.api.status import status_code_pb2, status_pb2
@@ -346,6 +347,13 @@ class ModelClass(ABC):
346
347
  methods = {}
347
348
  for base in reversed(cls.__mro__):
348
349
  for name, method in base.__dict__.items():
350
+ # Skip class attributes, mocked objects, and non-methods
351
+ if not callable(method) or isinstance(method, (classmethod, staticmethod)):
352
+ continue
353
+ # Skip any mocked objects or attributes
354
+ if isinstance(method, MagicMock) or hasattr(method, '_mock_return_value'):
355
+ continue
356
+ # Only include methods that have been decorated with @ModelClass.method
349
357
  method_info = getattr(method, _METHOD_INFO_ATTR, None)
350
358
  if not method_info: # regular function, not a model method
351
359
  continue
@@ -11,27 +11,29 @@ class OpenAIModelClass(ModelClass):
11
11
  This handles all the transport between the API and the OpenAI-compatible server.
12
12
 
13
13
  To use this class, create a subclass and set the following class attributes:
14
- - openai_client: The OpenAI-compatible client instance
15
- - model_name: The name of the model to use with the client
14
+ - client: The OpenAI-compatible client instance
15
+ - model: The name of the model to use with the client
16
16
 
17
17
  Example:
18
18
  class MyOpenAIModel(OpenAIModelClass):
19
- openai_client = OpenAI(api_key="your-key")
20
- model_name = "gpt-4"
19
+ client = OpenAI(api_key="your-key")
20
+ model = "gpt-4"
21
21
  """
22
22
 
23
23
  # These should be overridden in subclasses
24
- openai_client = None
25
- model_name = None
24
+ client = None
25
+ model = None
26
26
 
27
27
  def __init__(self) -> None:
28
- if self.openai_client is None:
29
- raise NotImplementedError("Subclasses must set the 'openai_client' class attribute")
30
- if self.model_name is None:
31
- self.model_name = self.openai_client.models.list().data[0].id
32
-
33
- self.client = self.openai_client
34
- self.model = self.model_name
28
+ if self.client is None:
29
+ raise NotImplementedError("Subclasses must set the 'client' class attribute")
30
+ if self.model is None:
31
+ try:
32
+ self.model = self.client.models.list().data[0].id
33
+ except Exception as e:
34
+ raise NotImplementedError(
35
+ "Subclasses must set the 'model' class attribute or ensure the client can list models"
36
+ ) from e
35
37
 
36
38
  def _extract_request_params(self, request_data: Dict[str, Any]) -> Dict[str, Any]:
37
39
  """Extract and validate common openai arguments parameters from the request data.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clarifai
3
- Version: 11.4.5
3
+ Version: 11.4.6
4
4
  Home-page: https://github.com/Clarifai/clarifai-python
5
5
  Author: Clarifai
6
6
  Author-email: support@clarifai.com
@@ -1,4 +1,4 @@
1
- clarifai/__init__.py,sha256=kV7nbYrWnc8FLLQtKI_7asjBj6k3ELmICuzhSmhU4Mk,23
1
+ clarifai/__init__.py,sha256=nV_wnJ_Jf3dtyFB9emgspFcYUJJezVc0zPs1ncsDV3Q,23
2
2
  clarifai/cli.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  clarifai/errors.py,sha256=GXa6D4v_L404J83jnRNFPH7s-1V9lk7w6Ws99f1g-AY,2772
4
4
  clarifai/versions.py,sha256=ecSuEB_nOL2XSoYHDw2n23XUbm_KPOGjudMXmQrGdS8,224
@@ -67,14 +67,14 @@ clarifai/runners/__init__.py,sha256=CQhpUOj_x-oV9xEUKdL-hi3A1BQAtPUv-FFOev4a96w,
67
67
  clarifai/runners/server.py,sha256=9qVAs8pRHmtyY0RCNIQ1uP8nqDADIFZ03LnkoDt1h4U,4692
68
68
  clarifai/runners/dockerfile_template/Dockerfile.template,sha256=5cjv7U8PmWa3DB_5B1CqSYh_6GE0E0np52TIAa7EIDE,2312
69
69
  clarifai/runners/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
70
- clarifai/runners/models/dummy_openai_model.py,sha256=nbE6ZnLDUfor9omN536jMk64ZOi5OnwJqgvI93wTKqY,7220
70
+ clarifai/runners/models/dummy_openai_model.py,sha256=5oa7r8j1GpymenpmMfaAV9Vt6VObKvrT9tDXgFmP4qY,7208
71
71
  clarifai/runners/models/mcp_class.py,sha256=7uwCMade0LMMBq7vczhPf4Kxdmh8Rj0R7Pg3pPxYdjQ,6386
72
72
  clarifai/runners/models/model_builder.py,sha256=PiqPyTGPSKsYvOQNpBzs4e1_wuEbtE-P3yEkLE4Py10,49231
73
- clarifai/runners/models/model_class.py,sha256=OHVd0tMOXDyl9v1vWeHOmYGx_dvP77N4zlLGMyTakag,15575
73
+ clarifai/runners/models/model_class.py,sha256=-euUF-eHUi4KXR_e1pIwvToDZ13CM6TSz2FolzildjM,16069
74
74
  clarifai/runners/models/model_run_locally.py,sha256=6-6WjEKc0ba3gAv4wOLdMs2XOzS3b-2bZHJS0wdVqJY,20088
75
75
  clarifai/runners/models/model_runner.py,sha256=SccX-RxTgruSpQaM21uMSl-z1x6fOa13fQZMQW8NNRY,7297
76
76
  clarifai/runners/models/model_servicer.py,sha256=rRd_fNEXwqiBSzTUtPI2r07EBdcCPd8tcSPHeqTe0_I,3445
77
- clarifai/runners/models/openai_class.py,sha256=bD5Th_Pgu8RRP0OsraWClDUtbrB9-bygfIBRpzWfOac,8074
77
+ clarifai/runners/models/openai_class.py,sha256=3u6K7vTdYybxdTT3t3pYh9wvQyWhkL595t7hR5IkljU,8159
78
78
  clarifai/runners/models/visual_classifier_class.py,sha256=f9ZP8KFamMUdMpUG3AlL9nVCdcggy_E5n9RJY3ixR1U,2739
79
79
  clarifai/runners/models/visual_detector_class.py,sha256=ky4oFAkGCKPpGPdgaOso-n6D3HcmnbKee_8hBsNiV8U,2883
80
80
  clarifai/runners/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -106,9 +106,9 @@ clarifai/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
106
106
  clarifai/workflows/export.py,sha256=Oq3RVNKvv1iH46U6oIjXa-MXWJ4sTlXr_NSfwoxr3H4,2149
107
107
  clarifai/workflows/utils.py,sha256=ESL3INcouNcLKCh-nMpfXX-YbtCzX7tz7hT57_RGQ3M,2079
108
108
  clarifai/workflows/validate.py,sha256=UhmukyHkfxiMFrPPeBdUTiCOHQT5-shqivlBYEyKTlU,2931
109
- clarifai-11.4.5.dist-info/licenses/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
110
- clarifai-11.4.5.dist-info/METADATA,sha256=5wUGZgaAVSm1sGoBaaBp8Lq6shX5SrkHuYkAhSND000,22398
111
- clarifai-11.4.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
112
- clarifai-11.4.5.dist-info/entry_points.txt,sha256=X9FZ4Z-i_r2Ud1RpZ9sNIFYuu_-9fogzCMCRUD9hyX0,51
113
- clarifai-11.4.5.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
114
- clarifai-11.4.5.dist-info/RECORD,,
109
+ clarifai-11.4.6.dist-info/licenses/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
110
+ clarifai-11.4.6.dist-info/METADATA,sha256=Y2hsYELo0z0R3xTTPuv0-VvPcMlYdieAS1EWKfkhQ6o,22398
111
+ clarifai-11.4.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
112
+ clarifai-11.4.6.dist-info/entry_points.txt,sha256=X9FZ4Z-i_r2Ud1RpZ9sNIFYuu_-9fogzCMCRUD9hyX0,51
113
+ clarifai-11.4.6.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
114
+ clarifai-11.4.6.dist-info/RECORD,,