nexaai 1.0.16rc11__cp310-cp310-macosx_13_0_x86_64.whl → 1.0.16rc12__cp310-cp310-macosx_13_0_x86_64.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
@@ -21,6 +21,9 @@ except ImportError:
21
21
  # Import common configuration classes first (no external dependencies)
22
22
  from .common import ModelConfig, GenerationConfig, ChatMessage, SamplerConfig, PluginID
23
23
 
24
+ # Import logging functionality
25
+ from .log import set_logger, get_error_message
26
+
24
27
  # Create alias for PluginID to be accessible as plugin_id
25
28
  plugin_id = PluginID
26
29
 
@@ -45,6 +48,10 @@ __all__ = [
45
48
  "EmbeddingConfig",
46
49
  "PluginID",
47
50
  "plugin_id",
51
+
52
+ # Logging functionality
53
+ "set_logger",
54
+ "get_error_message",
48
55
 
49
56
  "LLM",
50
57
  "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.16-rc11"
4
+ __version__ = "1.0.16-rc12"
Binary file
Binary file
nexaai/log.py ADDED
@@ -0,0 +1,92 @@
1
+ """
2
+ Logging configuration for NexaAI bridge.
3
+
4
+ This module provides a minimal API to configure bridge-wide logging
5
+ to route into Python's logging system.
6
+ """
7
+
8
+ import logging
9
+ import threading
10
+ from enum import IntEnum
11
+ from typing import Optional
12
+
13
+ from nexaai.binds import common_bind
14
+ from nexaai.runtime import is_initialized
15
+
16
+
17
+ class LogLevel(IntEnum):
18
+ """Log levels matching ml_LogLevel from ml.h"""
19
+ TRACE = 0
20
+ DEBUG = 1
21
+ INFO = 2
22
+ WARN = 3
23
+ ERROR = 4
24
+
25
+
26
+ # Module-level state
27
+ _config_lock = threading.Lock()
28
+ _current_logger: Optional[logging.Logger] = None
29
+
30
+
31
+ def set_logger(logger: Optional[logging.Logger] = None, *, strict: bool = True) -> None:
32
+ """
33
+ Set the process-wide bridge logger.
34
+
35
+ Args:
36
+ logger: Python logger to receive bridge logs. If None, uses "nexaai.ml" logger.
37
+ strict: If True, raises if called after runtime initialization.
38
+ If False, attempts to set anyway (best-effort).
39
+
40
+ Raises:
41
+ RuntimeError: If strict=True and runtime is already initialized.
42
+ """
43
+ global _current_logger
44
+
45
+ with _config_lock:
46
+ # Check initialization state if strict mode
47
+ if strict and is_initialized():
48
+ raise RuntimeError(
49
+ "Cannot configure logging after runtime initialization. "
50
+ "Call set_logger() before creating any models, or use strict=False for best-effort."
51
+ )
52
+
53
+ # Use default logger if none provided
54
+ if logger is None:
55
+ logger = logging.getLogger("nexaai.ml")
56
+
57
+ _current_logger = logger
58
+
59
+ # Set the C callback
60
+ common_bind.ml_set_log(_log_callback)
61
+
62
+
63
+ def _log_callback(level: int, message: str) -> None:
64
+ """Internal callback that forwards bridge logs to Python logger."""
65
+ if _current_logger is None:
66
+ return
67
+
68
+ # Map bridge log levels to Python logging levels
69
+ if level == LogLevel.TRACE or level == LogLevel.DEBUG:
70
+ _current_logger.debug(message)
71
+ elif level == LogLevel.INFO:
72
+ _current_logger.info(message)
73
+ elif level == LogLevel.WARN:
74
+ _current_logger.warning(message)
75
+ elif level == LogLevel.ERROR:
76
+ _current_logger.error(message)
77
+ else:
78
+ # Fallback for unknown levels
79
+ _current_logger.info(f"[Level {level}] {message}")
80
+
81
+
82
+ def get_error_message(error_code: int) -> str:
83
+ """
84
+ Get error message string for error code.
85
+
86
+ Args:
87
+ error_code: ML error code (typically negative)
88
+
89
+ Returns:
90
+ Human-readable error message
91
+ """
92
+ return common_bind.ml_get_error_message(error_code)
nexaai/runtime.py CHANGED
@@ -28,6 +28,10 @@ def _shutdown_runtime() -> None:
28
28
  # Public helper so advanced users can reclaim memory on demand
29
29
  shutdown = _shutdown_runtime
30
30
 
31
+ def is_initialized() -> bool:
32
+ """Check if the runtime has been initialized."""
33
+ return _runtime_alive
34
+
31
35
  # ----------------------------------------------------------------------
32
36
  # Single public class
33
37
  # ----------------------------------------------------------------------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nexaai
3
- Version: 1.0.16rc11
3
+ Version: 1.0.16rc12
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
- nexaai/__init__.py,sha256=jXdC4vv6DBK1fVewYTYSUhOOYfvf_Mk81UIeMGGIKUg,2029
2
- nexaai/_stub.cpython-310-darwin.so,sha256=knZxZuqq6tr1Pbw7fOWnprCy0DizSaxwTGuexo-fgps,49832
3
- nexaai/_version.py,sha256=f7rjwo4Z-jPnRW2BO8DA1Z8FCkrghe6e-uQJVLsIGLE,144
1
+ nexaai/__init__.py,sha256=L8oB7GFZZMGnUpCg0PecDbI_ycKuQak-ZEJ4Y12_QIw,2184
2
+ nexaai/_stub.cpython-310-darwin.so,sha256=mcdyeHnyEkUqqNOIS9CecUp30uQ-bZva0qiv3Tv43tU,49832
3
+ nexaai/_version.py,sha256=VcEloSyZAF14s_ZLUSzu8vLdcbhwdSK1deBNqQktuqA,144
4
4
  nexaai/asr.py,sha256=NljMXDErwPNMOPaRkJZMEDka9Nk8xyur7L8i924TStY,2054
5
5
  nexaai/base.py,sha256=N8PRgDFA-XPku2vWnQIofQ7ipz3pPlO6f8YZGnuhquE,982
6
6
  nexaai/common.py,sha256=yBnIbqYaQYnfrl7IczOBh6MDibYZVxwaRJEglYcKgGs,3422
@@ -8,18 +8,19 @@ nexaai/cv.py,sha256=RHCDo8gvBH8BkGZx7qVyp-OKxqi7E1GG9XzyaXehCNA,3273
8
8
  nexaai/embedder.py,sha256=Cw0tSHkPgd-RI62afCqQAcTHMnQhaI2CvfTMO-1JKOg,2452
9
9
  nexaai/image_gen.py,sha256=0C_5Tjj4BYmxLbmMmvwajp-yy2mmEEOKwBFnDQNPzx4,4356
10
10
  nexaai/llm.py,sha256=S1o_k2VQoF5w2wO25f142OO1R75TP89Ii69VZv8pIGo,3567
11
+ nexaai/log.py,sha256=Kwo2CIfWN6iP4M4F5EUIV8KIO5hAsvz6HZAaOwJ27Og,2628
11
12
  nexaai/rerank.py,sha256=vWaBucoQ1wz-2iYnZqyFIcEjm-4Xcs1KDbFN5X8zzDQ,1872
12
- nexaai/runtime.py,sha256=mxxHYsb5iBUAm2K_u-XJWr_U-spJ9S4eApc8kf9myjw,1957
13
+ nexaai/runtime.py,sha256=JvllhlNPgYGLbgGyX2yNvmGzT0lZ5XbvTvEo8sZG_Ho,2067
13
14
  nexaai/tts.py,sha256=ZnBpWUxIfHhh7KfEjddtH7hHOTa91zg7ogGLakMIALo,2167
14
15
  nexaai/vlm.py,sha256=OCxwML-Z5uVGp3fjzJVtbCxfTLpgxkhQ8Wo6MVysoiw,4733
15
16
  nexaai/asr_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
17
  nexaai/asr_impl/mlx_asr_impl.py,sha256=eosd8-TIWAOwV0HltmoFrLwzXHcU4jyxtncvuZE9pgA,3257
17
18
  nexaai/asr_impl/pybind_asr_impl.py,sha256=pE9Hb_hMi5yAc4MF83bLVOb8zDtreCkB3_u7XED9YpA,1516
18
19
  nexaai/binds/__init__.py,sha256=eYuay_8DDXeOUWz2_R9HFSabohxs6hvZn391t2L0Po0,104
19
- nexaai/binds/common_bind.cpython-310-darwin.so,sha256=KX_nfaQQPzxGv0GS0efcO-ByWai7y7RskMZvSAAaJWI,233960
20
+ nexaai/binds/common_bind.cpython-310-darwin.so,sha256=km1TU5WOJHVjvyM4l5mgAkS_omxuKt8pM92E9Wv0VqM,235488
20
21
  nexaai/binds/embedder_bind.cpython-310-darwin.so,sha256=b2NoXFAJvPLi_P1X7lXLKmAUU0v2HJI3Zwa10gfqHdw,202032
21
- nexaai/binds/libnexa_bridge.dylib,sha256=h9Xwbcu_ZqQEw5n_OesrY4PGEDfVTmaANosGaUUYKh8,250376
22
- nexaai/binds/llm_bind.cpython-310-darwin.so,sha256=aKcT2kW1PL1xPFX7vsT6Gs79ZydcVfg8bKtnEthRpI4,183008
22
+ nexaai/binds/libnexa_bridge.dylib,sha256=4zWaD6S2M5Kd6uVy25nelyuAkfQUImZRHJPBPCfJTys,250408
23
+ nexaai/binds/llm_bind.cpython-310-darwin.so,sha256=p1ZTGMolEkWywkmwzOUjTr3RpSEH21BHZAggVzo89Ks,183088
23
24
  nexaai/binds/vlm_bind.cpython-310-darwin.so,sha256=LGd-tykePnQFfGca25HnPIBfXsfrMzbwyx6d5Ld3xps,183000
24
25
  nexaai/binds/nexa_llama_cpp/libggml-base.dylib,sha256=GyOkHOM-5uHp7NUZ4Sr9BWak6BYpcc9aqI9A-zPnQp4,629528
25
26
  nexaai/binds/nexa_llama_cpp/libggml-cpu.so,sha256=cnLUQ7WdX-5iiDaH8v45u1kX1NUmK8DanpzSMGCpXPE,1039800
@@ -27,7 +28,7 @@ nexaai/binds/nexa_llama_cpp/libggml-metal.so,sha256=Xhhl_tLg1xmCIQVrKjqPFaLHAlx_
27
28
  nexaai/binds/nexa_llama_cpp/libggml.dylib,sha256=12Q1Z98oM81hxzT_GMQsW5rlhC8DOMsX6luWVCFQHcI,58336
28
29
  nexaai/binds/nexa_llama_cpp/libllama.dylib,sha256=ORoTILXdGGX6MLMh-IWLIp4P5UEPOjE4lvWOKM18pCk,1982280
29
30
  nexaai/binds/nexa_llama_cpp/libmtmd.dylib,sha256=1plWvthTQf8IXbXthMG0MZXzWhbzV6ghdVzVFIb1FnU,701504
30
- nexaai/binds/nexa_llama_cpp/libnexa_plugin.dylib,sha256=1fhFzoJzs4lKjVLn7qPu_n2awlAFlw3iFEog8Lpaz2c,2025496
31
+ nexaai/binds/nexa_llama_cpp/libnexa_plugin.dylib,sha256=VYNzHCTPqE1Mhx9VnnfhpA1PWjYaXsmn1XcBu9K9zOw,2042784
31
32
  nexaai/cv_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
33
  nexaai/cv_impl/mlx_cv_impl.py,sha256=gKECQOv8iaWwG3bl7xeqVy2NN_9K7tYerIFzfn4eLo4,3228
33
34
  nexaai/cv_impl/pybind_cv_impl.py,sha256=uSmwBste4cT7c8DQmXzRLmzwDf773PAbXNYWW1UzVls,1064
@@ -387,7 +388,7 @@ nexaai/utils/quantization_utils.py,sha256=4gvp6UQfSO9G1FYBwnFtQspTzH9sDbi1PBXw2t
387
388
  nexaai/vlm_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
388
389
  nexaai/vlm_impl/mlx_vlm_impl.py,sha256=pLtWm_ckz8a0U-AtAOMVseFDO4OVPvHyYO2KlfBaGYk,10833
389
390
  nexaai/vlm_impl/pybind_vlm_impl.py,sha256=FAbhpRJzHgI78r0mUvKybO97R1szvNhH0aTn_I52oT4,8597
390
- nexaai-1.0.16rc11.dist-info/METADATA,sha256=ZBygPzSF5yfMU8SgBMTS8HmrlM4Rx_vAwQsoX8rZIks,1202
391
- nexaai-1.0.16rc11.dist-info/WHEEL,sha256=0KYp5feZ1CMUhsfFXKpSQTbSmQbXy4mv6yPPVBXg2EM,110
392
- nexaai-1.0.16rc11.dist-info/top_level.txt,sha256=LRE2YERlrZk2vfuygnSzsEeqSknnZbz3Z1MHyNmBU4w,7
393
- nexaai-1.0.16rc11.dist-info/RECORD,,
391
+ nexaai-1.0.16rc12.dist-info/METADATA,sha256=a6Oh67bHm9t2m1j9yPHyou4gx0YOJjag7YLhJYyjRxc,1202
392
+ nexaai-1.0.16rc12.dist-info/WHEEL,sha256=0KYp5feZ1CMUhsfFXKpSQTbSmQbXy4mv6yPPVBXg2EM,110
393
+ nexaai-1.0.16rc12.dist-info/top_level.txt,sha256=LRE2YERlrZk2vfuygnSzsEeqSknnZbz3Z1MHyNmBU4w,7
394
+ nexaai-1.0.16rc12.dist-info/RECORD,,