nexaai 1.0.16rc11__cp310-cp310-macosx_14_0_universal2.whl → 1.0.16rc12__cp310-cp310-macosx_14_0_universal2.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=6-Cum2FTCp9SJUfkSFZji8GUnxR_835-V6_VYrU3lmw,66768
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=bzuFvUH92pOTqDVeEN9Y9ULBe5iQhE5RUgzD_MRDrtE,66768
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=hVxY76tn7hN6uHDIgM7LWNvgoudHgNZVoaygM9X1RWE,217232
20
+ nexaai/binds/common_bind.cpython-310-darwin.so,sha256=ya8gz7NnUtHlniGnRyExdwWfdHimEHiJ7Dry4I7_y44,235264
20
21
  nexaai/binds/embedder_bind.cpython-310-darwin.so,sha256=tPa0c0Dv_GiW66fgmAGWGCHXRGNApznqoQS0eQx9GFM,202064
21
- nexaai/binds/libnexa_bridge.dylib,sha256=Tr5qwX_FgsEBf8xbqtvA1wEj6eChdQLBuzQOChMWydk,251144
22
- nexaai/binds/llm_bind.cpython-310-darwin.so,sha256=6vRO5eOsL6s-hCKdz6onIjBKR_wcpCIsXHtUJY9vJBI,182704
22
+ nexaai/binds/libnexa_bridge.dylib,sha256=y0cv3WWCPmKVyZFSj81BM6-yhzUOfkZWvezu_kfztQc,251192
23
+ nexaai/binds/llm_bind.cpython-310-darwin.so,sha256=TAWfa1Hzq00TjtC1xVsiAeLp6hv2LrL5afDz4omUghc,182784
23
24
  nexaai/binds/vlm_bind.cpython-310-darwin.so,sha256=nd6eG_m2EiPthzkSZ97hlXWUOZQir4cQfFJZ4p6eR2U,182704
24
25
  nexaai/binds/nexa_llama_cpp/libggml-base.dylib,sha256=JM4oOkie1su0ES5hMdtILeQHlRukRzH1vTleTupUXhg,650736
25
26
  nexaai/binds/nexa_llama_cpp/libggml-cpu.so,sha256=qiYxbTe4Nt7n36zJVvq3zovgSZEmrN2is6gzTern7UI,677728
@@ -27,7 +28,7 @@ nexaai/binds/nexa_llama_cpp/libggml-metal.so,sha256=zfaX7rIBYQazH2lf-vza007BMhPT
27
28
  nexaai/binds/nexa_llama_cpp/libggml.dylib,sha256=aOTj_6RrAMkfDO0ZI28_3nfcC-l4Y3dRCiS3C0d0_eI,58592
28
29
  nexaai/binds/nexa_llama_cpp/libllama.dylib,sha256=RkBd5usb8RvEIOamvxCW3UvMauI5bC66G_n6hw83NpY,1786128
29
30
  nexaai/binds/nexa_llama_cpp/libmtmd.dylib,sha256=o6mQqefzQNF0CS4j6odwJKj0gkXm15hIxwlNt88FOn4,605248
30
- nexaai/binds/nexa_llama_cpp/libnexa_plugin.dylib,sha256=4rTxwHGSVUfGnvA6laPpLztMMFooy-inG2798HXqKPY,1862104
31
+ nexaai/binds/nexa_llama_cpp/libnexa_plugin.dylib,sha256=f-ctmVHSL5x1LKLr0StYM5WscvUW_5olJ7al3ciVmmQ,1863000
31
32
  nexaai/binds/nexa_mlx/libnexa_plugin.dylib,sha256=s4oelR1kkFrk0MKL23I0m9Uei4yPf48rzdNvknpjodg,623192
32
33
  nexaai/binds/nexa_mlx/py-lib/ml.py,sha256=DKXVOAfh8cg7KTKljh7jpcPwfQFNigc6uv_ZXF6lse8,23977
33
34
  nexaai/binds/nexa_mlx/py-lib/profiling.py,sha256=Dc-mybFwBdCIKFWL7CbSHjkOJGAoYHG7r_e_XPhzwBU,9361
@@ -540,7 +541,7 @@ nexaai/utils/quantization_utils.py,sha256=4gvp6UQfSO9G1FYBwnFtQspTzH9sDbi1PBXw2t
540
541
  nexaai/vlm_impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
541
542
  nexaai/vlm_impl/mlx_vlm_impl.py,sha256=pLtWm_ckz8a0U-AtAOMVseFDO4OVPvHyYO2KlfBaGYk,10833
542
543
  nexaai/vlm_impl/pybind_vlm_impl.py,sha256=FAbhpRJzHgI78r0mUvKybO97R1szvNhH0aTn_I52oT4,8597
543
- nexaai-1.0.16rc11.dist-info/METADATA,sha256=ZBygPzSF5yfMU8SgBMTS8HmrlM4Rx_vAwQsoX8rZIks,1202
544
- nexaai-1.0.16rc11.dist-info/WHEEL,sha256=T2p57lol9__xkoU6aJTyN1Pm43ZpRU3q6km7mIbrAMs,114
545
- nexaai-1.0.16rc11.dist-info/top_level.txt,sha256=LRE2YERlrZk2vfuygnSzsEeqSknnZbz3Z1MHyNmBU4w,7
546
- nexaai-1.0.16rc11.dist-info/RECORD,,
544
+ nexaai-1.0.16rc12.dist-info/METADATA,sha256=a6Oh67bHm9t2m1j9yPHyou4gx0YOJjag7YLhJYyjRxc,1202
545
+ nexaai-1.0.16rc12.dist-info/WHEEL,sha256=T2p57lol9__xkoU6aJTyN1Pm43ZpRU3q6km7mIbrAMs,114
546
+ nexaai-1.0.16rc12.dist-info/top_level.txt,sha256=LRE2YERlrZk2vfuygnSzsEeqSknnZbz3Z1MHyNmBU4w,7
547
+ nexaai-1.0.16rc12.dist-info/RECORD,,