nexaai 1.0.19rc19__cp310-cp310-win_amd64.whl → 1.0.21rc1__cp310-cp310-win_amd64.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.

Potentially problematic release.


This version of nexaai might be problematic. Click here for more details.

nexaai/__init__.py CHANGED
@@ -24,6 +24,13 @@ from .common import ModelConfig, GenerationConfig, ChatMessage, SamplerConfig, P
24
24
  # Import logging functionality
25
25
  from .log import set_logger, get_error_message
26
26
 
27
+ # Import runtime errors
28
+ from .runtime_error import (
29
+ NexaRuntimeError,
30
+ ContextLengthExceededError,
31
+ GenerationError
32
+ )
33
+
27
34
  # Create alias for PluginID to be accessible as plugin_id
28
35
  plugin_id = PluginID
29
36
 
@@ -52,6 +59,11 @@ __all__ = [
52
59
  # Logging functionality
53
60
  "set_logger",
54
61
  "get_error_message",
62
+
63
+ # Runtime errors
64
+ "NexaRuntimeError",
65
+ "ContextLengthExceededError",
66
+ "GenerationError",
55
67
 
56
68
  "LLM",
57
69
  "Embedder",
Binary file
nexaai/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # This file is generated by CMake from _version.py.in
2
2
  # Do not modify this file manually - it will be overwritten
3
3
 
4
- __version__ = "1.0.19-rc19"
4
+ __version__ = "1.0.21-rc1"
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,24 @@
1
+ """Runtime errors for Nexa SDK operations."""
2
+
3
+
4
+ class NexaRuntimeError(Exception):
5
+ """Base class for Nexa runtime errors."""
6
+
7
+ def __init__(self, message: str, error_code: int = None):
8
+ self.error_code = error_code
9
+ super().__init__(message)
10
+
11
+
12
+ class ContextLengthExceededError(NexaRuntimeError):
13
+ """Raised when the input context length exceeds the model's maximum."""
14
+
15
+ def __init__(self, message: str = "Input context length exceeded model's maximum", error_code: int = None):
16
+ super().__init__(message, error_code)
17
+
18
+
19
+ class GenerationError(NexaRuntimeError):
20
+ """Raised when generation fails."""
21
+
22
+ def __init__(self, message: str = "Generation failed", error_code: int = None):
23
+ super().__init__(message, error_code)
24
+
nexaai/vlm.py CHANGED
@@ -99,7 +99,8 @@ class VLM(BaseModel):
99
99
  def apply_chat_template(
100
100
  self,
101
101
  messages: List[MultiModalMessage],
102
- tools: Optional[List[Dict[str, Any]]] = None
102
+ tools: Optional[List[Dict[str, Any]]] = None,
103
+ enable_thinking: bool = True
103
104
  ) -> str:
104
105
  """Apply the chat template to multimodal messages."""
105
106
  pass
@@ -72,7 +72,8 @@ class MlxVlmImpl(VLM):
72
72
  def apply_chat_template(
73
73
  self,
74
74
  messages: List[MultiModalMessage],
75
- tools: Optional[List[Dict[str, Any]]] = None
75
+ tools: Optional[List[Dict[str, Any]]] = None,
76
+ enable_thinking: bool = True
76
77
  ) -> str:
77
78
  """Apply the chat template to multimodal messages."""
78
79
  if not self._mlx_vlm:
@@ -116,7 +117,7 @@ class MlxVlmImpl(VLM):
116
117
  num_images=total_images,
117
118
  num_audios=total_audios,
118
119
  tools=tools,
119
- enable_thinking=False # Default to False, could be made configurable
120
+ enable_thinking=enable_thinking
120
121
  )
121
122
  else:
122
123
  # Use regular apply_chat_template for text-only messages
@@ -8,6 +8,11 @@ from nexaai.binds import vlm_bind, common_bind
8
8
  from nexaai.runtime import _ensure_runtime
