isa-model 0.3.5__py3-none-any.whl → 0.3.6__py3-none-any.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.
- isa_model/__init__.py +30 -1
- isa_model/client.py +770 -0
- isa_model/core/config/__init__.py +16 -0
- isa_model/core/config/config_manager.py +514 -0
- isa_model/core/config.py +426 -0
- isa_model/core/models/model_billing_tracker.py +476 -0
- isa_model/core/models/model_manager.py +399 -0
- isa_model/core/{storage/supabase_storage.py → models/model_repo.py} +72 -73
- isa_model/core/pricing_manager.py +426 -0
- isa_model/core/services/__init__.py +19 -0
- isa_model/core/services/intelligent_model_selector.py +547 -0
- isa_model/core/types.py +291 -0
- isa_model/deployment/__init__.py +2 -0
- isa_model/deployment/cloud/modal/isa_vision_doc_service.py +157 -3
- isa_model/deployment/cloud/modal/isa_vision_table_service.py +532 -0
- isa_model/deployment/cloud/modal/isa_vision_ui_service.py +104 -3
- isa_model/deployment/cloud/modal/register_models.py +321 -0
- isa_model/deployment/runtime/deployed_service.py +338 -0
- isa_model/deployment/services/__init__.py +9 -0
- isa_model/deployment/services/auto_deploy_vision_service.py +537 -0
- isa_model/deployment/services/model_service.py +332 -0
- isa_model/deployment/services/service_monitor.py +356 -0
- isa_model/deployment/services/service_registry.py +527 -0
- isa_model/eval/__init__.py +80 -44
- isa_model/eval/config/__init__.py +10 -0
- isa_model/eval/config/evaluation_config.py +108 -0
- isa_model/eval/evaluators/__init__.py +18 -0
- isa_model/eval/evaluators/base_evaluator.py +503 -0
- isa_model/eval/evaluators/llm_evaluator.py +472 -0
- isa_model/eval/factory.py +417 -709
- isa_model/eval/infrastructure/__init__.py +24 -0
- isa_model/eval/infrastructure/experiment_tracker.py +466 -0
- isa_model/eval/metrics.py +191 -21
- isa_model/inference/ai_factory.py +181 -605
- isa_model/inference/services/audio/base_stt_service.py +65 -1
- isa_model/inference/services/audio/base_tts_service.py +75 -1
- isa_model/inference/services/audio/openai_stt_service.py +189 -151
- isa_model/inference/services/audio/openai_tts_service.py +12 -10
- isa_model/inference/services/audio/replicate_tts_service.py +61 -56
- isa_model/inference/services/base_service.py +55 -17
- isa_model/inference/services/embedding/base_embed_service.py +65 -1
- isa_model/inference/services/embedding/ollama_embed_service.py +103 -43
- isa_model/inference/services/embedding/openai_embed_service.py +8 -10
- isa_model/inference/services/helpers/stacked_config.py +148 -0
- isa_model/inference/services/img/__init__.py +18 -0
- isa_model/inference/services/{vision → img}/base_image_gen_service.py +80 -1
- isa_model/inference/services/{stacked → img}/flux_professional_service.py +25 -1
- isa_model/inference/services/{stacked → img/helpers}/base_stacked_service.py +40 -35
- isa_model/inference/services/{vision → img}/replicate_image_gen_service.py +44 -31
- isa_model/inference/services/llm/__init__.py +3 -3
- isa_model/inference/services/llm/base_llm_service.py +492 -40
- isa_model/inference/services/llm/helpers/llm_prompts.py +258 -0
- isa_model/inference/services/llm/helpers/llm_utils.py +280 -0
- isa_model/inference/services/llm/ollama_llm_service.py +51 -17
- isa_model/inference/services/llm/openai_llm_service.py +70 -19
- isa_model/inference/services/llm/yyds_llm_service.py +24 -23
- isa_model/inference/services/vision/__init__.py +38 -4
- isa_model/inference/services/vision/base_vision_service.py +218 -117
- isa_model/inference/services/vision/{isA_vision_service.py → disabled/isA_vision_service.py} +98 -0
- isa_model/inference/services/{stacked → vision}/doc_analysis_service.py +1 -1
- isa_model/inference/services/vision/helpers/base_stacked_service.py +274 -0
- isa_model/inference/services/vision/helpers/image_utils.py +272 -3
- isa_model/inference/services/vision/helpers/vision_prompts.py +297 -0
- isa_model/inference/services/vision/openai_vision_service.py +104 -307
- isa_model/inference/services/vision/replicate_vision_service.py +140 -325
- isa_model/inference/services/{stacked → vision}/ui_analysis_service.py +2 -498
- isa_model/scripts/register_models.py +370 -0
- isa_model/scripts/register_models_with_embeddings.py +510 -0
- isa_model/serving/api/fastapi_server.py +6 -1
- isa_model/serving/api/routes/unified.py +202 -0
- {isa_model-0.3.5.dist-info → isa_model-0.3.6.dist-info}/METADATA +4 -1
- {isa_model-0.3.5.dist-info → isa_model-0.3.6.dist-info}/RECORD +77 -53
- isa_model/config/__init__.py +0 -9
- isa_model/config/config_manager.py +0 -213
- isa_model/core/model_manager.py +0 -213
- isa_model/core/model_registry.py +0 -375
- isa_model/core/vision_models_init.py +0 -116
- isa_model/inference/billing_tracker.py +0 -406
- isa_model/inference/services/llm/triton_llm_service.py +0 -481
- isa_model/inference/services/stacked/__init__.py +0 -26
- isa_model/inference/services/stacked/config.py +0 -426
- isa_model/inference/services/vision/ollama_vision_service.py +0 -194
- /isa_model/core/{model_storage.py → models/model_storage.py} +0 -0
- /isa_model/inference/services/{vision → embedding}/helpers/text_splitter.py +0 -0
- /isa_model/inference/services/llm/{llm_adapter.py → helpers/llm_adapter.py} +0 -0
- {isa_model-0.3.5.dist-info → isa_model-0.3.6.dist-info}/WHEEL +0 -0
- {isa_model-0.3.5.dist-info → isa_model-0.3.6.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,202 @@
|
|
1
|
+
"""
|
2
|
+
Unified API Route - Single endpoint for all AI services
|
3
|
+
|
4
|
+
This is the main API that handles all types of AI requests:
|
5
|
+
- Vision tasks (image analysis, OCR, UI detection)
|
6
|
+
- Text tasks (chat, generation, translation)
|
7
|
+
- Audio tasks (TTS, STT)
|
8
|
+
- Image generation tasks
|
9
|
+
- Embedding tasks
|
10
|
+
"""
|
11
|
+
|
12
|
+
from fastapi import APIRouter, HTTPException, UploadFile, File, Form
|
13
|
+
from pydantic import BaseModel, Field
|
14
|
+
from typing import Optional, Dict, Any, Union, List
|
15
|
+
import logging
|
16
|
+
import asyncio
|
17
|
+
from pathlib import Path
|
18
|
+
|
19
|
+
from isa_model.client import ISAModelClient
|
20
|
+
|
21
|
+
logger = logging.getLogger(__name__)
|
22
|
+
router = APIRouter()
|
23
|
+
|
24
|
+
class UnifiedRequest(BaseModel):
|
25
|
+
"""Unified request model for all AI services"""
|
26
|
+
input_data: Union[str, Dict[str, Any]] = Field(..., description="Input data (text, image URL, etc.)")
|
27
|
+
task: str = Field(..., description="Task to perform (chat, analyze_image, generate_speech, etc.)")
|
28
|
+
service_type: str = Field(..., description="Service type (text, vision, audio, image, embedding)")
|
29
|
+
model_hint: Optional[str] = Field(None, description="Optional model preference")
|
30
|
+
provider_hint: Optional[str] = Field(None, description="Optional provider preference")
|
31
|
+
parameters: Optional[Dict[str, Any]] = Field(default_factory=dict, description="Additional task parameters")
|
32
|
+
|
33
|
+
class UnifiedResponse(BaseModel):
|
34
|
+
"""Unified response model for all AI services"""
|
35
|
+
success: bool
|
36
|
+
result: Optional[Any] = None
|
37
|
+
error: Optional[str] = None
|
38
|
+
metadata: Dict[str, Any]
|
39
|
+
|
40
|
+
# Global ISA client instance for server-side processing
|
41
|
+
_isa_client = None
|
42
|
+
|
43
|
+
def get_isa_client():
|
44
|
+
"""Get or create ISA client for local processing"""
|
45
|
+
global _isa_client
|
46
|
+
if _isa_client is None:
|
47
|
+
_isa_client = ISAModelClient(mode="local") # Use local mode
|
48
|
+
return _isa_client
|
49
|
+
|
50
|
+
@router.get("/")
|
51
|
+
async def unified_info():
|
52
|
+
"""API information"""
|
53
|
+
return {
|
54
|
+
"service": "unified_api",
|
55
|
+
"status": "active",
|
56
|
+
"description": "Single endpoint for all AI services",
|
57
|
+
"supported_service_types": ["vision", "text", "audio", "image", "embedding"],
|
58
|
+
"version": "1.0.0"
|
59
|
+
}
|
60
|
+
|
61
|
+
@router.post("/invoke", response_model=UnifiedResponse)
|
62
|
+
async def unified_invoke(request: UnifiedRequest) -> UnifiedResponse:
|
63
|
+
"""
|
64
|
+
**Unified API endpoint for all AI services**
|
65
|
+
|
66
|
+
This single endpoint handles:
|
67
|
+
- Vision: image analysis, OCR, UI detection
|
68
|
+
- Text: chat, generation, translation
|
69
|
+
- Audio: TTS, STT, transcription
|
70
|
+
- Image: generation, img2img
|
71
|
+
- Embedding: text embedding, similarity
|
72
|
+
|
73
|
+
**Uses ISAModelClient in local mode - all the complex logic is in client.py**
|
74
|
+
"""
|
75
|
+
try:
|
76
|
+
# Get ISA client instance (local mode)
|
77
|
+
client = get_isa_client()
|
78
|
+
|
79
|
+
# Use client's local invoke method directly
|
80
|
+
# This handles all the complexity: model selection, service routing, execution
|
81
|
+
result = await client._invoke_local(
|
82
|
+
input_data=request.input_data,
|
83
|
+
task=request.task,
|
84
|
+
service_type=request.service_type,
|
85
|
+
model_hint=request.model_hint,
|
86
|
+
provider_hint=request.provider_hint,
|
87
|
+
**request.parameters
|
88
|
+
)
|
89
|
+
|
90
|
+
# Return the result in our API format
|
91
|
+
return UnifiedResponse(
|
92
|
+
success=result["success"],
|
93
|
+
result=result.get("result"),
|
94
|
+
error=result.get("error"),
|
95
|
+
metadata=result["metadata"]
|
96
|
+
)
|
97
|
+
|
98
|
+
except Exception as e:
|
99
|
+
logger.error(f"Unified invoke failed: {e}")
|
100
|
+
return UnifiedResponse(
|
101
|
+
success=False,
|
102
|
+
error=str(e),
|
103
|
+
metadata={
|
104
|
+
"task": request.task,
|
105
|
+
"service_type": request.service_type,
|
106
|
+
"model_hint": request.model_hint,
|
107
|
+
"provider_hint": request.provider_hint
|
108
|
+
}
|
109
|
+
)
|
110
|
+
|
111
|
+
@router.post("/invoke-file", response_model=UnifiedResponse)
|
112
|
+
async def unified_invoke_file(
|
113
|
+
task: str = Form(...),
|
114
|
+
service_type: str = Form(...),
|
115
|
+
model_hint: Optional[str] = Form(None),
|
116
|
+
provider_hint: Optional[str] = Form(None),
|
117
|
+
file: UploadFile = File(...)
|
118
|
+
) -> UnifiedResponse:
|
119
|
+
"""
|
120
|
+
Unified file upload endpoint
|
121
|
+
|
122
|
+
For tasks that require file input (images, audio, documents)
|
123
|
+
"""
|
124
|
+
try:
|
125
|
+
# Read file data
|
126
|
+
file_data = await file.read()
|
127
|
+
|
128
|
+
# Get ISA client instance (local mode)
|
129
|
+
client = get_isa_client()
|
130
|
+
|
131
|
+
# Use client's local invoke method with binary data
|
132
|
+
result = await client._invoke_local(
|
133
|
+
input_data=file_data, # Binary data
|
134
|
+
task=task,
|
135
|
+
service_type=service_type,
|
136
|
+
model_hint=model_hint,
|
137
|
+
provider_hint=provider_hint,
|
138
|
+
filename=file.filename,
|
139
|
+
content_type=file.content_type,
|
140
|
+
file_size=len(file_data)
|
141
|
+
)
|
142
|
+
|
143
|
+
# Return the result in our API format
|
144
|
+
return UnifiedResponse(
|
145
|
+
success=result["success"],
|
146
|
+
result=result.get("result"),
|
147
|
+
error=result.get("error"),
|
148
|
+
metadata={
|
149
|
+
**result["metadata"],
|
150
|
+
"filename": file.filename,
|
151
|
+
"content_type": file.content_type,
|
152
|
+
"file_size": len(file_data)
|
153
|
+
}
|
154
|
+
)
|
155
|
+
|
156
|
+
except Exception as e:
|
157
|
+
logger.error(f"File invoke failed: {e}")
|
158
|
+
return UnifiedResponse(
|
159
|
+
success=False,
|
160
|
+
error=str(e),
|
161
|
+
metadata={
|
162
|
+
"task": task,
|
163
|
+
"service_type": service_type,
|
164
|
+
"filename": file.filename if file else None
|
165
|
+
}
|
166
|
+
)
|
167
|
+
|
168
|
+
@router.get("/models")
|
169
|
+
async def get_available_models(service_type: Optional[str] = None):
|
170
|
+
"""Get available models (optional filter by service type)"""
|
171
|
+
try:
|
172
|
+
client = get_isa_client()
|
173
|
+
return await client.get_available_models(service_type)
|
174
|
+
except Exception as e:
|
175
|
+
logger.error(f"Failed to get available models: {e}")
|
176
|
+
# Fallback static model list
|
177
|
+
return {
|
178
|
+
"models": [
|
179
|
+
{"service_type": "vision", "provider": "openai", "model_id": "gpt-4.1-mini"},
|
180
|
+
{"service_type": "text", "provider": "openai", "model_id": "gpt-4.1-mini"},
|
181
|
+
{"service_type": "audio", "provider": "openai", "model_id": "whisper-1"},
|
182
|
+
{"service_type": "audio", "provider": "openai", "model_id": "tts-1"},
|
183
|
+
{"service_type": "embedding", "provider": "openai", "model_id": "text-embedding-3-small"},
|
184
|
+
{"service_type": "image", "provider": "replicate", "model_id": "black-forest-labs/flux-schnell"}
|
185
|
+
]
|
186
|
+
}
|
187
|
+
|
188
|
+
@router.get("/health")
|
189
|
+
async def health_check():
|
190
|
+
"""Health check for unified API"""
|
191
|
+
try:
|
192
|
+
client = get_isa_client()
|
193
|
+
health_result = await client.health_check()
|
194
|
+
return {
|
195
|
+
"api": "healthy",
|
196
|
+
"client_health": health_result
|
197
|
+
}
|
198
|
+
except Exception as e:
|
199
|
+
return {
|
200
|
+
"api": "error",
|
201
|
+
"error": str(e)
|
202
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: isa_model
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.6
|
4
4
|
Summary: Unified AI model serving framework
|
5
5
|
Author: isA_Model Contributors
|
6
6
|
Classifier: Development Status :: 3 - Alpha
|
@@ -34,6 +34,9 @@ Requires-Dist: accelerate>=0.20.0
|
|
34
34
|
Requires-Dist: bitsandbytes>=0.39.0
|
35
35
|
Requires-Dist: peft>=0.4.0
|
36
36
|
Requires-Dist: trl>=0.4.0
|
37
|
+
Requires-Dist: supabase>=2.0.0
|
38
|
+
Requires-Dist: pgvector>=0.2.0
|
39
|
+
Requires-Dist: psycopg2-binary>=2.9.0
|
37
40
|
|
38
41
|
# isa_model_sdk - Unified AI Model Serving Framework
|
39
42
|
|
@@ -1,19 +1,26 @@
|
|
1
|
-
isa_model/__init__.py,sha256=
|
2
|
-
isa_model/
|
3
|
-
isa_model/config
|
4
|
-
isa_model/core/
|
5
|
-
isa_model/core/
|
6
|
-
isa_model/core/
|
7
|
-
isa_model/core/
|
1
|
+
isa_model/__init__.py,sha256=bAbHdrDVQ-mySC_GJtgfLNI8KPcs2LfReBkIOOtpaQQ,867
|
2
|
+
isa_model/client.py,sha256=5u_hqGB1hcFX8MQdVYlCLqzs4ylQFY3rq91h3iTI24c,27500
|
3
|
+
isa_model/core/config.py,sha256=h9GVTEEMlaJYSCDd0W9q1KtaWTV5V5TawMsKtGuphds,15686
|
4
|
+
isa_model/core/pricing_manager.py,sha256=b7HcZsBQ8ZSCzMepOhqN-J9kU43vhTxX5NabQS0aM70,17125
|
5
|
+
isa_model/core/types.py,sha256=XLUs442WGNc8E0gF2M-nb6dutD_s-XCfpr2BfGBCA2M,8445
|
6
|
+
isa_model/core/config/__init__.py,sha256=SLeHQtYGDHl64NDVyb3ECQXOKepGM8YNHEoM8CVEWus,350
|
7
|
+
isa_model/core/config/config_manager.py,sha256=hx0qcdvYEE_cCp-qb8tnVkXnpsTXEuRM1108DoAiUnE,19905
|
8
|
+
isa_model/core/models/model_billing_tracker.py,sha256=hxqG5DvQ8kqROC3WVb5Y0tespp73TPPWYq-AwatMZwc,18782
|
9
|
+
isa_model/core/models/model_manager.py,sha256=9_JHok4i2q79dhFD3nckrlG-k3z8UGb6bM82iUR-T84,14917
|
10
|
+
isa_model/core/models/model_repo.py,sha256=OqvtUrvWmn_k4tkAgdOQ61NneUHsJGbUjkobJf3LNSw,14036
|
11
|
+
isa_model/core/models/model_storage.py,sha256=yMLapW87EY1EPXw6S7H8UQAZh3hJ1KxsEohjgjw-HrA,4507
|
12
|
+
isa_model/core/services/__init__.py,sha256=M1ob5N-PDPUW0o03ioHORRl5ye5ZEEzT7265-u-NrP4,481
|
13
|
+
isa_model/core/services/intelligent_model_selector.py,sha256=vf8BhITetIh5VJcccsESrHyeh9p-V6AHD9NRAEt6a5w,21501
|
8
14
|
isa_model/core/storage/hf_storage.py,sha256=HTj1-YGJM3Q-9_Adw7u4NjEmSdr0njsFEL45KXzfcFw,14701
|
9
15
|
isa_model/core/storage/local_storage.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
16
|
isa_model/core/storage/minio_storage.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
-
isa_model/
|
12
|
-
isa_model/deployment/__init__.py,sha256=Wu-sBbQtwx7wzWu_MRON3RPmI4y8UfhK8pGe12-iUzs,1323
|
17
|
+
isa_model/deployment/__init__.py,sha256=tzBOOvDXl6Hh8IiS2ehW6RKeUcBia_MY1uegQFFfFRg,1400
|
13
18
|
isa_model/deployment/cloud/__init__.py,sha256=ztahTvIZYNoEU_bqmVAvb3xL_ttWHAGO_UAiwQP4dHY,135
|
14
19
|
isa_model/deployment/cloud/modal/__init__.py,sha256=iD65eaqvI7L_W31p-tDO4fMIG5EWfkir1l3SKRSp72Y,265
|
15
|
-
isa_model/deployment/cloud/modal/isa_vision_doc_service.py,sha256=
|
16
|
-
isa_model/deployment/cloud/modal/
|
20
|
+
isa_model/deployment/cloud/modal/isa_vision_doc_service.py,sha256=GnIOwMNibXFqeA4ToUOovPxuj0NQTLXgkSbR1r6nUcU,30386
|
21
|
+
isa_model/deployment/cloud/modal/isa_vision_table_service.py,sha256=ewuRLIM1sqeet_7Vb9y1xcB1vXg2OAHVZNDfeFA_KHM,19814
|
22
|
+
isa_model/deployment/cloud/modal/isa_vision_ui_service.py,sha256=75iTaucfLYvWBqAvNdSXJT80R7hInYWOeLamxCyfteQ,14027
|
23
|
+
isa_model/deployment/cloud/modal/register_models.py,sha256=gqvKDE8hdwOlSyg5nWrAYNlQ0AjHa4aP9OhFBw7UXLw,12162
|
17
24
|
isa_model/deployment/core/__init__.py,sha256=QJkJrs0FYgYcjvnHMSvAtUBiT6uq_ciqLKWLwx0mkDg,803
|
18
25
|
isa_model/deployment/core/deployment_config.py,sha256=__bHohsvbdZK_rS_86S1rSHPPP1bTkOnx_G0cj1HMcA,11305
|
19
26
|
isa_model/deployment/core/deployment_manager.py,sha256=kICHX1V8wIlmldkrfdqakz2OAjitUfGY6ZG_QjGzZbM,20068
|
@@ -21,14 +28,26 @@ isa_model/deployment/core/isa_deployment_service.py,sha256=sXU7REZ4xhUUGrpqxlJh-
|
|
21
28
|
isa_model/deployment/gpu_int8_ds8/app/server.py,sha256=lwWxdnR2DNEd0vIGQyfabKtDSUzSHVQsy3Z_AJejpVg,2102
|
22
29
|
isa_model/deployment/gpu_int8_ds8/scripts/test_client.py,sha256=aCULgRYzEQj_ELUK1bmPgN99yvFgNR5C0O3gc8S32pg,1421
|
23
30
|
isa_model/deployment/gpu_int8_ds8/scripts/test_client_os.py,sha256=XXrneTCHUeh1LNRcu-YtZQ5B4pNawlrxC-cTWmJU2A8,936
|
24
|
-
isa_model/
|
31
|
+
isa_model/deployment/runtime/deployed_service.py,sha256=0Z_Hg42oXasEVvuKjwBylJPazcmJYXhS-L9uPainaIg,13400
|
32
|
+
isa_model/deployment/services/__init__.py,sha256=JrLlmBlLb6RfiqGMzVVxKZfF5tAKliQqpon_rPoNoeA,216
|
33
|
+
isa_model/deployment/services/auto_deploy_vision_service.py,sha256=Luo8FaXsEBoKjGw5HQ7veOnv9Eh0e7U0claXaGa3-1o,19624
|
34
|
+
isa_model/deployment/services/model_service.py,sha256=_ncC--8hr5BUwzCWh59yRXPKIPVLapx_31TorB2DIr8,13492
|
35
|
+
isa_model/deployment/services/service_monitor.py,sha256=P1zGoeqkNEJwt9AXZF2qTjfSLRm5PKUa80GJVNDSIdA,15223
|
36
|
+
isa_model/deployment/services/service_registry.py,sha256=LQgWQOvoP0lb7mC6WTS6shEt6WuX6xc8rRmcixrKwTc,22765
|
37
|
+
isa_model/eval/__init__.py,sha256=CRbxC5SN7ow4ymdALSNTHawqw4f82DEdAb7twNT_Pw0,2447
|
25
38
|
isa_model/eval/benchmarks.py,sha256=_L4Vwj2hwf2yhqoleIASO9z5e3LRCClCVEVCQbGt0I8,16885
|
26
|
-
isa_model/eval/factory.py,sha256=
|
27
|
-
isa_model/eval/metrics.py,sha256=
|
39
|
+
isa_model/eval/factory.py,sha256=bm5OVY7HIxdBgjlH1n7e5K1YO4ytv8e4KB7z_JS9HVQ,20737
|
40
|
+
isa_model/eval/metrics.py,sha256=VMQqcB13OScJsEmfuMZeBk5RLCs01zWknuMqQRVFCjo,30315
|
41
|
+
isa_model/eval/config/__init__.py,sha256=SDwprIRp1GSG7PAXJuyNldUZ6dPeuIcwdxCkHZXIeVQ,181
|
42
|
+
isa_model/eval/config/evaluation_config.py,sha256=y4tQAqafx5snoQ0QD239C9QXHmqcQvjH34uGSEJUhvI,3051
|
43
|
+
isa_model/eval/evaluators/__init__.py,sha256=bDMBhD8bTW740dQEt8Ru-nWPGiJHkyQQcfGEejgzkh4,461
|
44
|
+
isa_model/eval/evaluators/base_evaluator.py,sha256=1RivgnnuA-k9EtsZ-KMEtts_5gcfnaTGAoF-uBVSesE,19292
|
45
|
+
isa_model/eval/evaluators/llm_evaluator.py,sha256=yfFJFdxwGV2F3mzEWjZ-0fr9u8SR3A20UJ7zS7OgKsw,18054
|
46
|
+
isa_model/eval/infrastructure/__init__.py,sha256=fxTdtwAFtjCDOV9MJ3GbhY0A-DqKeTwr_u9WTBnGI_U,648
|
47
|
+
isa_model/eval/infrastructure/experiment_tracker.py,sha256=yfMWIAk6oA8Lfer3AtmKg0OEZiGhczmsCD5gmp--uew,15283
|
28
48
|
isa_model/inference/__init__.py,sha256=usfuQJ4zYY2RRtHkE-V6LuJ5aN7WJogtPUj9Qmy4Wvw,318
|
29
|
-
isa_model/inference/ai_factory.py,sha256=
|
49
|
+
isa_model/inference/ai_factory.py,sha256=IN-q3jNmcraZ-PWNTHyhdABoxxhIweZYcXO2fr_uXoM,16478
|
30
50
|
isa_model/inference/base.py,sha256=qwOddnSGI0GUdD6qIdGBPQpkW7UjU3Y-zaZvu70B4WA,1278
|
31
|
-
isa_model/inference/billing_tracker.py,sha256=uimayifP3oBZfU03qgveArJGl-1u6Vw2VTPj40O27t8,14888
|
32
51
|
isa_model/inference/adapter/unified_api.py,sha256=67_Ok8W20m6Otf6r9WyOEVpnxondP4UAxOASk9ozDk4,8668
|
33
52
|
isa_model/inference/providers/__init__.py,sha256=a83q-LMFv8u47wf0XtxvqOw_mlVgA_90wtuwy02qdDE,581
|
34
53
|
isa_model/inference/providers/base_provider.py,sha256=PT-YnGwBu-Jn_4T3iAphkAJw_mYmKVLjUID62vf2_Ow,2711
|
@@ -41,59 +60,64 @@ isa_model/inference/providers/replicate_provider.py,sha256=0oi_BglIE6-HYgzLau9if
|
|
41
60
|
isa_model/inference/providers/triton_provider.py,sha256=GKlth7cTOx6ERbsXXJ0gDNby3kVGQNULBDt098BXBSU,15258
|
42
61
|
isa_model/inference/providers/yyds_provider.py,sha256=KbDsopShs11_G9oX3b2i2NgHIqkZV7HYWe9K9uZLccc,4284
|
43
62
|
isa_model/inference/services/__init__.py,sha256=yfLz0YGl8ixk6LfTRL6cRTvZMb9F_Pv1QRgGyNc9xYM,386
|
44
|
-
isa_model/inference/services/base_service.py,sha256=
|
45
|
-
isa_model/inference/services/audio/base_stt_service.py,sha256=
|
46
|
-
isa_model/inference/services/audio/base_tts_service.py,sha256=
|
63
|
+
isa_model/inference/services/base_service.py,sha256=fVaSx0CogHK71UEsNJeSyM8mhqmq5_9ePbbSZVi3Al8,5085
|
64
|
+
isa_model/inference/services/audio/base_stt_service.py,sha256=sfzAfreFdvEOBHtphoTrQSjb-gCoCOW4WCj6iIe51oU,5804
|
65
|
+
isa_model/inference/services/audio/base_tts_service.py,sha256=PgctcV98Pe9I2kSjScsm8epRwdaEU-vAGCIfdd2P8us,6924
|
47
66
|
isa_model/inference/services/audio/openai_realtime_service.py,sha256=UENsx1bEb7aJoXNuBtFGIbTmETpNTZcCHlv0RydEp_U,13340
|
48
|
-
isa_model/inference/services/audio/openai_stt_service.py,sha256=
|
49
|
-
isa_model/inference/services/audio/openai_tts_service.py,sha256=
|
50
|
-
isa_model/inference/services/audio/replicate_tts_service.py,sha256=
|
51
|
-
isa_model/inference/services/embedding/base_embed_service.py,sha256=
|
52
|
-
isa_model/inference/services/embedding/ollama_embed_service.py,sha256=
|
53
|
-
isa_model/inference/services/embedding/openai_embed_service.py,sha256=
|
54
|
-
isa_model/inference/services/
|
55
|
-
isa_model/inference/services/
|
56
|
-
isa_model/inference/services/
|
57
|
-
isa_model/inference/services/
|
58
|
-
isa_model/inference/services/
|
59
|
-
isa_model/inference/services/
|
60
|
-
isa_model/inference/services/
|
67
|
+
isa_model/inference/services/audio/openai_stt_service.py,sha256=chqVuSU8JtwkqY6Y7INm0AdSoDqh-bsg9POzJkxN3h0,10989
|
68
|
+
isa_model/inference/services/audio/openai_tts_service.py,sha256=C4vIRvCKoySs4-zBEteI_DZYZsATS84W_ZUwbxjJjpA,8253
|
69
|
+
isa_model/inference/services/audio/replicate_tts_service.py,sha256=kCG_bBNgW7GQwt5-ZdwPSqsMiTV54-FhSowFwNWGvg0,10292
|
70
|
+
isa_model/inference/services/embedding/base_embed_service.py,sha256=_9HLzwDfKXbhFWT_3VbLQpDF3N1Rr3JS-QXqAZM9Wyc,6045
|
71
|
+
isa_model/inference/services/embedding/ollama_embed_service.py,sha256=Pbc3jePaEsudHOn07BSf_A525weoesH3d3r5vs8ODvc,6702
|
72
|
+
isa_model/inference/services/embedding/openai_embed_service.py,sha256=Egzq0sxFWf5lndf12xijLuvJSw1wnLeU9wdNR9pnzkQ,8342
|
73
|
+
isa_model/inference/services/embedding/helpers/text_splitter.py,sha256=6AbvcQ7H6MS54B9d9T1XBGg4GhvmKfZqp00lKp9pF-U,1635
|
74
|
+
isa_model/inference/services/helpers/stacked_config.py,sha256=xPGvWBu364qSF5RXAefAdsqC9SUHC6frTtJamQRQZX8,5473
|
75
|
+
isa_model/inference/services/img/__init__.py,sha256=Mip969-_UGRAADfDlcXEBPrsYY7sZleztolcjjmKfyA,518
|
76
|
+
isa_model/inference/services/img/base_image_gen_service.py,sha256=PECzUood4E25Bh2hAbe-d62nB6CwRbg1pORdDkLlEjg,7194
|
77
|
+
isa_model/inference/services/img/flux_professional_service.py,sha256=c-3F9ANUuYiZPG4SgsOgb6jTDFIXWD52Kz-RC9g_a-Q,26407
|
78
|
+
isa_model/inference/services/img/replicate_image_gen_service.py,sha256=QLjgrXNmtdXmKQPCLkmrTjNPL7_icy6enWmeArRCicU,17240
|
79
|
+
isa_model/inference/services/img/helpers/base_stacked_service.py,sha256=Y2g2Hz3n2Uwo4RoCbsC33IXxTeQ2TeT6T-2HnXd-2B0,10546
|
80
|
+
isa_model/inference/services/llm/__init__.py,sha256=hSdfeqE0463CtQ6ZzREqPBvtzXNuzi3W5PFKS0nwhvo,336
|
81
|
+
isa_model/inference/services/llm/base_llm_service.py,sha256=fg79J5mKy27qahvtLscMcquOe4O2L-EoNjE33yPRI9E,22196
|
82
|
+
isa_model/inference/services/llm/ollama_llm_service.py,sha256=c0i9TLce6YcPlsLpj11kvwd-H2Uvw23G0ACuNShGyAM,16009
|
83
|
+
isa_model/inference/services/llm/openai_llm_service.py,sha256=yhqsExCWvVs6G7EhwZnoXMtKncpwY1VPeZqgLibMSX0,11922
|
84
|
+
isa_model/inference/services/llm/yyds_llm_service.py,sha256=WA5vwK9j7PrEEffdvP4thNwBlZ5Z13vFXX_F3Kd5V-Y,10475
|
85
|
+
isa_model/inference/services/llm/helpers/llm_adapter.py,sha256=gkKND55EoizRxsaGOCEazUmL-2yTIBI-_njpEOXt-4k,21779
|
86
|
+
isa_model/inference/services/llm/helpers/llm_prompts.py,sha256=4ZOovr_Jx5bwPiMkgO1lZF7GMyEFbITP3ZrhhI48QMs,10964
|
87
|
+
isa_model/inference/services/llm/helpers/llm_utils.py,sha256=LNfB3qzREyD2TyleOyVa20FU8HbhdxA8G6QV-N-wfZs,10016
|
61
88
|
isa_model/inference/services/ml/base_ml_service.py,sha256=mLBA6ENowa3KVzNqHyhWxf_Pr-cJJj84lDE4TniPzYI,2894
|
62
89
|
isa_model/inference/services/ml/sklearn_ml_service.py,sha256=Lf9JrwvI25lca7JBbjB_e66eAUtXFbwxZ3Hs13dVGkA,5512
|
63
90
|
isa_model/inference/services/others/table_transformer_service.py,sha256=r74h6QUSwSj6jTt-gRProz9SgwBwKWDe50NR0uqW0ZI,2367
|
64
|
-
isa_model/inference/services/
|
65
|
-
isa_model/inference/services/
|
66
|
-
isa_model/inference/services/
|
67
|
-
isa_model/inference/services/
|
68
|
-
isa_model/inference/services/
|
69
|
-
isa_model/inference/services/
|
70
|
-
isa_model/inference/services/vision/
|
71
|
-
isa_model/inference/services/vision/
|
72
|
-
isa_model/inference/services/vision/
|
73
|
-
isa_model/inference/services/vision/
|
74
|
-
isa_model/inference/services/vision/ollama_vision_service.py,sha256=Btm3jJmnSBcJDiTujr51eWC3a3eA_58xKMj5TsatXJQ,6821
|
75
|
-
isa_model/inference/services/vision/openai_vision_service.py,sha256=aGjYI5jRzL73hchFFLb1077rnnoUFDJ_EEV14EjqJG8,18686
|
76
|
-
isa_model/inference/services/vision/replicate_image_gen_service.py,sha256=NMOPNTLKOJi_SF86pI5mgvGIO1IMEEiU9TmBbRcfLXM,16509
|
77
|
-
isa_model/inference/services/vision/replicate_vision_service.py,sha256=UtuC_jrSD_ZYwLbrRZPzTo5ElXHQNYyAywcwTHaXpTM,28474
|
78
|
-
isa_model/inference/services/vision/helpers/image_utils.py,sha256=ieEL69LQ9-T4zsSFj2Mmt2jRUU_UOUAgt1W6Je9kaa8,1800
|
79
|
-
isa_model/inference/services/vision/helpers/text_splitter.py,sha256=6AbvcQ7H6MS54B9d9T1XBGg4GhvmKfZqp00lKp9pF-U,1635
|
91
|
+
isa_model/inference/services/vision/__init__.py,sha256=9JkNzwZa6WQPUXtq4i7x78mPxkzBNRB-6CkU2WyoCYE,1191
|
92
|
+
isa_model/inference/services/vision/base_vision_service.py,sha256=FInmrdhKaeu0vBUbxScH3_B9a_fk3pj2foLx0P81a6o,12645
|
93
|
+
isa_model/inference/services/vision/doc_analysis_service.py,sha256=_klnuI99tSkA1gcs5hPQmj6Ld8GElg0S823LXa9id2Y,24797
|
94
|
+
isa_model/inference/services/vision/openai_vision_service.py,sha256=IcDX0nBPqt9TJSwMEUD89Fojz1X8jF3ZD1voJGOzu4A,9609
|
95
|
+
isa_model/inference/services/vision/replicate_vision_service.py,sha256=smRkSCTwk5mvyKVnvyplqPNuVYjRZngVBWxTCbFmrxA,20679
|
96
|
+
isa_model/inference/services/vision/ui_analysis_service.py,sha256=LTFY5rMIQwgWh_kh9KWA44ZI01Mb3We5NsG2scSgBeA,32153
|
97
|
+
isa_model/inference/services/vision/disabled/isA_vision_service.py,sha256=VYa8VJtxDB9KdnfNW0GPEP_TPker4pHp33gLD_TnpaM,18336
|
98
|
+
isa_model/inference/services/vision/helpers/base_stacked_service.py,sha256=Y2g2Hz3n2Uwo4RoCbsC33IXxTeQ2TeT6T-2HnXd-2B0,10546
|
99
|
+
isa_model/inference/services/vision/helpers/image_utils.py,sha256=7RZ368o2UXcRCqyzldUOGhzB5vWbCCJOVR24UdiVdhs,11061
|
100
|
+
isa_model/inference/services/vision/helpers/vision_prompts.py,sha256=WbzOYu-Z2-8Xn9dcvuPRTA7VTy23_uoMRRGO4t0wZ8Q,12098
|
80
101
|
isa_model/inference/utils/conversion/bge_rerank_convert.py,sha256=1dvtxe5-PPCe2Au6SO8F2XaD-xdIoeA4zDTcid2L9FU,2691
|
81
102
|
isa_model/inference/utils/conversion/onnx_converter.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
82
103
|
isa_model/inference/utils/conversion/torch_converter.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
83
104
|
isa_model/scripts/inference_tracker.py,sha256=T6qQJMHJcAIQ8eYlgqpM9RWxfiV4z5xIolaoglKBBsg,8831
|
84
105
|
isa_model/scripts/mlflow_manager.py,sha256=7xMN0_wELr1jcALuTW9WeWirRkPZPlE2LlFfZKflXBY,12142
|
85
106
|
isa_model/scripts/model_registry.py,sha256=7rycPkVk8WHUO3LJaHfdyy5Yq8qmd_4WkGk4wKan-2w,14279
|
107
|
+
isa_model/scripts/register_models.py,sha256=ukqhUFiXkZh2IGzJTjEKpqRpf6VW4oSYm4PP_JjYcM8,14658
|
108
|
+
isa_model/scripts/register_models_with_embeddings.py,sha256=A4utiT5_uqvgMQJ9qioIZM2XMreHLgJoqZOysNbzmM8,20990
|
86
109
|
isa_model/scripts/start_mlflow.py,sha256=3AGKBzByjzbZ56I8w0IOfYnp3V6EU2Lv9NtX9maSqL8,2571
|
87
110
|
isa_model/scripts/training_tracker.py,sha256=cnXPi8ip2OK76-aWAOgC-dKx90PqZLEnP6UbHso7Fwc,8080
|
88
111
|
isa_model/serving/__init__.py,sha256=LTO0Adbvm7A-bgQqtuOQSoHvdu9OH3OrEjYgQanuHgI,429
|
89
112
|
isa_model/serving/api/__init__.py,sha256=wgWD69eqV37fFTLxhz8b0rOn_34P7SZHoWw2sufWjk4,162
|
90
|
-
isa_model/serving/api/fastapi_server.py,sha256=
|
113
|
+
isa_model/serving/api/fastapi_server.py,sha256=UP3CZim8E2tNcyUGaoU9cYM80_yzzpWQFd3ADfo6ANk,2628
|
91
114
|
isa_model/serving/api/middleware/__init__.py,sha256=iCKUYECf0bjNGXgV91K03hb8Dnp0Jc_wnUL897Rd0sg,163
|
92
115
|
isa_model/serving/api/middleware/request_logger.py,sha256=d48n6tp1pqZ7HFWFl8jg6er24ugWkWkMOc1y80aqPU8,2938
|
93
116
|
isa_model/serving/api/routes/__init__.py,sha256=RIaG9OPg0AjAIVbtMzwnqGyNU-tuQXbdvFcYOt4b_Do,84
|
94
117
|
isa_model/serving/api/routes/health.py,sha256=NwQcC_bpcaI4YZHTIKbGtg82yQ6QLdp0TwcqbEiqbWs,2208
|
95
118
|
isa_model/serving/api/routes/llm.py,sha256=5ZVxWugff0i6VBKz_Nv5CqacMZJsPZEKyoSB6XDrW34,385
|
96
119
|
isa_model/serving/api/routes/ui_analysis.py,sha256=-WxLaRKQNHnRh4okB85cWA4blTegpEPZtzHTsF3yeeU,6848
|
120
|
+
isa_model/serving/api/routes/unified.py,sha256=rSoHPtMWkGlzFwzzoZeFlCmFGWj2r3q-5QH9VeNQQxA,7074
|
97
121
|
isa_model/serving/api/routes/vision.py,sha256=U9jxssQYe6igtayUW0C2fcYwqmLRIE15__X-5Ru9J4c,396
|
98
122
|
isa_model/serving/api/schemas/__init__.py,sha256=Tu_hzxoKW1ZHpww3-5ER4A2hNuDByZ0rAfrgaJ7Bs-M,275
|
99
123
|
isa_model/serving/api/schemas/common.py,sha256=HVaAS7wlvqrwC1gMZ2Cvo0vzHB053x2uOTAwUoY2vsE,696
|
@@ -117,7 +141,7 @@ isa_model/training/core/config.py,sha256=oqgKpBvtzrN6jwLIQYQ2707lH6nmjrktRiSxp9i
|
|
117
141
|
isa_model/training/core/dataset.py,sha256=XCFsnf0NUMU1dJpdvo_CAMyvXB-9_RCUEiy8TU50e20,7802
|
118
142
|
isa_model/training/core/trainer.py,sha256=h5TjqjdFr0Fsv5y4-0siy1KmOlqLfliVaUXybvuoeXU,26932
|
119
143
|
isa_model/training/core/utils.py,sha256=Nik0M2ssfNbWqP6fKO0Kfyhzr_H6Q19ioxB-qCYbn5E,8387
|
120
|
-
isa_model-0.3.
|
121
|
-
isa_model-0.3.
|
122
|
-
isa_model-0.3.
|
123
|
-
isa_model-0.3.
|
144
|
+
isa_model-0.3.6.dist-info/METADATA,sha256=TMGcK76gGTCDWcXfCp17JuAoWxVN4TfVv5Nu-8mN8JE,12326
|
145
|
+
isa_model-0.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
146
|
+
isa_model-0.3.6.dist-info/top_level.txt,sha256=eHSy_Xb3kNkh2kK11mi1mZh0Wz91AQ5b8k2KFYO-rE8,10
|
147
|
+
isa_model-0.3.6.dist-info/RECORD,,
|
isa_model/config/__init__.py
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Configuration Management Module
|
3
|
-
|
4
|
-
Unified configuration system for all ISA Model components
|
5
|
-
"""
|
6
|
-
|
7
|
-
from .config_manager import ConfigManager, get_config, DeploymentConfig, ModelConfig
|
8
|
-
|
9
|
-
__all__ = ["ConfigManager", "get_config", "DeploymentConfig", "ModelConfig"]
|
@@ -1,213 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Configuration Manager
|
3
|
-
|
4
|
-
Central configuration management with environment support
|
5
|
-
"""
|
6
|
-
|
7
|
-
import os
|
8
|
-
import yaml
|
9
|
-
from typing import Dict, Any, Optional
|
10
|
-
from pathlib import Path
|
11
|
-
from dataclasses import dataclass
|
12
|
-
import logging
|
13
|
-
|
14
|
-
logger = logging.getLogger(__name__)
|
15
|
-
|
16
|
-
@dataclass
|
17
|
-
class ConfigSection:
|
18
|
-
"""Base configuration section"""
|
19
|
-
def to_dict(self) -> Dict[str, Any]:
|
20
|
-
return self.__dict__
|
21
|
-
|
22
|
-
@dataclass
|
23
|
-
class DeploymentConfig(ConfigSection):
|
24
|
-
"""Deployment configuration"""
|
25
|
-
platform: str = "replicate" # replicate, modal, aws, local
|
26
|
-
modal_app_name: str = "isa-ui-analysis"
|
27
|
-
modal_gpu_type: str = "A100-40GB"
|
28
|
-
modal_memory: int = 32768
|
29
|
-
modal_timeout: int = 1800
|
30
|
-
modal_keep_warm: int = 1
|
31
|
-
|
32
|
-
@dataclass
|
33
|
-
class ModelConfig(ConfigSection):
|
34
|
-
"""Model configuration"""
|
35
|
-
ui_detection_model: str = "microsoft/omniparser-v2"
|
36
|
-
ui_planning_model: str = "gpt-4o-mini"
|
37
|
-
fallback_detection: str = "yolov8n"
|
38
|
-
quantization: bool = False
|
39
|
-
batch_size: int = 1
|
40
|
-
|
41
|
-
@dataclass
|
42
|
-
class ServingConfig(ConfigSection):
|
43
|
-
"""Serving configuration"""
|
44
|
-
host: str = "0.0.0.0"
|
45
|
-
port: int = 8000
|
46
|
-
workers: int = 1
|
47
|
-
reload: bool = False
|
48
|
-
log_level: str = "info"
|
49
|
-
cors_origins: list = None
|
50
|
-
|
51
|
-
def __post_init__(self):
|
52
|
-
if self.cors_origins is None:
|
53
|
-
self.cors_origins = ["*"]
|
54
|
-
|
55
|
-
@dataclass
|
56
|
-
class APIConfig(ConfigSection):
|
57
|
-
"""API configuration"""
|
58
|
-
rate_limit: int = 100 # requests per minute
|
59
|
-
max_file_size: int = 10 * 1024 * 1024 # 10MB
|
60
|
-
cache_ttl: int = 3600 # 1 hour
|
61
|
-
enable_auth: bool = False
|
62
|
-
|
63
|
-
@dataclass
|
64
|
-
class ISAConfig:
|
65
|
-
"""Complete ISA configuration"""
|
66
|
-
environment: str
|
67
|
-
deployment: DeploymentConfig
|
68
|
-
models: ModelConfig
|
69
|
-
serving: ServingConfig
|
70
|
-
api: APIConfig
|
71
|
-
|
72
|
-
def to_dict(self) -> Dict[str, Any]:
|
73
|
-
return {
|
74
|
-
"environment": self.environment,
|
75
|
-
"deployment": self.deployment.to_dict(),
|
76
|
-
"models": self.models.to_dict(),
|
77
|
-
"serving": self.serving.to_dict(),
|
78
|
-
"api": self.api.to_dict()
|
79
|
-
}
|
80
|
-
|
81
|
-
class ConfigManager:
|
82
|
-
"""Configuration manager with environment support"""
|
83
|
-
|
84
|
-
_instance = None
|
85
|
-
_config = None
|
86
|
-
|
87
|
-
def __new__(cls):
|
88
|
-
if cls._instance is None:
|
89
|
-
cls._instance = super(ConfigManager, cls).__new__(cls)
|
90
|
-
return cls._instance
|
91
|
-
|
92
|
-
def __init__(self):
|
93
|
-
if self._config is None:
|
94
|
-
self._load_config()
|
95
|
-
|
96
|
-
def _load_config(self):
|
97
|
-
"""Load configuration from environment and files"""
|
98
|
-
env = os.getenv("ISA_ENV", "development")
|
99
|
-
|
100
|
-
# Default configurations
|
101
|
-
default_config = {
|
102
|
-
"deployment": DeploymentConfig(),
|
103
|
-
"models": ModelConfig(),
|
104
|
-
"serving": ServingConfig(),
|
105
|
-
"api": APIConfig()
|
106
|
-
}
|
107
|
-
|
108
|
-
# Load environment-specific configuration
|
109
|
-
config_file = self._get_config_file(env)
|
110
|
-
if config_file and config_file.exists():
|
111
|
-
try:
|
112
|
-
with open(config_file, 'r') as f:
|
113
|
-
file_config = yaml.safe_load(f)
|
114
|
-
|
115
|
-
# Merge configurations
|
116
|
-
self._config = self._merge_configs(default_config, file_config, env)
|
117
|
-
logger.info(f"Loaded configuration for environment: {env}")
|
118
|
-
|
119
|
-
except Exception as e:
|
120
|
-
logger.warning(f"Failed to load config file {config_file}: {e}")
|
121
|
-
self._config = ISAConfig(environment=env, **default_config)
|
122
|
-
else:
|
123
|
-
logger.info(f"No config file found for {env}, using defaults")
|
124
|
-
self._config = ISAConfig(environment=env, **default_config)
|
125
|
-
|
126
|
-
# Override with environment variables
|
127
|
-
self._apply_env_overrides()
|
128
|
-
|
129
|
-
def _get_config_file(self, env: str) -> Optional[Path]:
|
130
|
-
"""Get configuration file path for environment"""
|
131
|
-
# Try to find config file in multiple locations
|
132
|
-
possible_paths = [
|
133
|
-
Path(__file__).parent / "environments" / f"{env}.yaml",
|
134
|
-
Path.cwd() / "config" / f"{env}.yaml",
|
135
|
-
Path.cwd() / f"config_{env}.yaml"
|
136
|
-
]
|
137
|
-
|
138
|
-
for path in possible_paths:
|
139
|
-
if path.exists():
|
140
|
-
return path
|
141
|
-
return None
|
142
|
-
|
143
|
-
def _merge_configs(self, default: Dict, file_config: Dict, env: str) -> ISAConfig:
|
144
|
-
"""Merge default and file configurations"""
|
145
|
-
|
146
|
-
# Update deployment config
|
147
|
-
deployment_data = {**default["deployment"].__dict__}
|
148
|
-
if "deployment" in file_config:
|
149
|
-
deployment_data.update(file_config["deployment"])
|
150
|
-
deployment = DeploymentConfig(**deployment_data)
|
151
|
-
|
152
|
-
# Update model config
|
153
|
-
models_data = {**default["models"].__dict__}
|
154
|
-
if "models" in file_config:
|
155
|
-
models_data.update(file_config["models"])
|
156
|
-
models = ModelConfig(**models_data)
|
157
|
-
|
158
|
-
# Update serving config
|
159
|
-
serving_data = {**default["serving"].__dict__}
|
160
|
-
if "serving" in file_config:
|
161
|
-
serving_data.update(file_config["serving"])
|
162
|
-
serving = ServingConfig(**serving_data)
|
163
|
-
|
164
|
-
# Update API config
|
165
|
-
api_data = {**default["api"].__dict__}
|
166
|
-
if "api" in file_config:
|
167
|
-
api_data.update(file_config["api"])
|
168
|
-
api = APIConfig(**api_data)
|
169
|
-
|
170
|
-
return ISAConfig(
|
171
|
-
environment=env,
|
172
|
-
deployment=deployment,
|
173
|
-
models=models,
|
174
|
-
serving=serving,
|
175
|
-
api=api
|
176
|
-
)
|
177
|
-
|
178
|
-
def _apply_env_overrides(self):
|
179
|
-
"""Apply environment variable overrides"""
|
180
|
-
# Deployment overrides
|
181
|
-
if os.getenv("ISA_DEPLOYMENT_PLATFORM"):
|
182
|
-
self._config.deployment.platform = os.getenv("ISA_DEPLOYMENT_PLATFORM")
|
183
|
-
|
184
|
-
# Model overrides
|
185
|
-
if os.getenv("ISA_UI_DETECTION_MODEL"):
|
186
|
-
self._config.models.ui_detection_model = os.getenv("ISA_UI_DETECTION_MODEL")
|
187
|
-
|
188
|
-
# Serving overrides
|
189
|
-
if os.getenv("ISA_SERVING_PORT"):
|
190
|
-
self._config.serving.port = int(os.getenv("ISA_SERVING_PORT"))
|
191
|
-
|
192
|
-
if os.getenv("ISA_SERVING_HOST"):
|
193
|
-
self._config.serving.host = os.getenv("ISA_SERVING_HOST")
|
194
|
-
|
195
|
-
def get_config(self) -> ISAConfig:
|
196
|
-
"""Get current configuration"""
|
197
|
-
return self._config
|
198
|
-
|
199
|
-
def reload(self):
|
200
|
-
"""Reload configuration"""
|
201
|
-
self._config = None
|
202
|
-
self._load_config()
|
203
|
-
|
204
|
-
# Singleton instance
|
205
|
-
_config_manager = ConfigManager()
|
206
|
-
|
207
|
-
def get_config() -> ISAConfig:
|
208
|
-
"""Get configuration instance"""
|
209
|
-
return _config_manager.get_config()
|
210
|
-
|
211
|
-
def reload_config():
|
212
|
-
"""Reload configuration"""
|
213
|
-
_config_manager.reload()
|