isa-model 0.1.0__tar.gz → 0.1.1__tar.gz

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.
Files changed (145) hide show
  1. {isa_model-0.1.0 → isa_model-0.1.1}/MANIFEST.in +0 -1
  2. isa_model-0.1.1/PKG-INFO +327 -0
  3. isa_model-0.1.1/README.md +296 -0
  4. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/__init__.py +1 -1
  5. isa_model-0.1.1/isa_model/core/model_registry.py +342 -0
  6. isa_model-0.1.1/isa_model/deployment/gpu_fp16_ds8/models/deepseek_r1/1/model.py +120 -0
  7. isa_model-0.1.1/isa_model/deployment/gpu_fp16_ds8/scripts/download_model.py +18 -0
  8. isa_model-0.1.1/isa_model/deployment/gpu_int8_ds8/app/server.py +66 -0
  9. isa_model-0.1.1/isa_model/deployment/gpu_int8_ds8/scripts/test_client.py +43 -0
  10. isa_model-0.1.1/isa_model/deployment/gpu_int8_ds8/scripts/test_client_os.py +35 -0
  11. isa_model-0.1.1/isa_model/eval/__init__.py +56 -0
  12. isa_model-0.1.1/isa_model/eval/benchmarks.py +469 -0
  13. isa_model-0.1.1/isa_model/eval/factory.py +582 -0
  14. isa_model-0.1.1/isa_model/eval/metrics.py +628 -0
  15. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/ai_factory.py +98 -93
  16. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/providers/openai_provider.py +21 -7
  17. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/providers/replicate_provider.py +18 -5
  18. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/providers/triton_provider.py +1 -1
  19. isa_model-0.1.1/isa_model/inference/services/audio/base_stt_service.py +91 -0
  20. isa_model-0.1.1/isa_model/inference/services/audio/base_tts_service.py +136 -0
  21. isa_model-0.1.0/isa_model/inference/services/audio/yyds_audio_service.py → isa_model-0.1.1/isa_model/inference/services/audio/openai_tts_service.py +4 -4
  22. isa_model-0.1.1/isa_model/inference/services/embedding/ollama_embed_service.py +97 -0
  23. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/services/llm/__init__.py +0 -4
  24. isa_model-0.1.1/isa_model/inference/services/llm/base_llm_service.py +134 -0
  25. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/services/llm/ollama_llm_service.py +1 -10
  26. isa_model-0.1.1/isa_model/inference/services/llm/openai_llm_service.py +138 -0
  27. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/services/vision/__init__.py +1 -1
  28. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/services/vision/ollama_vision_service.py +4 -4
  29. isa_model-0.1.0/isa_model/inference/services/vision/yyds_vision_service.py → isa_model-0.1.1/isa_model/inference/services/vision/openai_vision_service.py +5 -5
  30. isa_model-0.1.1/isa_model/inference/services/vision/replicate_image_gen_service.py +185 -0
  31. isa_model-0.1.1/isa_model/training/__init__.py +44 -0
  32. isa_model-0.1.1/isa_model/training/factory.py +393 -0
  33. isa_model-0.1.1/isa_model.egg-info/PKG-INFO +327 -0
  34. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model.egg-info/SOURCES.txt +18 -43
  35. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model.egg-info/requires.txt +3 -1
  36. {isa_model-0.1.0 → isa_model-0.1.1}/pyproject.toml +6 -6
  37. isa_model-0.1.0/PKG-INFO +0 -116
  38. isa_model-0.1.0/README.md +0 -86
  39. isa_model-0.1.0/isa_model/core/model_registry.py +0 -115
  40. isa_model-0.1.0/isa_model/deployment/mlflow_gateway/__init__.py +0 -8
  41. isa_model-0.1.0/isa_model/deployment/mlflow_gateway/start_gateway.py +0 -65
  42. isa_model-0.1.0/isa_model/deployment/unified_multimodal_client.py +0 -341
  43. isa_model-0.1.0/isa_model/inference/adapter/triton_adapter.py +0 -453
  44. isa_model-0.1.0/isa_model/inference/backends/Pytorch/bge_embed_backend.py +0 -188
  45. isa_model-0.1.0/isa_model/inference/backends/Pytorch/gemma_backend.py +0 -167
  46. isa_model-0.1.0/isa_model/inference/backends/Pytorch/llama_backend.py +0 -166
  47. isa_model-0.1.0/isa_model/inference/backends/Pytorch/whisper_backend.py +0 -194
  48. isa_model-0.1.0/isa_model/inference/backends/__init__.py +0 -53
  49. isa_model-0.1.0/isa_model/inference/backends/base_backend_client.py +0 -26
  50. isa_model-0.1.0/isa_model/inference/backends/container_services.py +0 -104
  51. isa_model-0.1.0/isa_model/inference/backends/local_services.py +0 -72
  52. isa_model-0.1.0/isa_model/inference/backends/openai_client.py +0 -130
  53. isa_model-0.1.0/isa_model/inference/backends/replicate_client.py +0 -197
  54. isa_model-0.1.0/isa_model/inference/backends/third_party_services.py +0 -239
  55. isa_model-0.1.0/isa_model/inference/backends/triton_client.py +0 -97
  56. isa_model-0.1.0/isa_model/inference/client_sdk/client.py +0 -134
  57. isa_model-0.1.0/isa_model/inference/client_sdk/client_data_std.py +0 -34
  58. isa_model-0.1.0/isa_model/inference/client_sdk/client_sdk_schema.py +0 -16
  59. isa_model-0.1.0/isa_model/inference/client_sdk/exceptions.py +0 -0
  60. isa_model-0.1.0/isa_model/inference/engine/triton/model_repository/bge/1/model.py +0 -174
  61. isa_model-0.1.0/isa_model/inference/engine/triton/model_repository/gemma/1/model.py +0 -250
  62. isa_model-0.1.0/isa_model/inference/engine/triton/model_repository/llama/1/model.py +0 -76
  63. isa_model-0.1.0/isa_model/inference/engine/triton/model_repository/whisper/1/model.py +0 -195
  64. isa_model-0.1.0/isa_model/inference/providers/vllm_provider.py +0 -0
  65. isa_model-0.1.0/isa_model/inference/providers/yyds_provider.py +0 -83
  66. isa_model-0.1.0/isa_model/inference/services/audio/fish_speech/handler.py +0 -215
  67. isa_model-0.1.0/isa_model/inference/services/audio/runpod_tts_fish_service.py +0 -212
  68. isa_model-0.1.0/isa_model/inference/services/audio/triton_speech_service.py +0 -138
  69. isa_model-0.1.0/isa_model/inference/services/audio/whisper_service.py +0 -186
  70. isa_model-0.1.0/isa_model/inference/services/base_tts_service.py +0 -66
  71. isa_model-0.1.0/isa_model/inference/services/embedding/bge_service.py +0 -183
  72. isa_model-0.1.0/isa_model/inference/services/embedding/ollama_embed_service.py +0 -85
  73. isa_model-0.1.0/isa_model/inference/services/embedding/ollama_rerank_service.py +0 -118
  74. isa_model-0.1.0/isa_model/inference/services/embedding/onnx_rerank_service.py +0 -73
  75. isa_model-0.1.0/isa_model/inference/services/llm/gemma_service.py +0 -143
  76. isa_model-0.1.0/isa_model/inference/services/llm/llama_service.py +0 -143
  77. isa_model-0.1.0/isa_model/inference/services/llm/openai_llm_service.py +0 -129
  78. isa_model-0.1.0/isa_model/inference/services/llm/replicate_llm_service.py +0 -179
  79. isa_model-0.1.0/isa_model/inference/services/llm/triton_llm_service.py +0 -230
  80. isa_model-0.1.0/isa_model/inference/services/vision/replicate_vision_service.py +0 -241
  81. isa_model-0.1.0/isa_model/inference/services/vision/triton_vision_service.py +0 -199
  82. isa_model-0.1.0/isa_model.egg-info/PKG-INFO +0 -116
  83. {isa_model-0.1.0 → isa_model-0.1.1}/LICENSE +0 -0
  84. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/core/model_manager.py +0 -0
  85. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/core/model_router.py +0 -0
  86. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/core/model_storage.py +0 -0
  87. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/core/model_version.py +0 -0
  88. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/core/resource_manager.py +0 -0
  89. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/core/storage/hf_storage.py +0 -0
  90. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/core/storage/local_storage.py +0 -0
  91. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/core/storage/minio_storage.py +0 -0
  92. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/__init__.py +0 -0
  93. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/adapter/unified_api.py +0 -0
  94. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/base.py +0 -0
  95. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/providers/__init__.py +0 -0
  96. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/providers/base_provider.py +0 -0
  97. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/providers/model_cache_manager.py +0 -0
  98. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/providers/ollama_provider.py +0 -0
  99. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/services/__init__.py +0 -0
  100. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/services/base_service.py +0 -0
  101. /isa_model-0.1.0/isa_model/inference/client_sdk/__init__.py → /isa_model-0.1.1/isa_model/inference/services/embedding/openai_embed_service.py +0 -0
  102. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/services/others/table_transformer_service.py +0 -0
  103. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/services/vision/helpers/image_utils.py +0 -0
  104. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/services/vision/helpers/text_splitter.py +0 -0
  105. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/utils/conversion/bge_rerank_convert.py +0 -0
  106. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/utils/conversion/onnx_converter.py +0 -0
  107. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/inference/utils/conversion/torch_converter.py +0 -0
  108. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/scripts/inference_tracker.py +0 -0
  109. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/scripts/mlflow_manager.py +0 -0
  110. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/scripts/model_registry.py +0 -0
  111. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/scripts/start_mlflow.py +0 -0
  112. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/scripts/training_tracker.py +0 -0
  113. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/engine/llama_factory/__init__.py +0 -0
  114. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/engine/llama_factory/config.py +0 -0
  115. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/engine/llama_factory/data_adapter.py +0 -0
  116. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/engine/llama_factory/examples/__init__.py +0 -0
  117. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/engine/llama_factory/examples/finetune_with_tracking.py +0 -0
  118. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/engine/llama_factory/examples/rlhf_with_tracking.py +0 -0
  119. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/engine/llama_factory/factory.py +0 -0
  120. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/engine/llama_factory/rl.py +0 -0
  121. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/engine/llama_factory/trainer.py +0 -0
  122. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/configs/create_config.py +0 -0
  123. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/configs/create_flux_config.py +0 -0
  124. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/configs/create_lora_config.py +0 -0
  125. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/prepare_massed_compute.py +0 -0
  126. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/prepare_upload.py +0 -0
  127. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/raw_data/create_captions.py +0 -0
  128. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/raw_data/create_lora_captions.py +0 -0
  129. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/raw_data/pre_processing.py +0 -0
  130. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/train/train.py +0 -0
  131. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/train/train_flux.py +0 -0
  132. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/train/train_lora.py +0 -0
  133. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/image_model/train_main.py +0 -0
  134. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/llm_model/annotation/annotation_schema.py +0 -0
  135. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/llm_model/annotation/processors/annotation_processor.py +0 -0
  136. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/llm_model/annotation/storage/dataset_manager.py +0 -0
  137. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/llm_model/annotation/storage/dataset_schema.py +0 -0
  138. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/llm_model/annotation/tests/test_annotation_flow.py +0 -0
  139. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/llm_model/annotation/tests/test_minio copy.py +0 -0
  140. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/llm_model/annotation/tests/test_minio_upload.py +0 -0
  141. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model/training/llm_model/annotation/views/annotation_controller.py +0 -0
  142. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model.egg-info/dependency_links.txt +0 -0
  143. {isa_model-0.1.0 → isa_model-0.1.1}/isa_model.egg-info/top_level.txt +0 -0
  144. {isa_model-0.1.0 → isa_model-0.1.1}/setup.cfg +0 -0
  145. {isa_model-0.1.0 → isa_model-0.1.1}/setup.py +0 -0
