nexaai 1.0.12rc1__cp310-cp310-win_amd64.whl → 1.0.13rc1__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.

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.12-rc1"
4
+ __version__ = "1.0.13-rc1"
nexaai/binds/__init__.py CHANGED
@@ -1,3 +1,4 @@
1
1
  from .common_bind import *
2
2
  from .llm_bind import *
3
3
  from .embedder_bind import *
4
+ from .vlm_bind import *
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1124,15 +1124,64 @@ def download_from_huggingface(
1124
1124
  ##########################################################################
1125
1125
 
1126
1126
 
1127
+ def _download_model_if_needed(
1128
+ model_path: str,
1129
+ param_name: str,
1130
+ progress_callback: Optional[Callable[[Dict[str, Any]], None]] = None,
1131
+ token: Union[bool, str, None] = None
1132
+ ) -> str:
1133
+ """
1134
+ Helper function to download a model from HuggingFace if it doesn't exist locally.
1135
+
1136
+ Args:
1137
+ model_path: The model path that may be local or remote
1138
+ param_name: Name of the parameter (for error messages)
1139
+ progress_callback: Callback function for download progress updates
1140
+ token: HuggingFace authentication token for private repositories
1141
+
1142
+ Returns:
1143
+ str: Local path to the model (either existing or downloaded)
1144
+
1145
+ Raises:
1146
+ RuntimeError: If download fails
1147
+ """
1148
+ # Check if model_path exists locally (file or directory)
1149
+ if os.path.exists(model_path):
1150
+ # Local path exists, return as-is
1151
+ return model_path
1152
+
1153
+ # Model path doesn't exist locally, try to download from HuggingFace
1154
+ try:
1155
+ # Parse model_path to extract repo_id and filename
1156
+ repo_id, file_name = _parse_model_path(model_path)
1157
+
1158
+ # Download the model
1159
+ downloaded_path = download_from_huggingface(
1160
+ repo_id=repo_id,
1161
+ file_name=file_name,
1162
+ local_dir=None, # Use default cache directory
1163
+ enable_transfer=True,
1164
+ progress_callback=progress_callback,
1165
+ show_progress=True,
1166
+ token=token
1167
+ )
1168
+
1169
+ return downloaded_path
1170
+
1171
+ except Exception as e:
1172
+ # Only handle download-related errors
1173
+ raise RuntimeError(f"Could not load model from '{param_name}={model_path}': {e}")
1174
+
1175
+
1127
1176
  def auto_download_model(func: Callable) -> Callable:
1128
1177
  """
1129
1178
  Decorator that automatically downloads models from HuggingFace if they don't exist locally.
1130
1179
 
1131
- This decorator should be applied to __init__ methods that take a name_or_path parameter.
1132
- If name_or_path doesn't exist as a local file/directory, it will attempt to download
1133
- it from HuggingFace Hub using the download_from_huggingface function.
1180
+ This decorator should be applied to __init__ methods that take a name_or_path parameter
1181
+ and optionally an mmproj_path parameter. If these paths don't exist as local files/directories,
1182
+ it will attempt to download them from HuggingFace Hub using the download_from_huggingface function.
1134
1183
 
1135
- The name_or_path can be in formats like:
1184
+ The name_or_path and mmproj_path can be in formats like:
1136
1185
  - "microsoft/DialoGPT-small" (downloads entire repo)
1137
1186
  - "microsoft/DialoGPT-small/pytorch_model.bin" (downloads specific file)
1138
1187
  - "Qwen/Qwen3-4B-GGUF/Qwen3-4B-Q4_K_M.gguf" (downloads specific file)
@@ -1149,21 +1198,6 @@ def auto_download_model(func: Callable) -> Callable:
1149
1198
  """
1150
1199
  @functools.wraps(func)
1151
1200
  def wrapper(*args, **kwargs):
1152
- # Find name_or_path in arguments
1153
- # Assuming name_or_path is the first argument after self
1154
- if len(args) >= 2:
1155
- name_or_path = args[1]
1156
- args_list = list(args)
1157
- path_index = 1
1158
- is_positional = True
1159
- elif 'name_or_path' in kwargs:
1160
- name_or_path = kwargs['name_or_path']
1161
- path_index = None
1162
- is_positional = False
1163
- else:
1164
- # No name_or_path found, call original function
1165
- return func(*args, **kwargs)
1166
-
1167
1201
  # Extract progress_callback and token from arguments
1168
1202
  progress_callback = None
1169
1203
  if 'progress_callback' in kwargs:
@@ -1173,39 +1207,63 @@ def auto_download_model(func: Callable) -> Callable:
1173
1207
  if 'token' in kwargs:
1174
1208
  token = kwargs.pop('token') # Remove from kwargs to avoid passing to original func
1175
1209
 
1176
- # Check if name_or_path exists locally (file or directory)
1177
- if os.path.exists(name_or_path):
1178
- # Local path exists, use as-is without downloading
1210
+ # Handle name_or_path parameter
1211
+ name_or_path = None
1212
+ name_path_index = None
1213
+ is_name_positional = False
1214
+
1215
+ # Find name_or_path in arguments
1216
+ # Assuming name_or_path is the first argument after self
1217
+ if len(args) >= 2:
1218
+ name_or_path = args[1]
1219
+ args_list = list(args)
1220
+ name_path_index = 1
1221
+ is_name_positional = True
1222
+ elif 'name_or_path' in kwargs:
1223
+ name_or_path = kwargs['name_or_path']
1224
+ is_name_positional = False
1225
+
1226
+ # Handle mmproj_path parameter
1227
+ mmproj_path = None
1228
+ if 'mmproj_path' in kwargs:
1229
+ mmproj_path = kwargs['mmproj_path']
1230
+
1231
+ # If neither parameter is found, call original function
1232
+ if name_or_path is None and mmproj_path is None:
1179
1233
  return func(*args, **kwargs)
1180
1234
 
1181
- # Model path doesn't exist locally, try to download from HuggingFace
1182
- try:
1183
- # Parse name_or_path to extract repo_id and filename
1184
- repo_id, file_name = _parse_model_path(name_or_path)
1185
-
1186
- # Download the model
1187
- downloaded_path = download_from_huggingface(
1188
- repo_id=repo_id,
1189
- file_name=file_name,
1190
- local_dir=None, # Use default cache directory
1191
- enable_transfer=True,
1192
- progress_callback=progress_callback, # Use the extracted callback
1193
- show_progress=True,
1194
- token=token # Use the extracted token
1195
- )
1196
-
1197
- # Replace name_or_path with downloaded path
1198
- if is_positional:
1199
- args_list[path_index] = downloaded_path
1200
- args = tuple(args_list)
1201
- else:
1202
- kwargs['name_or_path'] = downloaded_path
1203
-
1204
- except Exception as e:
1205
- # Only handle download-related errors
1206
- raise RuntimeError(f"Could not load model from '{name_or_path}': {e}")
1235
+ # Download name_or_path if needed
1236
+ if name_or_path is not None:
1237
+ try:
1238
+ downloaded_name_path = _download_model_if_needed(
1239
+ name_or_path, 'name_or_path', progress_callback, token
1240
+ )
1241
+
1242
+ # Replace name_or_path with downloaded path
1243
+ if is_name_positional:
1244
+ if name_path_index is not None:
1245
+ args_list[name_path_index] = downloaded_name_path
1246
+ args = tuple(args_list)
1247
+ else:
1248
+ kwargs['name_or_path'] = downloaded_name_path
1249
+
1250
+ except Exception as e:
1251
+ raise e # Re-raise the error from _download_model_if_needed
1252
+
1253
+ # Download mmproj_path if needed
1254
+ if mmproj_path is not None:
1255
+ try:
1256
+ downloaded_mmproj_path = _download_model_if_needed(
1257
+ mmproj_path, 'mmproj_path', progress_callback, token
1258
+ )
1259
+
1260
+ # Replace mmproj_path with downloaded path
1261
+ kwargs['mmproj_path'] = downloaded_mmproj_path
1262
+
1263
+ except Exception as e:
1264
+ raise e # Re-raise the error from _download_model_if_needed
1207
1265
 
1208
- # Call original function with updated path (outside try-catch to let model creation errors bubble up)
1266
+ # Call original function with updated paths (outside try-catch to let model creation errors bubble up)
1209
1267
  return func(*args, **kwargs)
1210
1268
 
1211
1269
  return wrapper
@@ -1,7 +1,6 @@
1
1
  from typing import Generator, Optional, List, Dict, Any, Union
2
2
  import queue
3
3
  import threading
4
- import base64
5
4
  from pathlib import Path
6
5
 
7
6
  from nexaai.common import ModelConfig, GenerationConfig, MultiModalMessage, PluginID
@@ -102,26 +101,16 @@ class PyBindVLMImpl(VLM):
102
101
  t = c["type"]
103
102
  if t == "text":
104
103
  blocks.append({"type": "text", "text": c.get("text","") or ""})
104
+ elif t == "image":
105
+ # Pass through the original structure - let vlm-bind.cpp handle field extraction
106
+ blocks.append(c)
105
107
  else:
106
- # image/audio/video
107
- src = c.get("url") or c.get("path")
108
- if not src:
109
- raise ValueError(f"No url/path for {t}")
110
- # read local file or strip data URI
111
- if Path(src).exists():
112
- raw = Path(src).read_bytes()
113
- b64 = base64.b64encode(raw).decode("ascii")
114
- blocks.append({"type": t, "text": b64})
115
- elif src.startswith("data:"):
116
- b64 = src.split(",",1)[1]
117
- blocks.append({"type": t, "text": b64})
118
- else:
119
- # remote URL
120
- blocks.append({"type": t, "text": src})
108
+ raise ValueError(f"Unsupported content type: {t}. Use 'text' or 'image' to match the golden reference in vlm.cpp")
121
109
 
122
110
  payload.append({"role": role, "content": blocks})
123
111
 
124
- return vlm_bind.ml_vlm_apply_chat_template(self._handle, payload, tools)
112
+ result = vlm_bind.ml_vlm_apply_chat_template(self._handle, payload, tools)
113
+ return result
125
114
 
126
115
  def generate_stream(self, prompt: str, g_cfg: GenerationConfig = GenerationConfig()) -> Generator[str, None, None]:
127
116
  """Generate text with streaming."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nexaai
3
- Version: 1.0.12rc1
3
+ Version: 1.0.13rc1
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
@@ -1,6 +1,6 @@
1
1
  nexaai/__init__.py,sha256=Lt8NU57eTMtWrDYzpFeYR9XtGAPXqizynP83TPU0UW0,2105
2
- nexaai/_stub.cp310-win_amd64.pyd,sha256=l_sOvn0sGZaAzxUURKum8xng89EtFH_aE1lcWv_ZpKA,10752
3
- nexaai/_version.py,sha256=56eZbYiAoFM_PEDgdfRtf4Lkj9WNLYjfs6jyjl979Rs,147
2
+ nexaai/_stub.cp310-win_amd64.pyd,sha256=2kqB_I7bt9IOBZdXuVSl6GeZyklNg_9BsL_GASPecWU,10752
3
+ nexaai/_version.py,sha256=LWPXus8DDROkMfTf423Cv01gb3gMsNaD34NhoyTjtG4,147
4
4
  nexaai/asr.py,sha256=_fsGaxpiU137bUtO5ujtFSYCI1RLsyeEm3Gf4GhHVRk,2118
5
5
  nexaai/base.py,sha256=qQBCiQVNzgpkQjZX9aiFDEdbAAe56TROKC3WnWra2Zg,1021
6
6
  nexaai/common.py,sha256=6keIpdX5XS5us4z79EMoa6RSkVze9SbbXax13IJ9yvs,3525
@@ -15,21 +15,22 @@ nexaai/vlm.py,sha256=STjXCw67ABrHrEll8A2NGiwmfo7MotfYgBh1k1aNxkk,4775
15
15
  nexaai/asr_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  nexaai/asr_impl/mlx_asr_impl.py,sha256=XwMX3LYMeulp8cDS0TCCYcjvttFHAyDWQ_oMvABwQmI,3349
17
17
  nexaai/asr_impl/pybind_asr_impl.py,sha256=20o5SOPzhF9x41ra8L_qIM7YxCkYeLb5csSrNde-dds,1560
18
- nexaai/binds/__init__.py,sha256=tYvy0pFhoY29GstDT5r-oRiPRarPLECvJAkcamJItOg,83
19
- nexaai/binds/common_bind.cp310-win_amd64.pyd,sha256=rWuxRVTVPuakItIeyiXeouD25e4Ekl-niQix_GOriIs,201216
20
- nexaai/binds/embedder_bind.cp310-win_amd64.pyd,sha256=Bz5tKsR7W_ohrsshGq314-ZkfG39H5fs6dH9kJh584A,182784
21
- nexaai/binds/libcrypto-3-x64.dll,sha256=-Lau6pL5DpDXzpg9MED63gCeL8oRrSLI_e2LeaxIHqk,7314432
22
- nexaai/binds/libssl-3-x64.dll,sha256=Tzzyu5jRpUugFxr_65hbFlAtFpjxIDpOYMU1E0ijkJw,1313792
23
- nexaai/binds/llm_bind.cp310-win_amd64.pyd,sha256=Wpm1mEohC6DWlwYuK8BU_PJQoW5tjsarcjXhLFhdSgY,162816
24
- nexaai/binds/nexa_bridge.dll,sha256=UbbvGrUkwFk_tMJeALO5HM7O9rMfJ7xt8YXpB5LheEQ,168448
25
- nexaai/binds/nexa_llama_cpp/ggml-base.dll,sha256=qpJM5qmcne4UqEbsYEBeoDHOe0KyWjqPk-DrKd8TD_k,532480
26
- nexaai/binds/nexa_llama_cpp/ggml-cpu.dll,sha256=lbNh62Q7bW0hB_Dbps8HqUkLMNwh_VOQhT3gOTrpOt4,672768
27
- nexaai/binds/nexa_llama_cpp/ggml-cuda.dll,sha256=Hs_WgTlv9d5MkS2S-hENjwMVX953bhUZtM5959Q7jFs,313528832
28
- nexaai/binds/nexa_llama_cpp/ggml-vulkan.dll,sha256=siZ1qWTIg4LWcOBlwVsdf7mryOIUrhhiMfdITMdH-TM,36627456
29
- nexaai/binds/nexa_llama_cpp/ggml.dll,sha256=sASNHyXx2Kor4O5Ao5X2AhmLZwMg3hdJe2jMSxdJmi0,66560
30
- nexaai/binds/nexa_llama_cpp/llama.dll,sha256=S_SaHxVswdt8LlLazOsLhA72pOoD4d2iba9JKjWGTlg,1611776
31
- nexaai/binds/nexa_llama_cpp/mtmd.dll,sha256=5bAv5F32eaZdlJ_lbwO53Ph3b3c62t14tmZiflkVL8U,561152
32
- nexaai/binds/nexa_llama_cpp/nexa_plugin.dll,sha256=1AruxKWsmmuvod95SwAQaffwbrtm38EZSJT9M2-ngM0,1405440
18
+ nexaai/binds/__init__.py,sha256=ENl-uoIF9-3XGIXitVgZ2QmJ6p7Yet4h1-X7nUDZ0Hk,108
19
+ nexaai/binds/common_bind.cp310-win_amd64.pyd,sha256=GDLsSU0D_XeYgTEtn8Popmk9xRj3NiLfZgAVTr9J53o,201216
20
+ nexaai/binds/embedder_bind.cp310-win_amd64.pyd,sha256=f4DGCuQjCJ8W686QILwqX_o_GD0f0bI0bUepqxkZpHs,182784
21
+ nexaai/binds/libcrypto-3-x64.dll,sha256=PYwJJtM4xpo2IQfxm-of6VR6rtVcHCyodwcvBHmfzig,7315968
22
+ nexaai/binds/libssl-3-x64.dll,sha256=mp_RoRjYcCeAuqMy3QDYvxQ-cjAMUNCuwA320oXVVpg,1313792
23
+ nexaai/binds/llm_bind.cp310-win_amd64.pyd,sha256=syZ7WqdxBZ2kgSWV7Xz4bdCFTjfUneZAxJQp_RK34to,162816
24
+ nexaai/binds/nexa_bridge.dll,sha256=5_ek6-h0kMlHh4P1YtSJxuAx7U51W7bkjd1Lmu5dx9c,168448
25
+ nexaai/binds/vlm_bind.cp310-win_amd64.pyd,sha256=zb0hJz9eKBSpWDeV0wtgF9QaLnz0Q09Glcp7b1LWihc,168960
26
+ nexaai/binds/nexa_llama_cpp/ggml-base.dll,sha256=kKTLxMmbNEAyyIgk_l6W--Apa5a0nGgV1qdICra3C8Q,532480
27
+ nexaai/binds/nexa_llama_cpp/ggml-cpu.dll,sha256=nrgEyUrV6lzyX5XLgCxfSsj9hz_eU0GCRhU906dHx0Q,672768
28
+ nexaai/binds/nexa_llama_cpp/ggml-cuda.dll,sha256=Zw5tuw8RFRSNGvqFavwbxCAUptn9OYNjHn6zLW0Od5s,313528832
29
+ nexaai/binds/nexa_llama_cpp/ggml-vulkan.dll,sha256=fr-akwWSxnZwNYErSB502bWgx-Rgz8ab0gAIwl1_ASw,36627456
30
+ nexaai/binds/nexa_llama_cpp/ggml.dll,sha256=6moSgelf0ORjwM2Uepzs1iF83eEk6RWrTnPLYd6S97g,66560
31
+ nexaai/binds/nexa_llama_cpp/llama.dll,sha256=hHfbJB4MHAG10VN-sAJb3tjnF0ZDsqOVV7iAZU-rq1s,1611776
32
+ nexaai/binds/nexa_llama_cpp/mtmd.dll,sha256=A95Q7TGpEAXrLLQPqBFEAa9NV4n6ww6JOp30G0zb40s,561152
33
+ nexaai/binds/nexa_llama_cpp/nexa_plugin.dll,sha256=GF4O0KEbL2Pv0A23YMgQJ1JG1hsy5aEdZI5voz33oxA,1405440
33
34
  nexaai/cv_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
34
35
  nexaai/cv_impl/mlx_cv_impl.py,sha256=QLd_8w90gtxH8kmssaDYatCTRvQNIJuUGKZNnYrmx6E,3317
35
36
  nexaai/cv_impl/pybind_cv_impl.py,sha256=aSOCAxmHrwJbEkSN6VX3Cykqlj_9RIpVrZXILul04GA,1096
@@ -51,14 +52,14 @@ nexaai/tts_impl/pybind_tts_impl.py,sha256=n3z4zmPQayQJgAwcvETw0IBUCp8IYROuYFSg0t
51
52
  nexaai/utils/avatar_fetcher.py,sha256=D01f8je-37Nd68zGw8MYK2m7y3fvGlC6h0KR-aN9kdU,3925
52
53
  nexaai/utils/decode.py,sha256=0Z9jDH4ICzw4YXj8nD4L-sMouDaev-TISGRQ4KzidWE,421
53
54
  nexaai/utils/manifest_utils.py,sha256=zMgQpf5dAgF2RjGhk73zBggxRDGMRKDGxh2a8m8kmYg,10045
54
- nexaai/utils/model_manager.py,sha256=TmaT1fFculHgfAdutpNXP4d07HIhEMPVTfPvFKE-zR0,51480
55
+ nexaai/utils/model_manager.py,sha256=Gr8PfCHIUVKB1xUQL3WDbi-7hQ5dYey3_w9r42hMWyY,53569
55
56
  nexaai/utils/model_types.py,sha256=arIyb9q-1uG0nyUGdWZaxxDJAxv0cfnJEpjCzyELL5Q,1416
56
57
  nexaai/utils/progress_tracker.py,sha256=BztrFqtjwNUmeREwZ5m7H6ZcrVzQEbpZfsxndWh4z0A,15778
57
58
  nexaai/utils/quantization_utils.py,sha256=jjQaz7K4qH6TdP8Tnv5Ktb2viz8BaVBSOrb_jm3ns28,7889
58
59
  nexaai/vlm_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
60
  nexaai/vlm_impl/mlx_vlm_impl.py,sha256=oY_qb9z_iF0zArBuY5CCYIvZcA3R0i_NKXrr_r-QSgg,10989
60
- nexaai/vlm_impl/pybind_vlm_impl.py,sha256=Hu8g8OXyPn8OzLQOpRSE5lfGmhjChiKj7fMRB8mC_cI,9147
61
- nexaai-1.0.12rc1.dist-info/METADATA,sha256=6sAd6d9nS11AE5aIHCxvqT5MeuRxoYeezwFsQGjsGkg,1233
62
- nexaai-1.0.12rc1.dist-info/WHEEL,sha256=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
63
- nexaai-1.0.12rc1.dist-info/top_level.txt,sha256=LRE2YERlrZk2vfuygnSzsEeqSknnZbz3Z1MHyNmBU4w,7
64
- nexaai-1.0.12rc1.dist-info/RECORD,,
61
+ nexaai/vlm_impl/pybind_vlm_impl.py,sha256=7Bo0kpSrmOdr--bWSpQBvcaexkPPRt3x1yt9e_jIyDs,8686
62
+ nexaai-1.0.13rc1.dist-info/METADATA,sha256=60xKZLiss9_ltNHe6S6o7X-jc2Cbjg5vALDQja6CrXA,1233
63
+ nexaai-1.0.13rc1.dist-info/WHEEL,sha256=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
64
+ nexaai-1.0.13rc1.dist-info/top_level.txt,sha256=LRE2YERlrZk2vfuygnSzsEeqSknnZbz3Z1MHyNmBU4w,7
65
+ nexaai-1.0.13rc1.dist-info/RECORD,,