clarifai 11.4.3__py3-none-any.whl → 11.4.4__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.3"
1
+ __version__ = "11.4.4"
@@ -196,7 +196,7 @@ class ModelClient:
196
196
  f.__name__ = method_name
197
197
  f.__qualname__ = f'{self.__class__.__name__}.{method_name}'
198
198
  input_annotations = code_script._get_annotations_source(method_signature)
199
- return_annotation = input_annotations.pop('return', (None, None))[0]
199
+ return_annotation = input_annotations.pop('return', (None, None, None))[0]
200
200
  sig = inspect.signature(f).replace(
201
201
  parameters=[
202
202
  inspect.Parameter(k, inspect.Parameter.POSITIONAL_OR_KEYWORD, annotation=v[0])
@@ -87,13 +87,13 @@ model = Model({model_ui_url},
87
87
  method_name = method_signature.name
88
88
  client_script_str = f'response = model.{method_name}('
89
89
  annotations = _get_annotations_source(method_signature)
90
- for param_name, (param_type, default_value) in annotations.items():
90
+ for param_name, (param_type, default_value, required) in annotations.items():
91
91
  print(
92
92
  f"param_name: {param_name}, param_type: {param_type}, default_value: {default_value}"
93
93
  )
94
94
  if param_name == "return":
95
95
  continue
96
- if default_value is None:
96
+ if default_value is None and required:
97
97
  default_value = _set_default_value(param_type)
98
98
  client_script_str += f"{param_name}={default_value}, "
99
99
  client_script_str = client_script_str.rstrip(", ") + ")"
@@ -132,7 +132,7 @@ def _get_annotations_source(method_signature: resources_pb2.MethodSignature) ->
132
132
  default_value = None
133
133
  if data_utils.Param.get_default(input_field):
134
134
  default_value = _parse_default_value(input_field)
135
- annotations[param_name] = (param_type, default_value)
135
+ annotations[param_name] = (param_type, default_value, input_field.required)
136
136
  if not method_signature.output_fields:
137
137
  raise ValueError("MethodSignature must have at least one output field")
138
138
  for output_field in method_signature.output_fields:
@@ -140,7 +140,7 @@ def _get_annotations_source(method_signature: resources_pb2.MethodSignature) ->
140
140
  param_type = _get_base_type(output_field)
141
141
  if output_field.iterator:
142
142
  param_type = f"Iterator[{param_type}]"
143
- annotations[param_name] = (param_type, None)
143
+ annotations[param_name] = (param_type, None, output_field.required)
144
144
  return annotations
145
145
 
146
146
 
@@ -189,7 +189,7 @@ def _map_default_value(field_type):
189
189
  default_value = None
190
190
 
191
191
  if field_type == "str":
192
- default_value = 'What is the future of AI?'
192
+ default_value = repr('What is the future of AI?')
193
193
  elif field_type == "bytes":
194
194
  default_value = b""
195
195
  elif field_type == "int":
@@ -224,11 +224,9 @@ def _set_default_value(field_type):
224
224
  Set the default value of a field if it is not set.
225
225
  """
226
226
  is_iterator = False
227
- print(f"before field_type: {field_type}")
228
227
  if field_type.startswith("Iterator["):
229
228
  is_iterator = True
230
229
  field_type = field_type[9:-1]
231
- print(f"after field_type: {field_type}")
232
230
  default_value = None
233
231
  default_value = _map_default_value(field_type)
234
232
  if field_type.startswith("List["):
@@ -245,11 +243,8 @@ def _set_default_value(field_type):
245
243
  element_type_defaults = [_map_default_value(et) for et in element_types]
246
244
  default_value = f"{{{', '.join([str(et) for et in element_type_defaults])}}}"
247
245
 
248
- if field_type == 'str':
249
- default_value = repr(default_value)
250
246
  if is_iterator:
251
247
  default_value = f'iter([{default_value}])'
252
- print(f"after default_value: {default_value}")
253
248
  return default_value
254
249
 
255
250
 
@@ -320,9 +320,7 @@ class Param(MessageData):
320
320
  proto.model_type_range_info.CopyFrom(range_info)
321
321
  proto.is_param = self.is_param
322
322
 
323
- if self.default is not None:
324
- proto = self.set_default(proto, self.default)
325
-
323
+ proto = self.set_default(proto, self.default)
326
324
  return proto
327
325
 
328
326
  @classmethod
@@ -74,32 +74,12 @@ def build_function_signature(func):
74
74
  assert method_type in ('UNARY_UNARY', 'UNARY_STREAMING', 'STREAMING_STREAMING')
75
75
  # method_signature.method_type = method_type
76
76
  method_signature.description = inspect.cleandoc(func.__doc__ or '')
77
- # method_signature.annotations_json = json.dumps(_get_annotations_source(func))
78
77
 
79
78
  method_signature.input_fields.extend(input_sigs)
80
79
  method_signature.output_fields.append(output_sig)
81
80
  return method_signature
82
81
 
83
82
 
84
- # def _get_annotations_source(func):
85
- # """Extracts raw annotation strings from the function source."""
86
- # source = inspect.getsource(func) # Get function source code
87
- # source = textwrap.dedent(source) # Dedent source code
88
- # tree = ast.parse(source) # Parse into AST
89
- # func_node = next(node for node in tree.body
90
- # if isinstance(node, ast.FunctionDef)) # Get function node
91
-
92
- # annotations = {}
93
- # for arg in func_node.args.args: # Process arguments
94
- # if arg.annotation:
95
- # annotations[arg.arg] = ast.unparse(arg.annotation) # Get raw annotation string
96
-
97
- # if func_node.returns: # Process return type
98
- # annotations["return"] = ast.unparse(func_node.returns)
99
-
100
- # return annotations
101
-
102
-
103
83
  def _process_input_field(field: resources_pb2.ModelTypeField) -> str:
104
84
  base_type = _get_base_type(field)
105
85
  if field.iterator:
@@ -171,14 +171,14 @@ def openai_to_hf_messages(openai_messages):
171
171
 
172
172
 
173
173
  def build_openai_messages(
174
- prompt: str,
175
- image: Image,
176
- images: List[Image],
177
- audio: Audio,
178
- audios: List[Audio],
179
- video: Video,
180
- videos: List[Video],
181
- messages: List[Dict],
174
+ prompt: str = None,
175
+ image: Image = None,
176
+ images: List[Image] = None,
177
+ audio: Audio = None,
178
+ audios: List[Audio] = None,
179
+ video: Video = None,
180
+ videos: List[Video] = None,
181
+ messages: List[Dict] = None,
182
182
  ) -> List[Dict]:
183
183
  """
184
184
  Construct OpenAI-compatible messages from input components.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clarifai
3
- Version: 11.4.3
3
+ Version: 11.4.4
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=WC-Q7uwDymQD3TdIUlUDTeqf9vxRXHJ_xDIRpvTVvsw,23
1
+ clarifai/__init__.py,sha256=sUX_44ac6i5WHivSDqnx8WOTpwJ2J_D46SUoKT-SUh4,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
@@ -19,7 +19,7 @@ clarifai/client/deployment.py,sha256=QBf0tzkKBEpzNgmOEmWUJMOlVWdFEFc70Y44o8y75Gs
19
19
  clarifai/client/input.py,sha256=jpX47qwn7aUBBIEuSSLHF5jk70XaWEh0prD065c9b-E,51205
20
20
  clarifai/client/lister.py,sha256=1YEm2suNxPaJO4x9V5szgD_YX6N_00vgSO-7m0HagY8,2208
21
21
  clarifai/client/model.py,sha256=XptnbfvNnaRCvv6Sdc7hfZnEPL8z9_-nFB3OmKujfAE,86267
22
- clarifai/client/model_client.py,sha256=V0rDa1Qnol2qfAvJI6SwZfbtXqNowPRRMOYBH2Em0so,22386
22
+ clarifai/client/model_client.py,sha256=XOrrm1xOZt62eLX5KbvV-zKSpK4EJOPUTUrGnH8z_KE,22392
23
23
  clarifai/client/module.py,sha256=jLViQYvVV3FmRN_ivvbk83uwsx7CgYGeEx4dYAr6yD4,4537
24
24
  clarifai/client/nodepool.py,sha256=Y5zQ0JLdTjAp2TmVnx7AAOwaB2YUslk3nl7s6BQ90FQ,16415
25
25
  clarifai/client/runner.py,sha256=5xCiqByGGscfNm0IjHelhDTx8-9l8G0C3HL-3YZogK8,2253
@@ -76,12 +76,12 @@ clarifai/runners/models/model_servicer.py,sha256=rRd_fNEXwqiBSzTUtPI2r07EBdcCPd8
76
76
  clarifai/runners/models/visual_classifier_class.py,sha256=f9ZP8KFamMUdMpUG3AlL9nVCdcggy_E5n9RJY3ixR1U,2739
77
77
  clarifai/runners/models/visual_detector_class.py,sha256=ky4oFAkGCKPpGPdgaOso-n6D3HcmnbKee_8hBsNiV8U,2883
78
78
  clarifai/runners/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
79
- clarifai/runners/utils/code_script.py,sha256=3_zBuMKs-eKfC4rbxKf-atVMz36djKH5QvDY2Fgs6Jk,11418
79
+ clarifai/runners/utils/code_script.py,sha256=qU5B3vJmIjQnB_nQJI_aUfj8glezmNWgaPonZsE0_Xo,11278
80
80
  clarifai/runners/utils/const.py,sha256=Q4Ps6gIEJCyTdQCfmT6PaS61WHmhT25XigV1NugWz-E,1544
81
- clarifai/runners/utils/data_utils.py,sha256=GspFOTgUPdqSQG-Zy6lrB1V55gQhGDG3Co6AxiqAr1I,20792
81
+ clarifai/runners/utils/data_utils.py,sha256=4M4n-cGprBEBV5UkgOWaUlVfZ3WBTmegdffGQ3SfYCU,20750
82
82
  clarifai/runners/utils/loader.py,sha256=K5Y8MPbIe5STw2gDnrL8KqFgKNxEo7bz-RV0ip1T4PM,10900
83
- clarifai/runners/utils/method_signatures.py,sha256=3EqrTLxynaBC4clj23iw9fZApFDQeapCzVlre6uybbI,19152
84
- clarifai/runners/utils/openai_convertor.py,sha256=2emAgi9YXpxlOGRw5MG9jhyUUrdDjD9Sv3mnGtwcgts,8192
83
+ clarifai/runners/utils/method_signatures.py,sha256=qdHaO8ZIgP6BBXXMhMPhcQ46dse-XMP2t4VJCNG7O3Q,18335
84
+ clarifai/runners/utils/openai_convertor.py,sha256=ZlIrvvfHttD_DavLvmKZdL8gNq_TQvQtZVnYamwdWz4,8248
85
85
  clarifai/runners/utils/serializers.py,sha256=pI7GqMTC0T3Lu_X8v8TO4RiplO-gC_49Ns37jYwsPtg,7908
86
86
  clarifai/runners/utils/url_fetcher.py,sha256=Segkvi-ktPa3-koOpUu8DNZeWOaK6G82Ya9b7_oIKwo,1778
87
87
  clarifai/runners/utils/data_types/__init__.py,sha256=iBtmPkIoLK9ew6ZiXElGt2YBBTDLEA0fmxE_eOYzvhk,478
@@ -104,9 +104,9 @@ clarifai/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
104
104
  clarifai/workflows/export.py,sha256=Oq3RVNKvv1iH46U6oIjXa-MXWJ4sTlXr_NSfwoxr3H4,2149
105
105
  clarifai/workflows/utils.py,sha256=ESL3INcouNcLKCh-nMpfXX-YbtCzX7tz7hT57_RGQ3M,2079
106
106
  clarifai/workflows/validate.py,sha256=UhmukyHkfxiMFrPPeBdUTiCOHQT5-shqivlBYEyKTlU,2931
107
- clarifai-11.4.3.dist-info/licenses/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
108
- clarifai-11.4.3.dist-info/METADATA,sha256=ZtwykytAB7xvh8sEZVa84cPoTAM7nX15TQowlnejPE0,22398
109
- clarifai-11.4.3.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
110
- clarifai-11.4.3.dist-info/entry_points.txt,sha256=X9FZ4Z-i_r2Ud1RpZ9sNIFYuu_-9fogzCMCRUD9hyX0,51
111
- clarifai-11.4.3.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
112
- clarifai-11.4.3.dist-info/RECORD,,
107
+ clarifai-11.4.4.dist-info/licenses/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
108
+ clarifai-11.4.4.dist-info/METADATA,sha256=PPC2dIigq8LyS79SNag-OWUK5oMM9BCU24_KFRv4AF0,22398
109
+ clarifai-11.4.4.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
110
+ clarifai-11.4.4.dist-info/entry_points.txt,sha256=X9FZ4Z-i_r2Ud1RpZ9sNIFYuu_-9fogzCMCRUD9hyX0,51
111
+ clarifai-11.4.4.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
112
+ clarifai-11.4.4.dist-info/RECORD,,