9
9
  from nexaai.vlm import VLM
10
10
  from nexaai.base import ProfilingData
11
+ from nexaai.runtime_error import ContextLengthExceededError, GenerationError
12
+
13
+ # Error codes from ml.h
14
+ ML_SUCCESS = 0
15
+ ML_ERROR_LLM_TOKENIZATION_CONTEXT_LENGTH = -200004
11
16
 
12
17
 
13
18
  class PyBindVLMImpl(VLM):
@@ -91,7 +96,8 @@ class PyBindVLMImpl(VLM):
91
96
  def apply_chat_template(
92
97
  self,
93
98
  messages: List[MultiModalMessage],
94
- tools: Optional[List[Dict[str, Any]]] = None
99
+ tools: Optional[List[Dict[str, Any]]] = None,
100
+ enable_thinking: bool = True
95
101
  ) -> str:
96
102
  """Apply the chat template to multimodal messages."""
97
103
  payload = []
@@ -111,7 +117,7 @@ class PyBindVLMImpl(VLM):
111
117
 
112
118
  payload.append({"role": role, "content": blocks})
113
119
 
114
- result = vlm_bind.ml_vlm_apply_chat_template(self._handle, payload, tools)
120
+ result = vlm_bind.ml_vlm_apply_chat_template(self._handle, payload, tools, enable_thinking)
115
121
  return result
116
122
 
117
123
  def generate_stream(self, prompt: str, g_cfg: GenerationConfig = GenerationConfig()) -> Generator[str, None, None]:
@@ -143,6 +149,18 @@ class PyBindVLMImpl(VLM):
143
149
  on_token=on_token,
144
150
  user_data=None
145
151
  )
152
+
153
+ # Check for errors in result
154
+ error_code = result.get("error_code", ML_SUCCESS)
155
+ if error_code != ML_SUCCESS:
156
+ error_message = result.get("error_message", "Unknown error")
157
+ if error_code == ML_ERROR_LLM_TOKENIZATION_CONTEXT_LENGTH:
158
+ exception_container[0] = ContextLengthExceededError(error_message, error_code)
159
+ else:
160
+ exception_container[0] = GenerationError(error_message, error_code)
161
+ token_queue.put(('end', None))
162
+ return
163
+
146
164
  self._profiling_data = ProfilingData.from_dict(result.get("profile_data", {}))
147
165
  except Exception as e:
148
166
  exception_container[0] = e
@@ -186,6 +204,15 @@ class PyBindVLMImpl(VLM):
186
204
  user_data=None
187
205
  )
188
206
 
207
+ # Check for errors in result
208
+ error_code = result.get("error_code", ML_SUCCESS)
209
+ if error_code != ML_SUCCESS:
210
+ error_message = result.get("error_message", "Unknown error")
211
+ if error_code == ML_ERROR_LLM_TOKENIZATION_CONTEXT_LENGTH:
212
+ raise ContextLengthExceededError(error_message, error_code)
213
+ else:
214
+ raise GenerationError(error_message, error_code)
215
+
189
216
  self._profiling_data = ProfilingData.from_dict(result.get("profile_data", {}))
190
217
  return result.get("text", "")
191
218
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nexaai
3
- Version: 1.0.19rc19
3
+ Version: 1.0.21rc1
4
4
  Summary: Python bindings for NexaSDK C-lib backend
5
5
  Author-email: "Nexa AI, Inc." <dev@nexa.ai>
6
6
  Project-URL: Homepage, https://github.com/NexaAI/nexasdk-bridge
@@ -19,7 +19,7 @@ Requires-Dist: numpy
19
19
  Requires-Dist: httpx
20
20
  Provides-Extra: mlx
21
21
  Requires-Dist: mlx; extra == "mlx"
22
- Requires-Dist: mlx-lm; extra == "mlx"
22
+ Requires-Dist: mlx-lm==0.27.0; extra == "mlx"
23
23
  Requires-Dist: mlx-vlm; extra == "mlx"