@@ -1,3 +1,2 @@
1
- include LICENSE
2
1
  include README.md
3
2
  recursive-include isa_model *.py
@@ -0,0 +1,327 @@
1
+ Metadata-Version: 2.4
2
+ Name: isa-model
3
+ Version: 0.1.1
4
+ Summary: Unified AI model serving framework
5
+ Author-email: isA_Model Contributors <your.email@example.com>
6
+ License-Expression: MIT
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: fastapi>=0.95.0
15
+ Requires-Dist: numpy>=1.20.0
16
+ Requires-Dist: httpx>=0.23.0
17
+ Requires-Dist: pydantic>=2.0.0
18
+ Requires-Dist: uvicorn>=0.22.0
19
+ Requires-Dist: requests>=2.28.0
20
+ Requires-Dist: aiohttp>=3.8.0
21
+ Requires-Dist: transformers>=4.30.0
22
+ Requires-Dist: langchain-core>=0.1.0
23
+ Requires-Dist: huggingface-hub>=0.16.0
24
+ Requires-Dist: kubernetes>=25.3.0
25
+ Requires-Dist: mlflow>=2.4.0
26
+ Requires-Dist: torch>=2.0.0
27
+ Requires-Dist: openai>=1.10.0
28
+ Requires-Dist: replicate>=0.23.0
29
+ Requires-Dist: python-dotenv>=1.0.0
30
+ Dynamic: license-file
31
+
32
+ # isA Model - Unified AI Model Serving Framework
33
+
34
+ A comprehensive Python framework for working with multiple AI providers and models through a unified interface. Support for OpenAI, Replicate, Ollama, and more.
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ pip install isa-model
40
+ ```
41
+
42
+ ## Quick Start
43
+
44
+ The isa-model package supports three main usage patterns:
45
+
46
+ ### 1. Pass API Keys Directly (Recommended)
47
+
48
+ This is the most flexible approach - no environment variables needed:
49
+
50
+ ```python
51
+ from isa_model.inference.ai_factory import AIFactory
52
+
53
+ # Create factory instance
54
+ factory = AIFactory.get_instance()
55
+
56
+ # Use OpenAI with API key
57
+ llm = factory.get_llm(
58
+ model_name="gpt-4o-mini",
59
+ provider="openai",
60
+ api_key="your-openai-api-key-here"
61
+ )
62
+
63
+ # Use Replicate for image generation
64
+ image_gen = factory.get_vision_model(
65
+ model_name="stability-ai/sdxl",
66
+ provider="replicate",
67
+ api_key="your-replicate-token-here"
68
+ )
69
+ ```
70
+
71
+ ### 2. Use Environment Variables
72
+
73
+ Set your API keys as environment variables:
74
+
75
+ ```bash
76
+ export OPENAI_API_KEY="your-openai-api-key"
77
+ export REPLICATE_API_TOKEN="your-replicate-token"
78
+ ```
79
+
80
+ Then use without passing keys:
81
+
82
+ ```python
83
+ from isa_model.inference.ai_factory import AIFactory
84
+
85
+ factory = AIFactory.get_instance()
86
+
87
+ # Will automatically use OPENAI_API_KEY from environment
88
+ llm = factory.get_llm(model_name="gpt-4o-mini", provider="openai")
89
+
90
+ # Will automatically use REPLICATE_API_TOKEN from environment
91
+ image_gen = factory.get_vision_model(model_name="stability-ai/sdxl", provider="replicate")
92
+ ```
93
+
94
+ ### 3. Use Local Models (No API Key Needed)
95
+
96
+ For local models like Ollama, no API keys are required:
97
+
98
+ ```python
99
+ from isa_model.inference.ai_factory import AIFactory
100
+
101
+ factory = AIFactory.get_instance()
102
+
103
+ # Use local Ollama model (no API key needed)
104
+ llm = factory.get_llm(model_name="llama3.1", provider="ollama")
105
+ ```
106
+
107
+ ## Supported Services
108
+
109
+ ### Language Models (LLM)
110
+
111
+ ```python
112
+ # OpenAI models
113
+ llm = factory.get_llm("gpt-4o-mini", "openai", api_key="your-key")
114
+ llm = factory.get_llm("gpt-4o", "openai", api_key="your-key")
115
+
116
+ # Ollama models (local)
117
+ llm = factory.get_llm("llama3.1", "ollama")
118
+ llm = factory.get_llm("codellama", "ollama")
119
+
120
+ # Replicate models
121
+ llm = factory.get_llm("meta/llama-3-70b-instruct", "replicate", api_key="your-token")
122
+ ```
123
+
124
+ ### Vision Models
125
+
126
+ ```python
127
+ # OpenAI vision
128
+ vision = factory.get_vision_model("gpt-4o", "openai", api_key="your-key")
129
+
130
+ # Replicate image generation
131
+ image_gen = factory.get_vision_model("stability-ai/sdxl", "replicate", api_key="your-token")
132
+
133
+ # Ollama vision (local)
134
+ vision = factory.get_vision_model("llava", "ollama")
135
+ ```
136
+
137
+ ### Embedding Models
138
+
139
+ ```python
140
+ # OpenAI embeddings
141
+ embedder = factory.get_embedding("text-embedding-3-small", "openai", {"api_key": "your-key"})
142
+
143
+ # Ollama embeddings (local)
144
+ embedder = factory.get_embedding("bge-m3", "ollama")
145
+ ```
146
+
147
+ ## Base Service Classes
148
+
149
+ The framework provides comprehensive base classes for implementing new AI services:
150
+
151
+ ### BaseLLMService
152
+ - `ainvoke()` - Universal invocation method
153
+ - `achat()` - Chat completion with messages
154
+ - `acompletion()` - Simple text completion
155
+ - `agenerate()` - Generate multiple completions
156
+ - `astream_chat()` - Streaming chat responses
157
+ - `get_token_usage()` - Token usage statistics
158
+
159
+ ### BaseVisionService
160
+ - `analyze_image()` - Analyze and describe images
161
+ - `describe_image()` - Generate detailed descriptions
162
+ - `extract_text()` - OCR text extraction
163
+ - `detect_objects()` - Object detection
164
+ - `classify_image()` - Image classification
165
+ - `compare_images()` - Image similarity comparison
166
+
167
+ ### BaseImageGenService
168
+ - `generate_image()` - Generate single image from text
169
+ - `generate_images()` - Generate multiple images
170
+ - `image_to_image()` - Transform existing images
171
+ - `get_supported_sizes()` - Get supported dimensions
172
+
173
+ ### BaseEmbedService
174
+ - `create_text_embedding()` - Single text embedding
175
+ - `create_text_embeddings()` - Batch text embeddings
176
+ - `compute_similarity()` - Similarity calculation
177
+ - `find_similar_texts()` - Semantic search
178
+
179
+ ### BaseSTTService (Speech-to-Text)
180
+ - `transcribe_audio()` - Audio transcription
181
+ - `transcribe_audio_batch()` - Batch transcription
182
+ - `detect_language()` - Language detection
183
+
184
+ ### BaseTTSService (Text-to-Speech)
185
+ - `synthesize_speech()` - Text to speech conversion
186
+ - `synthesize_speech_to_file()` - Save speech to file
187
+ - `get_available_voices()` - List available voices
188
+
189
+ ## Usage Examples
190
+
191
+ ### Chat Completion
192
+
193
+ ```python
194
+ import asyncio
195
+ from isa_model.inference.ai_factory import AIFactory
196
+
197
+ async def chat_example():
198
+ factory = AIFactory.get_instance()
199
+ llm = factory.get_llm("gpt-4o-mini", "openai", api_key="your-key")
200
+
201
+ messages = [
202
+ {"role": "user", "content": "Hello, how are you?"}
203
+ ]
204
+
205
+ response = await llm.achat(messages)
206
+ print(response)
207
+
208
+ # Run the async function
209
+ asyncio.run(chat_example())
210
+ ```
211
+
212
+ ### Image Analysis
213
+
214
+ ```python
215
+ import asyncio
216
+ from isa_model.inference.ai_factory import AIFactory
217
+
218
+ async def vision_example():
219
+ factory = AIFactory.get_instance()
220
+ vision = factory.get_vision_model("gpt-4o", "openai", api_key="your-key")
221
+
222
+ result = await vision.analyze_image(
223
+ image="path/to/your/image.jpg",
224
+ prompt="What do you see in this image?"
225
+ )
226
+
227
+ print(result["text"])
228
+
229
+ asyncio.run(vision_example())
230
+ ```
231
+
232
+ ### Image Generation
233
+
234
+ ```python
235
+ import asyncio
236
+ from isa_model.inference.ai_factory import AIFactory
237
+
238
+ async def image_gen_example():
239
+ factory = AIFactory.get_instance()
240
+ image_gen = factory.get_vision_model(
241
+ "stability-ai/sdxl",
242
+ "replicate",
243
+ api_key="your-replicate-token"
244
+ )
245
+
246
+ result = await image_gen.generate_image(
247
+ prompt="A beautiful sunset over mountains",
248
+ width=1024,
249
+ height=1024
250
+ )
251
+
252
+ # Save the generated image
253
+ with open("generated_image.png", "wb") as f:
254
+ f.write(result["image_data"])
255
+
256
+ asyncio.run(image_gen_example())
257
+ ```
258
+
259
+ ## Configuration Options
260
+
261
+ You can pass additional configuration options:
262
+
263
+ ```python
264
+ # Custom configuration
265
+ config = {
266
+ "temperature": 0.7,
267
+ "max_tokens": 1000,
268
+ "top_p": 0.9
269
+ }
270
+
271
+ llm = factory.get_llm(
272
+ model_name="gpt-4o-mini",
273
+ provider="openai",
274
+ config=config,
275
+ api_key="your-key"
276
+ )
277
+ ```
278
+
279
+ ## Error Handling
280
+
281
+ The framework provides informative error messages and graceful fallbacks:
282
+
283
+ ```python
284
+ try:
285
+ llm = factory.get_llm("gpt-4o-mini", "openai", api_key="invalid-key")
286
+ response = await llm.achat([{"role": "user", "content": "Hello"}])
287
+ except Exception as e:
288
+ print(f"Error: {e}")
289
+ ```
290
+
291
+ ## Development
292
+
293
+ ### Installing for Development
294
+
295
+ ```bash
296
+ git clone <repository-url>
297
+ cd isA_Model
298
+ pip install -e .
299
+ ```
300
+
301
+ ### Running Tests
302
+
303
+ ```bash
304
+ pytest tests/
305
+ ```
306
+
307
+ ### Building and Publishing
308
+
309
+ ```bash
310
+ # Build the package
311
+ python -m build
312
+
313
+ # Upload to PyPI (requires PYPI_API_TOKEN in .env.local)
314
+ bash scripts/normal_update.sh
315
+ ```
316
+
317
+ ## License
318
+
319
+ MIT License - see LICENSE file for details.
320
+
321
+ ## Contributing
322
+
323
+ Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.
324
+
325
+ ## Support
326
+
327
+ For questions and support, please open an issue on our GitHub repository.
@@ -0,0 +1,296 @@
1
+ # isA Model - Unified AI Model Serving Framework
2
+
3
+ A comprehensive Python framework for working with multiple AI providers and models through a unified interface. Support for OpenAI, Replicate, Ollama, and more.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install isa-model
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ The isa-model package supports three main usage patterns:
14
+
15
+ ### 1. Pass API Keys Directly (Recommended)
16
+
17
+ This is the most flexible approach - no environment variables needed:
18
+
19
+ ```python
20
+ from isa_model.inference.ai_factory import AIFactory
21
+
22
+ # Create factory instance
23
+ factory = AIFactory.get_instance()
24
+
25
+ # Use OpenAI with API key
26
+ llm = factory.get_llm(
27
+ model_name="gpt-4o-mini",
28
+ provider="openai",
29
+ api_key="your-openai-api-key-here"
30
+ )
31
+
32
+ # Use Replicate for image generation
33
+ image_gen = factory.get_vision_model(
34
+ model_name="stability-ai/sdxl",
35
+ provider="replicate",
36
+ api_key="your-replicate-token-here"
37
+ )
38
+ ```
39
+
40
+ ### 2. Use Environment Variables
41
+
42
+ Set your API keys as environment variables:
43
+
44
+ ```bash
45
+ export OPENAI_API_KEY="your-openai-api-key"
46
+ export REPLICATE_API_TOKEN="your-replicate-token"
47
+ ```
48
+
49
+ Then use without passing keys:
50
+
51
+ ```python
52
+ from isa_model.inference.ai_factory import AIFactory
53
+
54
+ factory = AIFactory.get_instance()
55
+
56
+ # Will automatically use OPENAI_API_KEY from environment
57
+ llm = factory.get_llm(model_name="gpt-4o-mini", provider="openai")
58
+
59
+ # Will automatically use REPLICATE_API_TOKEN from environment
60
+ image_gen = factory.get_vision_model(model_name="stability-ai/sdxl", provider="replicate")
61
+ ```
62
+
63
+ ### 3. Use Local Models (No API Key Needed)
64
+
65
+ For local models like Ollama, no API keys are required:
66
+
67
+ ```python
68
+ from isa_model.inference.ai_factory import AIFactory
69
+
70
+ factory = AIFactory.get_instance()
71
+
72
+ # Use local Ollama model (no API key needed)
73
+ llm = factory.get_llm(model_name="llama3.1", provider="ollama")
74
+ ```
75
+
76
+ ## Supported Services
77
+
78
+ ### Language Models (LLM)
79
+
80
+ ```python
81
+ # OpenAI models
82
+ llm = factory.get_llm("gpt-4o-mini", "openai", api_key="your-key")
83
+ llm = factory.get_llm("gpt-4o", "openai", api_key="your-key")
84
+
85
+ # Ollama models (local)
86
+ llm = factory.get_llm("llama3.1", "ollama")
87
+ llm = factory.get_llm("codellama", "ollama")
88
+
89
+ # Replicate models
90
+ llm = factory.get_llm("meta/llama-3-70b-instruct", "replicate", api_key="your-token")
91
+ ```
92
+
93
+ ### Vision Models
94
+
95
+ ```python
96
+ # OpenAI vision
97
+ vision = factory.get_vision_model("gpt-4o", "openai", api_key="your-key")
98
+
99
+ # Replicate image generation
100
+ image_gen = factory.get_vision_model("stability-ai/sdxl", "replicate", api_key="your-token")
101
+
102
+ # Ollama vision (local)
103
+ vision = factory.get_vision_model("llava", "ollama")
104
+ ```
105
+
106
+ ### Embedding Models
107
+
108
+ ```python
109
+ # OpenAI embeddings
110
+ embedder = factory.get_embedding("text-embedding-3-small", "openai", {"api_key": "your-key"})
111
+
112
+ # Ollama embeddings (local)
113
+ embedder = factory.get_embedding("bge-m3", "ollama")
114
+ ```
115
+
116
+ ## Base Service Classes
117
+
118
+ The framework provides comprehensive base classes for implementing new AI services:
119
+
120
+ ### BaseLLMService
121
+ - `ainvoke()` - Universal invocation method
122
+ - `achat()` - Chat completion with messages
123
+ - `acompletion()` - Simple text completion
124
+ - `agenerate()` - Generate multiple completions
125
+ - `astream_chat()` - Streaming chat responses
126
+ - `get_token_usage()` - Token usage statistics
127
+
128
+ ### BaseVisionService
129
+ - `analyze_image()` - Analyze and describe images
130
+ - `describe_image()` - Generate detailed descriptions
131
+ - `extract_text()` - OCR text extraction
132
+ - `detect_objects()` - Object detection
133
+ - `classify_image()` - Image classification
134
+ - `compare_images()` - Image similarity comparison
135
+
136
+ ### BaseImageGenService
137
+ - `generate_image()` - Generate single image from text
138
+ - `generate_images()` - Generate multiple images
139
+ - `image_to_image()` - Transform existing images
140
+ - `get_supported_sizes()` - Get supported dimensions
141
+
142
+ ### BaseEmbedService
143
+ - `create_text_embedding()` - Single text embedding
144
+ - `create_text_embeddings()` - Batch text embeddings
145
+ - `compute_similarity()` - Similarity calculation
146
+ - `find_similar_texts()` - Semantic search
147
+
148
+ ### BaseSTTService (Speech-to-Text)
149
+ - `transcribe_audio()` - Audio transcription
150
+ - `transcribe_audio_batch()` - Batch transcription
151
+ - `detect_language()` - Language detection
152
+
153
+ ### BaseTTSService (Text-to-Speech)
154
+ - `synthesize_speech()` - Text to speech conversion
155
+ - `synthesize_speech_to_file()` - Save speech to file
156
+ - `get_available_voices()` - List available voices
157
+
158
+ ## Usage Examples
159
+
160
+ ### Chat Completion
161
+
162
+ ```python
163
+ import asyncio
164
+ from isa_model.inference.ai_factory import AIFactory
165
+
166
+ async def chat_example():
167
+ factory = AIFactory.get_instance()
168
+ llm = factory.get_llm("gpt-4o-mini", "openai", api_key="your-key")
169
+
170
+ messages = [
171
+ {"role": "user", "content": "Hello, how are you?"}
172
+ ]
173
+
174
+ response = await llm.achat(messages)
175
+ print(response)
176
+
177
+ # Run the async function
178
+ asyncio.run(chat_example())
179
+ ```
180
+
181
+ ### Image Analysis
182
+
183
+ ```python
184
+ import asyncio
185
+ from isa_model.inference.ai_factory import AIFactory
186
+
187
+ async def vision_example():
188
+ factory = AIFactory.get_instance()
189
+ vision = factory.get_vision_model("gpt-4o", "openai", api_key="your-key")
190
+
191
+ result = await vision.analyze_image(
192
+ image="path/to/your/image.jpg",
193
+ prompt="What do you see in this image?"
194
+ )
195
+
196
+ print(result["text"])
197
+
198
+ asyncio.run(vision_example())
199
+ ```
200
+
201
+ ### Image Generation
202
+
203
+ ```python
204
+ import asyncio
205
+ from isa_model.inference.ai_factory import AIFactory
206
+
207
+ async def image_gen_example():
208
+ factory = AIFactory.get_instance()
209
+ image_gen = factory.get_vision_model(
210
+ "stability-ai/sdxl",
211
+ "replicate",
212
+ api_key="your-replicate-token"
213
+ )
214
+
215
+ result = await image_gen.generate_image(
216
+ prompt="A beautiful sunset over mountains",
217
+ width=1024,
218
+ height=1024
219
+ )
220
+
221
+ # Save the generated image
222
+ with open("generated_image.png", "wb") as f:
223
+ f.write(result["image_data"])
224
+
225
+ asyncio.run(image_gen_example())
226
+ ```
227
+
228
+ ## Configuration Options
229
+
230
+ You can pass additional configuration options:
231
+
232
+ ```python
233
+ # Custom configuration
234
+ config = {
235
+ "temperature": 0.7,
236
+ "max_tokens": 1000,
237
+ "top_p": 0.9
238
+ }
239
+
240
+ llm = factory.get_llm(
241
+ model_name="gpt-4o-mini",
242
+ provider="openai",
243
+ config=config,
244
+ api_key="your-key"
245
+ )
246
+ ```
247
+
248
+ ## Error Handling
249
+
250
+ The framework provides informative error messages and graceful fallbacks:
251
+
252
+ ```python
253
+ try:
254
+ llm = factory.get_llm("gpt-4o-mini", "openai", api_key="invalid-key")
255
+ response = await llm.achat([{"role": "user", "content": "Hello"}])
256
+ except Exception as e:
257
+ print(f"Error: {e}")
258
+ ```
259
+
260
+ ## Development
261
+
262
+ ### Installing for Development
263
+
264
+ ```bash
265
+ git clone <repository-url>
266
+ cd isA_Model
267
+ pip install -e .
268
+ ```
269
+
270
+ ### Running Tests
271
+
272
+ ```bash
273
+ pytest tests/
274
+ ```
275
+
276
+ ### Building and Publishing
277
+
278
+ ```bash
279
+ # Build the package
280
+ python -m build
281
+
282
+ # Upload to PyPI (requires PYPI_API_TOKEN in .env.local)
283
+ bash scripts/normal_update.sh
284
+ ```
285
+
286
+ ## License
287
+
288
+ MIT License - see LICENSE file for details.
289
+
290
+ ## Contributing
291
+
292
+ Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.
293
+
294
+ ## Support
295
+
296
+ For questions and support, please open an issue on our GitHub repository.
@@ -2,4 +2,4 @@
2
2
  isA_Model - A simple interface for AI model integration
3
3
  """
4
4
 
5
- __version__ = "0.1.0"
5
+ __version__ = "0.1.1"