nexaai 1.0.21rc5__cp313-cp313-win_arm64.whl → 1.0.21rc16__cp313-cp313-win_arm64.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.

Files changed (104) hide show
  1. nexaai/__init__.py +95 -95
  2. nexaai/_stub.cp313-win_arm64.pyd +0 -0
  3. nexaai/_version.py +4 -1
  4. nexaai/asr.py +68 -65
  5. nexaai/asr_impl/mlx_asr_impl.py +92 -92
  6. nexaai/asr_impl/pybind_asr_impl.py +127 -44
  7. nexaai/base.py +39 -39
  8. nexaai/binds/__init__.py +6 -5
  9. nexaai/binds/asr_bind.cp313-win_arm64.pyd +0 -0
  10. nexaai/binds/common_bind.cp313-win_arm64.pyd +0 -0
  11. nexaai/binds/cpu_gpu/ggml-base.dll +0 -0
  12. nexaai/binds/cpu_gpu/ggml-cpu.dll +0 -0
  13. nexaai/binds/cpu_gpu/ggml-opencl.dll +0 -0
  14. nexaai/binds/cpu_gpu/ggml.dll +0 -0
  15. nexaai/binds/cpu_gpu/mtmd.dll +0 -0
  16. nexaai/binds/cpu_gpu/nexa_cpu_gpu.dll +0 -0
  17. nexaai/binds/cpu_gpu/nexa_plugin.dll +0 -0
  18. nexaai/binds/embedder_bind.cp313-win_arm64.pyd +0 -0
  19. nexaai/binds/libcrypto-3-arm64.dll +0 -0
  20. nexaai/binds/libssl-3-arm64.dll +0 -0
  21. nexaai/binds/llm_bind.cp313-win_arm64.pyd +0 -0
  22. nexaai/binds/nexa_bridge.dll +0 -0
  23. nexaai/binds/npu/convnext-sdk.dll +0 -0
  24. nexaai/binds/npu/embed-gemma-sdk.dll +0 -0
  25. nexaai/binds/npu/ggml-base.dll +0 -0
  26. nexaai/binds/npu/ggml-cpu.dll +0 -0
  27. nexaai/binds/{nexaml → npu}/ggml-opencl.dll +0 -0
  28. nexaai/binds/npu/ggml.dll +0 -0
  29. nexaai/binds/npu/granite-nano-sdk.dll +0 -0
  30. nexaai/binds/npu/granite4-sdk.dll +0 -0
  31. nexaai/binds/npu/jina-rerank-sdk.dll +0 -0
  32. nexaai/binds/npu/liquid-sdk.dll +0 -0
  33. nexaai/binds/npu/llama3-3b-sdk.dll +0 -0
  34. nexaai/binds/npu/nexa-mm-process.dll +0 -0
  35. nexaai/binds/npu/nexa-sampling.dll +0 -0
  36. nexaai/binds/npu/nexa_plugin.dll +0 -0
  37. nexaai/binds/npu/omni-neural-sdk.dll +0 -0
  38. nexaai/binds/npu/openblas.dll +0 -0
  39. nexaai/binds/npu/paddleocr-sdk.dll +0 -0
  40. nexaai/binds/npu/parakeet-sdk.dll +0 -0
  41. nexaai/binds/npu/phi3-5-sdk.dll +0 -0
  42. nexaai/binds/npu/phi4-sdk.dll +0 -0
  43. nexaai/binds/npu/pyannote-sdk.dll +0 -0
  44. nexaai/binds/npu/qwen3-4b-sdk.dll +0 -0
  45. nexaai/binds/npu/qwen3vl-sdk.dll +0 -0
  46. nexaai/binds/npu/qwen3vl-vision.dll +0 -0
  47. nexaai/binds/npu/yolov12-sdk.dll +0 -0
  48. nexaai/binds/npu/zlib1.dll +0 -0
  49. nexaai/binds/rerank_bind.cp313-win_arm64.pyd +0 -0
  50. nexaai/binds/vlm_bind.cp313-win_arm64.pyd +0 -0
  51. nexaai/common.py +105 -105
  52. nexaai/cv.py +93 -93
  53. nexaai/cv_impl/mlx_cv_impl.py +89 -89
  54. nexaai/cv_impl/pybind_cv_impl.py +32 -32
  55. nexaai/embedder.py +73 -73
  56. nexaai/embedder_impl/mlx_embedder_impl.py +118 -118
  57. nexaai/embedder_impl/pybind_embedder_impl.py +96 -96
  58. nexaai/image_gen.py +141 -141
  59. nexaai/image_gen_impl/mlx_image_gen_impl.py +292 -292
  60. nexaai/image_gen_impl/pybind_image_gen_impl.py +85 -85
  61. nexaai/llm.py +98 -98
  62. nexaai/llm_impl/mlx_llm_impl.py +271 -271
  63. nexaai/llm_impl/pybind_llm_impl.py +220 -220
  64. nexaai/log.py +92 -92
  65. nexaai/rerank.py +57 -57
  66. nexaai/rerank_impl/mlx_rerank_impl.py +94 -94
  67. nexaai/rerank_impl/pybind_rerank_impl.py +136 -136
  68. nexaai/runtime.py +68 -68
  69. nexaai/runtime_error.py +24 -24
  70. nexaai/tts.py +75 -75
  71. nexaai/tts_impl/mlx_tts_impl.py +94 -94
  72. nexaai/tts_impl/pybind_tts_impl.py +43 -43
  73. nexaai/utils/decode.py +17 -17
  74. nexaai/utils/manifest_utils.py +531 -531
  75. nexaai/utils/model_manager.py +1562 -1562
  76. nexaai/utils/model_types.py +49 -49
  77. nexaai/utils/progress_tracker.py +384 -384
  78. nexaai/utils/quantization_utils.py +245 -245
  79. nexaai/vlm.py +129 -129
  80. nexaai/vlm_impl/mlx_vlm_impl.py +258 -258
  81. nexaai/vlm_impl/pybind_vlm_impl.py +256 -256
  82. {nexaai-1.0.21rc5.dist-info → nexaai-1.0.21rc16.dist-info}/METADATA +1 -1
  83. nexaai-1.0.21rc16.dist-info/RECORD +154 -0
  84. nexaai/binds/nexaml/FLAC.dll +0 -0
  85. nexaai/binds/nexaml/fftw3.dll +0 -0
  86. nexaai/binds/nexaml/fftw3f.dll +0 -0
  87. nexaai/binds/nexaml/ggml-base.dll +0 -0
  88. nexaai/binds/nexaml/ggml-cpu.dll +0 -0
  89. nexaai/binds/nexaml/ggml.dll +0 -0
  90. nexaai/binds/nexaml/libmp3lame.DLL +0 -0
  91. nexaai/binds/nexaml/mpg123.dll +0 -0
  92. nexaai/binds/nexaml/nexa-mm-process.dll +0 -0
  93. nexaai/binds/nexaml/nexa-sampling.dll +0 -0
  94. nexaai/binds/nexaml/nexa_plugin.dll +0 -0
  95. nexaai/binds/nexaml/nexaproc.dll +0 -0
  96. nexaai/binds/nexaml/ogg.dll +0 -0
  97. nexaai/binds/nexaml/opus.dll +0 -0
  98. nexaai/binds/nexaml/qwen3-vl.dll +0 -0
  99. nexaai/binds/nexaml/qwen3vl-vision.dll +0 -0
  100. nexaai/binds/nexaml/vorbis.dll +0 -0
  101. nexaai/binds/nexaml/vorbisenc.dll +0 -0
  102. nexaai-1.0.21rc5.dist-info/RECORD +0 -162
  103. {nexaai-1.0.21rc5.dist-info → nexaai-1.0.21rc16.dist-info}/WHEEL +0 -0
  104. {nexaai-1.0.21rc5.dist-info → nexaai-1.0.21rc16.dist-info}/top_level.txt +0 -0