24
24
  Requires-Dist: mlx-embeddings; extra == "mlx"
25
25
  Requires-Dist: tokenizers; extra == "mlx"
@@ -1,6 +1,6 @@
1
- nexaai/__init__.py,sha256=mbzzeXrEHHI_E3BQ0_OukD9wNajKJJVk0ykxT0rz8uM,2267
2
- nexaai/_stub.cp310-win_amd64.pyd,sha256=oBsyAojVBnmWvTxsQwqjvKwHuXXVwViAcaJ0UOU9gl4,10752
3
- nexaai/_version.py,sha256=ly1OAJ4Z8m8oUF6yqhQJ-skQN0goQcrzdf_W4s3nFMc,148
1
+ nexaai/__init__.py,sha256=Yt2YPVcRfwdA6DQoUR4ZI34CHBUYoY2cVsrG7Zp6IrI,2516
2
+ nexaai/_stub.cp310-win_amd64.pyd,sha256=wlEBCN5E8QuK2OoupinLzjTYqPdSdtTOrOmgkwrd9T0,10752
3
+ nexaai/_version.py,sha256=RJD43EAWJ7pU1bQt-f7S--4-GPeOQxjr-rdudgziXbA,147
4
4
  nexaai/asr.py,sha256=_fsGaxpiU137bUtO5ujtFSYCI1RLsyeEm3Gf4GhHVRk,2118
5
5
  nexaai/base.py,sha256=qQBCiQVNzgpkQjZX9aiFDEdbAAe56TROKC3WnWra2Zg,1021
6
6
  nexaai/common.py,sha256=muQqFY-WllwL5IO83tImexbuUcoEQsKg73u4gWL2lNs,3548
@@ -11,37 +11,38 @@ nexaai/llm.py,sha256=Qwm1q_NStLfD-JYZQIvxniWnAmwNl1V6LUON3Me7w_I,3663
11
11
  nexaai/log.py,sha256=F_Qe169kLbnFV25WJmS_ZtmBfOdcGic8BYFIsYVoD_o,2720
12
12
  nexaai/rerank.py,sha256=_zGWmX6eDigY2kViMKCtNssp4JMEeVycZZfJH9eAZOY,1927
13
13
  nexaai/runtime.py,sha256=_BoAtTUv5ZR7wtOlJL5TldR3AZTP0OnMWjB9p71k-8E,2135
14
+ nexaai/runtime_error.py,sha256=7TvjMJO7MpvVRQCYEDwcFPOgZsIILQtN-ZJ74JlARrE,803
14
15
  nexaai/tts.py,sha256=afs6sx0w0Tvs_aJlyZRPm62qQpTrs-fW_jDHrMkc4AA,2241
15
- nexaai/vlm.py,sha256=wUMbRURluxvULbS7vgyHsWdEPgLGrrC_S79bhdEN7Vg,4860
16
+ nexaai/vlm.py,sha256=e-IMTiyCkP1vvrVHn98quyJoISGQzVf6UETSQ3lHudo,4899
16
17
  nexaai/asr_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
18
  nexaai/asr_impl/mlx_asr_impl.py,sha256=XwMX3LYMeulp8cDS0TCCYcjvttFHAyDWQ_oMvABwQmI,3349
18
19
  nexaai/asr_impl/pybind_asr_impl.py,sha256=20o5SOPzhF9x41ra8L_qIM7YxCkYeLb5csSrNde-dds,1560
19
20
  nexaai/binds/__init__.py,sha256=ENl-uoIF9-3XGIXitVgZ2QmJ6p7Yet4h1-X7nUDZ0Hk,108
20
- nexaai/binds/common_bind.cp310-win_amd64.pyd,sha256=wwXQwxZCPVidbGyC28hcwbp8XilXFjco4X3FkCSEKfg,205824
21
- nexaai/binds/embedder_bind.cp310-win_amd64.pyd,sha256=URVof-RRuK7OHISj2Qcrnr5Beo_J1CiMYqZNTY3ZT7I,182784
21
+ nexaai/binds/common_bind.cp310-win_amd64.pyd,sha256=A7AuP8TpdE1O0jSRYSX0PmV0s8zXmrr_KcTXY93oa1I,205824
22
+ nexaai/binds/embedder_bind.cp310-win_amd64.pyd,sha256=bpk2lKSKLZPCNn97GdS72UIR7x5V0aWS_Ft6jxU5cWY,182784
22
23
  nexaai/binds/libcrypto-3-x64.dll,sha256=X7hDuQPMn6eRe58dTGJxTmRPKFWgd5i6Gjoy9QPLmPg,7315968
23
24
  nexaai/binds/libssl-3-x64.dll,sha256=GRw0cOaGUaR2QHRvBFuU_9S9iNgkyVgm0NIpZMnReAw,1313792
24
- nexaai/binds/llm_bind.cp310-win_amd64.pyd,sha256=IYdme70wPZFFHHIGUsbi6hiBHJZz0H478C1pBfkWXDg,162816
25
- nexaai/binds/nexa_bridge.dll,sha256=TdDzK71xKW_rE0Qvxnr1M05QsbXL7IuCCuu4WkS9WQU,187904
26
- nexaai/binds/vlm_bind.cp310-win_amd64.pyd,sha256=eemVZdUWNdjN42msYJDsPCq3IBvdmpg5vxiQUx854HA,168960
27
- nexaai/binds/cpu_gpu/ggml-base.dll,sha256=er-uYRvlG9B8b5ZZ3RBKf7mS97U5LSN51VZy-oNKS8o,532480
28
- nexaai/binds/cpu_gpu/ggml-cpu.dll,sha256=vzcRC3K4i4WnfStrM3Rt0-_DQ3nl3P3OvNyW7DTEz2U,672768
29
- nexaai/binds/cpu_gpu/ggml-cuda.dll,sha256=R4KEMvK_m47c5WO1SiYUO_FuRDZ5b5SAjxoiP_5n8jo,313528832
30
- nexaai/binds/cpu_gpu/ggml-vulkan.dll,sha256=3IP-XdGWuojTGCucHQ_erpWmFuJwadbU6DJsPPHZ_KY,36627968
31
- nexaai/binds/cpu_gpu/ggml.dll,sha256=3h0Vykj3K7IYLEAXE9cKzJShhmw4psKZmNTLNxXbItI,66560
32
- nexaai/binds/cpu_gpu/mtmd.dll,sha256=F5Y9ZdVaxKO7GnMMK5YrvhxVgVDNb85za14PxU3vvcE,561152
33
- nexaai/binds/cpu_gpu/nexa_cpu_gpu.dll,sha256=DOc_ROdv-CMly-Zw9DN-JltYBjYinkXF44kETdWzjp0,1611776
34
- nexaai/binds/cpu_gpu/nexa_plugin.dll,sha256=bcvp3FmhT8RXbbYuwDJ3UaNeg95oMF9KTFo1152sbIY,1411072
35
- nexaai/binds/nexaml/ggml-base.dll,sha256=er-uYRvlG9B8b5ZZ3RBKf7mS97U5LSN51VZy-oNKS8o,532480
36
- nexaai/binds/nexaml/ggml-cpu.dll,sha256=vzcRC3K4i4WnfStrM3Rt0-_DQ3nl3P3OvNyW7DTEz2U,672768
37
- nexaai/binds/nexaml/ggml-cuda.dll,sha256=R4KEMvK_m47c5WO1SiYUO_FuRDZ5b5SAjxoiP_5n8jo,313528832
38
- nexaai/binds/nexaml/ggml-vulkan.dll,sha256=3IP-XdGWuojTGCucHQ_erpWmFuJwadbU6DJsPPHZ_KY,36627968
39
- nexaai/binds/nexaml/ggml.dll,sha256=3h0Vykj3K7IYLEAXE9cKzJShhmw4psKZmNTLNxXbItI,66560
25
+ nexaai/binds/llm_bind.cp310-win_amd64.pyd,sha256=7isvwd_kZYtGAmc9O6u67KPr0RQbTpreASOcTjcVqo8,162816
26
+ nexaai/binds/nexa_bridge.dll,sha256=YrnvRvUw4aDoPSEYrOEUMia-FKbGTz88C-CN_jQNwWg,187904
27
+ nexaai/binds/vlm_bind.cp310-win_amd64.pyd,sha256=WcCrXej3pFt7JDr0VbeW_c8_Y5dPAt8n4THD2qf6JSo,170496
28
+ nexaai/binds/cpu_gpu/ggml-base.dll,sha256=h8m2MYmzg2syDaGLGvfogWbi88ZlA7e_ZnL79hDFwgE,532480
29
+ nexaai/binds/cpu_gpu/ggml-cpu.dll,sha256=fMHSkx2QYWUNC63l0tgO6F94Bb4kcQE3sH70ptnH9DQ,672768
30
+ nexaai/binds/cpu_gpu/ggml-cuda.dll,sha256=q4-dtifsuifcuRZn4St-5gJpiEA1hKE2ld1VEqkkqUk,313528832
31
+ nexaai/binds/cpu_gpu/ggml-vulkan.dll,sha256=_z41BQzz1Ud1w5UEoMiJmEGNE-ybxJKYKN1ssagdKGg,36627968
32
+ nexaai/binds/cpu_gpu/ggml.dll,sha256=_3ejjzy1owBjJAS8dGMmQBWBLAkhs1BRyo0qfT-jGkg,66560
33
+ nexaai/binds/cpu_gpu/mtmd.dll,sha256=XQKiNXM34-Cj27vrLTuH5I3KBdCN1gAgp6eTz7eYF-g,561152
34
+ nexaai/binds/cpu_gpu/nexa_cpu_gpu.dll,sha256=Gf9C8LiOUuM9QYNKd1jgCcgsfyT0ymFJ4ebHPib8Q24,1611776
35
+ nexaai/binds/cpu_gpu/nexa_plugin.dll,sha256=pBNvjvjomppglDJIQ3rnzzr2gJT3b-TqdEBe2sr3Az8,1411072
36
+ nexaai/binds/nexaml/ggml-base.dll,sha256=h8m2MYmzg2syDaGLGvfogWbi88ZlA7e_ZnL79hDFwgE,532480
37
+ nexaai/binds/nexaml/ggml-cpu.dll,sha256=fMHSkx2QYWUNC63l0tgO6F94Bb4kcQE3sH70ptnH9DQ,672768
38
+ nexaai/binds/nexaml/ggml-cuda.dll,sha256=q4-dtifsuifcuRZn4St-5gJpiEA1hKE2ld1VEqkkqUk,313528832
39
+ nexaai/binds/nexaml/ggml-vulkan.dll,sha256=_z41BQzz1Ud1w5UEoMiJmEGNE-ybxJKYKN1ssagdKGg,36627968
40
+ nexaai/binds/nexaml/ggml.dll,sha256=_3ejjzy1owBjJAS8dGMmQBWBLAkhs1BRyo0qfT-jGkg,66560
40
41
  nexaai/binds/nexaml/nexa-mm-process.dll,sha256=DDD5qPbelZAIrRWGggOd3Pg9U_fh_ZEYIplwqiyD5LY,4643328