@@ -1,85 +1,85 @@
1
- from typing import List, Optional, Union
2
-
3
- from nexaai.common import PluginID
4
- from nexaai.image_gen import ImageGen, ImageGenerationConfig, ImageSamplerConfig, SchedulerConfig, Image
5
-
6
-
7
- class PyBindImageGenImpl(ImageGen):
8
- def __init__(self):
9
- """Initialize PyBind Image Generation implementation."""
10
- super().__init__()
11
- # TODO: Add PyBind-specific initialization
12
-
13
- @classmethod
14
- def _load_from(cls,
15
- model_path: str,
16
- scheduler_config_path: str = "",
17
- plugin_id: Union[PluginID, str] = PluginID.LLAMA_CPP,
18
- device_id: Optional[str] = None,
19
- float16: bool = True,
20
- quantize: bool = False
21
- ) -> 'PyBindImageGenImpl':
22
- """Load image generation model from local path using PyBind backend."""
23
- # TODO: Implement PyBind image generation loading
24
- instance = cls()
25
- return instance
26
-
27
- def eject(self):
28
- """Destroy the model and free resources."""
29
- # TODO: Implement PyBind image generation cleanup
30
- pass
31
-
32
- def load_model(self, model_path: str, extra_data: Optional[str] = None) -> bool:
33
- """Load model from path."""
34
- # TODO: Implement PyBind image generation model loading
35
- raise NotImplementedError("PyBind image generation model loading not yet implemented")
36
-
37
- def set_scheduler(self, config: SchedulerConfig) -> None:
38
- """Set scheduler configuration."""
39
- # TODO: Implement PyBind scheduler setting
40
- raise NotImplementedError("PyBind scheduler setting not yet implemented")
41
-
42
- def set_sampler(self, config: ImageSamplerConfig) -> None:
43
- """Set sampler configuration."""
44
- # TODO: Implement PyBind sampler setting
45
- raise NotImplementedError("PyBind sampler setting not yet implemented")
46
-
47
- def reset_sampler(self) -> None:
48
- """Reset sampler to default configuration."""
49
- # TODO: Implement PyBind sampler reset
50
- raise NotImplementedError("PyBind sampler reset not yet implemented")
51
-
52
- def txt2img(self, prompt: str, config: ImageGenerationConfig) -> Image:
53
- """Generate image from text prompt."""
54
- # TODO: Implement PyBind text-to-image
55
- raise NotImplementedError("PyBind text-to-image not yet implemented")
56
-
57
- def img2img(self, init_image: Image, prompt: str, config: ImageGenerationConfig) -> Image:
58
- """Generate image from initial image and text prompt."""
59
- # TODO: Implement PyBind image-to-image
60
- raise NotImplementedError("PyBind image-to-image not yet implemented")
61
-
62
- def generate(self, config: ImageGenerationConfig) -> Image:
63
- """Generate image from configuration."""
64
- # TODO: Implement PyBind image generation
65
- raise NotImplementedError("PyBind image generation not yet implemented")
66
-
67
- def set_lora(self, lora_id: int) -> None:
68
- """Set active LoRA adapter."""
69
- # TODO: Implement PyBind LoRA setting
70
- raise NotImplementedError("PyBind LoRA setting not yet implemented")
71
-
72
- def add_lora(self, lora_path: str) -> int:
73
- """Add LoRA adapter and return its ID."""
74
- # TODO: Implement PyBind LoRA addition
75
- raise NotImplementedError("PyBind LoRA addition not yet implemented")
76
-
77
- def remove_lora(self, lora_id: int) -> None:
78
- """Remove LoRA adapter."""
79
- # TODO: Implement PyBind LoRA removal
80
- raise NotImplementedError("PyBind LoRA removal not yet implemented")
81
-
82
- def list_loras(self) -> List[int]:
83
- """List available LoRA adapters."""
84
- # TODO: Implement PyBind LoRA listing
85
- raise NotImplementedError("PyBind LoRA listing not yet implemented")
1
+ from typing import List, Optional, Union
2
+
3
+ from nexaai.common import PluginID
4
+ from nexaai.image_gen import ImageGen, ImageGenerationConfig, ImageSamplerConfig, SchedulerConfig, Image
5
+
6
+
7
+ class PyBindImageGenImpl(ImageGen):
8
+ def __init__(self):
9
+ """Initialize PyBind Image Generation implementation."""
10
+ super().__init__()
11
+ # TODO: Add PyBind-specific initialization
12
+
13
+ @classmethod
14
+ def _load_from(cls,
15
+ model_path: str,
16
+ scheduler_config_path: str = "",
17
+ plugin_id: Union[PluginID, str] = PluginID.LLAMA_CPP,
18
+ device_id: Optional[str] = None,
19
+ float16: bool = True,
20
+ quantize: bool = False
21
+ ) -> 'PyBindImageGenImpl':
22
+ """Load image generation model from local path using PyBind backend."""
23
+ # TODO: Implement PyBind image generation loading
24
+ instance = cls()
25
+ return instance
26
+
27
+ def eject(self):
28
+ """Destroy the model and free resources."""
29
+ # TODO: Implement PyBind image generation cleanup
30
+ pass
31
+
32
+ def load_model(self, model_path: str, extra_data: Optional[str] = None) -> bool:
33
+ """Load model from path."""
34
+ # TODO: Implement PyBind image generation model loading
35
+ raise NotImplementedError("PyBind image generation model loading not yet implemented")
36
+
37
+ def set_scheduler(self, config: SchedulerConfig) -> None:
38
+ """Set scheduler configuration."""
39
+ # TODO: Implement PyBind scheduler setting
40
+ raise NotImplementedError("PyBind scheduler setting not yet implemented")
41
+
42
+ def set_sampler(self, config: ImageSamplerConfig) -> None:
43
+ """Set sampler configuration."""
44
+ # TODO: Implement PyBind sampler setting
45
+ raise NotImplementedError("PyBind sampler setting not yet implemented")
46
+
47
+ def reset_sampler(self) -> None:
48
+ """Reset sampler to default configuration."""
49
+ # TODO: Implement PyBind sampler reset
50
+ raise NotImplementedError("PyBind sampler reset not yet implemented")
51
+
52
+ def txt2img(self, prompt: str, config: ImageGenerationConfig) -> Image:
53
+ """Generate image from text prompt."""
54
+ # TODO: Implement PyBind text-to-image
55
+ raise NotImplementedError("PyBind text-to-image not yet implemented")
56
+
57
+ def img2img(self, init_image: Image, prompt: str, config: ImageGenerationConfig) -> Image:
58
+ """Generate image from initial image and text prompt."""
59
+ # TODO: Implement PyBind image-to-image
60
+ raise NotImplementedError("PyBind image-to-image not yet implemented")
61
+
62
+ def generate(self, config: ImageGenerationConfig) -> Image:
63
+ """Generate image from configuration."""
64
+ # TODO: Implement PyBind image generation
65
+ raise NotImplementedError("PyBind image generation not yet implemented")
66
+
67
+ def set_lora(self, lora_id: int) -> None:
68
+ """Set active LoRA adapter."""
69
+ # TODO: Implement PyBind LoRA setting
70
+ raise NotImplementedError("PyBind LoRA setting not yet implemented")
71
+
72
+ def add_lora(self, lora_path: str) -> int:
73
+ """Add LoRA adapter and return its ID."""
74
+ # TODO: Implement PyBind LoRA addition
75
+ raise NotImplementedError("PyBind LoRA addition not yet implemented")
76
+
77
+ def remove_lora(self, lora_id: int) -> None:
78
+ """Remove LoRA adapter."""
79
+ # TODO: Implement PyBind LoRA removal
80
+ raise NotImplementedError("PyBind LoRA removal not yet implemented")
81
+
82
+ def list_loras(self) -> List[int]:
83
+ """List available LoRA adapters."""
84
+ # TODO: Implement PyBind LoRA listing
85
+ raise NotImplementedError("PyBind LoRA listing not yet implemented")
nexaai/llm.py CHANGED
@@ -1,98 +1,98 @@
1
- from typing import Generator, Optional, Union
2
- from abc import abstractmethod
3
- import queue
4
- import threading
5
-
6
- from nexaai.common import ModelConfig, GenerationConfig, ChatMessage, PluginID
7
- from nexaai.base import BaseModel, ProfilingData
8
-
9
- class LLM(BaseModel):
10
- def __init__(self, m_cfg: ModelConfig = ModelConfig()):
11
- """Initialize base LLM class."""
12
- self._m_cfg = m_cfg
13
- self._cancel_event = threading.Event() # New attribute to control cancellation
14
-
15
- @classmethod
16
- def _load_from(cls,
17
- local_path: str,
18
- model_name: Optional[str] = None,
19
- tokenizer_path: Optional[str] = None,
20
- m_cfg: ModelConfig = ModelConfig(),
21
- plugin_id: Union[PluginID, str] = PluginID.LLAMA_CPP,
22
- device_id: Optional[str] = None,
23
- **kwargs
24
- ) -> 'LLM':
25
- """Load model from local path, routing to appropriate implementation."""
26
- # Check plugin_id value for routing - handle both enum and string
27
- plugin_value = plugin_id.value if isinstance(plugin_id, PluginID) else plugin_id
28
-
29
- if plugin_value == "mlx":
30
- from nexaai.llm_impl.mlx_llm_impl import MLXLLMImpl
31
- return MLXLLMImpl._load_from(local_path, model_name, tokenizer_path, m_cfg, plugin_id, device_id)
32
- else:
33
- from nexaai.llm_impl.pybind_llm_impl import PyBindLLMImpl
34
- return PyBindLLMImpl._load_from(local_path, model_name, tokenizer_path, m_cfg, plugin_id, device_id)
35
-
36
- def cancel_generation(self):
37
- """Signal to cancel any ongoing stream generation."""
38
- self._cancel_event.set()
39
-
40
- def reset_cancel(self):
41
- """Reset the cancel event. Call before starting a new generation if needed."""
42
- self._cancel_event.clear()
43
-
44
- @abstractmethod
45
- def apply_chat_template(self, messages: list[ChatMessage], tools: Optional[str] = None, enable_thinking: bool = True, add_generation_prompt: bool = True) -> str:
46
- """Apply the chat template to messages."""
47
- pass
48
-
49
- @abstractmethod
50
- def generate_stream(self, prompt: str, g_cfg: GenerationConfig = GenerationConfig()) -> Generator[str, None, None]:
51
- """Generate text with streaming."""
52
- pass
53
-
54
- @abstractmethod
55
- def generate(self, prompt: str, g_cfg: GenerationConfig = GenerationConfig()) -> str:
56
- """
57
- Generate text without streaming.
58
-
59
- Args:
60
- prompt (str): The prompt to generate text from. For chat models, this is the chat messages after chat template is applied.
61
- g_cfg (GenerationConfig): Generation configuration.
62
-
63
- Returns:
64
- str: The generated text.
65
- """
66
- pass
67
-
68
- def get_profiling_data(self) -> Optional[ProfilingData]:
69
- """Get profiling data from the last generation."""
70
- pass
71
-
72
- @abstractmethod
73
- def save_kv_cache(self, path: str):
74
- """
75
- Save the key-value cache to the file.
76
-
77
- Args:
78
- path (str): The path to the file.
79
- """
80
- pass
81
-
82
- @abstractmethod
83
- def load_kv_cache(self, path: str):
84
- """
85
- Load the key-value cache from the file.
86
-
87
- Args:
88
- path (str): The path to the file.
89
- """
90
- pass
91
-
92
- @abstractmethod
93
- def reset(self):
94
- """
95
- Reset the LLM model context and KV cache. If not reset, the model will skip the number of evaluated tokens and treat tokens after those as the new incremental tokens.
96
- If your past chat history changed, or you are starting a new chat, you should always reset the model before running generate.
97
- """
98
- pass
1
+ from typing import Generator, Optional, Union
2
+ from abc import abstractmethod
3
+ import queue
4
+ import threading
5
+
6
+ from nexaai.common import ModelConfig, GenerationConfig, ChatMessage, PluginID
7
+ from nexaai.base import BaseModel, ProfilingData
8
+
9
+ class LLM(BaseModel):
10
+ def __init__(self, m_cfg: ModelConfig = ModelConfig()):
11
+ """Initialize base LLM class."""
12
+ self._m_cfg = m_cfg
13
+ self._cancel_event = threading.Event() # New attribute to control cancellation
14
+
15
+ @classmethod
16
+ def _load_from(cls,
17
+ local_path: str,
18
+ model_name: Optional[str] = None,
19
+ tokenizer_path: Optional[str] = None,
20
+ m_cfg: ModelConfig = ModelConfig(),
21
+ plugin_id: Union[PluginID, str] = PluginID.LLAMA_CPP,
22
+ device_id: Optional[str] = None,
23
+ **kwargs
24
+ ) -> 'LLM':
25
+ """Load model from local path, routing to appropriate implementation."""
26
+ # Check plugin_id value for routing - handle both enum and string
27
+ plugin_value = plugin_id.value if isinstance(plugin_id, PluginID) else plugin_id
28
+
29
+ if plugin_value == "mlx":
30
+ from nexaai.llm_impl.mlx_llm_impl import MLXLLMImpl
31
+ return MLXLLMImpl._load_from(local_path, model_name, tokenizer_path, m_cfg, plugin_id, device_id)
32
+ else:
33
+ from nexaai.llm_impl.pybind_llm_impl import PyBindLLMImpl
34
+ return PyBindLLMImpl._load_from(local_path, model_name, tokenizer_path, m_cfg, plugin_id, device_id)
35
+
36
+ def cancel_generation(self):
37
+ """Signal to cancel any ongoing stream generation."""
38
+ self._cancel_event.set()
39
+
40
+ def reset_cancel(self):
41
+ """Reset the cancel event. Call before starting a new generation if needed."""
42
+ self._cancel_event.clear()
43
+
44
+ @abstractmethod
45
+ def apply_chat_template(self, messages: list[ChatMessage], tools: Optional[str] = None, enable_thinking: bool = True, add_generation_prompt: bool = True) -> str:
46
+ """Apply the chat template to messages."""
47
+ pass
48
+
49
+ @abstractmethod
50
+ def generate_stream(self, prompt: str, g_cfg: GenerationConfig = GenerationConfig()) -> Generator[str, None, None]:
51
+ """Generate text with streaming."""
52
+ pass
53
+
54
+ @abstractmethod
55
+ def generate(self, prompt: str, g_cfg: GenerationConfig = GenerationConfig()) -> str:
56
+ """
57
+ Generate text without streaming.
58
+
59
+ Args:
60
+ prompt (str): The prompt to generate text from. For chat models, this is the chat messages after chat template is applied.
61
+ g_cfg (GenerationConfig): Generation configuration.
62
+
63
+ Returns:
64
+ str: The generated text.
65
+ """
66
+ pass
67
+
68
+ def get_profiling_data(self) -> Optional[ProfilingData]:
69
+ """Get profiling data from the last generation."""
70
+ pass
71
+
72
+ @abstractmethod
73
+ def save_kv_cache(self, path: str):
74
+ """
75
+ Save the key-value cache to the file.
76
+
77
+ Args:
78
+ path (str): The path to the file.
79
+ """
80
+ pass
81
+
82
+ @abstractmethod
83
+ def load_kv_cache(self, path: str):
84
+ """
85
+ Load the key-value cache from the file.
86
+
87
+ Args:
88
+ path (str): The path to the file.
89
+ """
90
+ pass
91
+
92
+ @abstractmethod
93
+ def reset(self):
94
+ """
95
+ Reset the LLM model context and KV cache. If not reset, the model will skip the number of evaluated tokens and treat tokens after those as the new incremental tokens.
96
+ If your past chat history changed, or you are starting a new chat, you should always reset the model before running generate.
97
+ """
98
+ pass