41
42
  nexaai/binds/nexaml/nexa-sampling.dll,sha256=Notkz287laSUG2_ED3oFXWVLJM3t7x_USkvX6wKVOLA,4265984
42
- nexaai/binds/nexaml/nexa_plugin.dll,sha256=6FUKlvQwcyEuFLIzL5KsVDvquDKjICFhIz4bAwOHLiU,600576
43
- nexaai/binds/nexaml/nexaproc.dll,sha256=cVU4ngSdsQ0MttqOv5IUZhmUE8lZLq-OjC8ueaAsx1s,2668544
44
- nexaai/binds/nexaml/qwen3-vl.dll,sha256=say_RLwLsIq_svPlgqPl12gfrOCQtcCiwa_q91Ql7YM,5873152
43
+ nexaai/binds/nexaml/nexa_plugin.dll,sha256=8XyOTP11koqdTaKUEgxFm2Fwl9v_O4GDgg040yw5F5g,601600
44
+ nexaai/binds/nexaml/nexaproc.dll,sha256=rRcdSfhkxnRwktXW4lp7Np8sNY_uefNXYwAmPp34AHg,2670080
45
+ nexaai/binds/nexaml/qwen3-vl.dll,sha256=KxwQ0PHvzM1zwLpH7vlNOlfaVzgEUHTfTV76e61KeyA,5873664
45
46
  nexaai/binds/nexaml/qwen3vl-vision.dll,sha256=5AX4MtAOWTcXSAkS2qqvl2pFti4HR55dtkCaOO03Evc,1063424
46
47
  nexaai/cv_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
48
  nexaai/cv_impl/mlx_cv_impl.py,sha256=QLd_8w90gtxH8kmssaDYatCTRvQNIJuUGKZNnYrmx6E,3317
@@ -68,9 +69,9 @@ nexaai/utils/model_types.py,sha256=q2m7diYLOpLvRl1ixL2eMq5_kdTj8KqPBGWX4p6Ob08,1
68
69
  nexaai/utils/progress_tracker.py,sha256=BztrFqtjwNUmeREwZ5m7H6ZcrVzQEbpZfsxndWh4z0A,15778
69
70
  nexaai/utils/quantization_utils.py,sha256=FxnZ6-uAE_bl_vQ5jsRXlpU0NBn-U4Y8iN9_O6aCdPA,8070
70
71
  nexaai/vlm_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
- nexaai/vlm_impl/mlx_vlm_impl.py,sha256=MgqJO7OzuPd79gOZZKhSXXMNSP2eBuhhrdCX8XHn6aQ,11090
72
- nexaai/vlm_impl/pybind_vlm_impl.py,sha256=NuQ_Ep1TnjmGAkjJuUS0Lb6z7iPu3wroLVOx7kiAwlE,8827
73
- nexaai-1.0.19rc19.dist-info/METADATA,sha256=2-hG8alVSHrKOSLulm6sVIUyyegHYxvYcQ-6YkZhDO8,1234
74
- nexaai-1.0.19rc19.dist-info/WHEEL,sha256=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
75
- nexaai-1.0.19rc19.dist-info/top_level.txt,sha256=LRE2YERlrZk2vfuygnSzsEeqSknnZbz3Z1MHyNmBU4w,7
76
- nexaai-1.0.19rc19.dist-info/RECORD,,
72
+ nexaai/vlm_impl/mlx_vlm_impl.py,sha256=gI09QJcok68QG-36csXr3c2yPCZXTE0dlq1MUBEo_Ms,11091
73
+ nexaai/vlm_impl/pybind_vlm_impl.py,sha256=4qPt5C5m4y4kWD9EFfVbcAkMq2Dgd5EP9tYo6yZIxgo,10162
74
+ nexaai-1.0.21rc1.dist-info/METADATA,sha256=ZWD3yi3ygRwzzLE5gkFx3V1hXnejEJH9Fm5zkX6Yo4I,1241
75
+ nexaai-1.0.21rc1.dist-info/WHEEL,sha256=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
76
+ nexaai-1.0.21rc1.dist-info/top_level.txt,sha256=LRE2YERlrZk2vfuygnSzsEeqSknnZbz3Z1MHyNmBU4w,7
77
+ nexaai-1.0.21rc1.dist-info/RECORD,,