isa-model 0.3.4__py3-none-any.whl → 0.3.5__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/config/__init__.py +9 -0
- isa_model/config/config_manager.py +213 -0
- isa_model/core/model_manager.py +5 -0
- isa_model/core/model_registry.py +39 -6
- isa_model/core/storage/supabase_storage.py +344 -0
- isa_model/core/vision_models_init.py +116 -0
- isa_model/deployment/cloud/__init__.py +9 -0
- isa_model/deployment/cloud/modal/__init__.py +10 -0
- isa_model/deployment/cloud/modal/isa_vision_doc_service.py +612 -0
- isa_model/deployment/cloud/modal/isa_vision_ui_service.py +305 -0
- isa_model/inference/ai_factory.py +238 -14
- isa_model/inference/providers/modal_provider.py +109 -0
- isa_model/inference/providers/yyds_provider.py +108 -0
- isa_model/inference/services/__init__.py +2 -1
- isa_model/inference/services/base_service.py +0 -38
- isa_model/inference/services/llm/base_llm_service.py +32 -0
- isa_model/inference/services/llm/llm_adapter.py +40 -0
- isa_model/inference/services/llm/ollama_llm_service.py +104 -3
- isa_model/inference/services/llm/openai_llm_service.py +67 -15
- isa_model/inference/services/llm/yyds_llm_service.py +254 -0
- isa_model/inference/services/stacked/__init__.py +26 -0
- isa_model/inference/services/stacked/base_stacked_service.py +269 -0
- isa_model/inference/services/stacked/config.py +426 -0
- isa_model/inference/services/stacked/doc_analysis_service.py +640 -0
- isa_model/inference/services/stacked/flux_professional_service.py +579 -0
- isa_model/inference/services/stacked/ui_analysis_service.py +1319 -0
- isa_model/inference/services/vision/base_image_gen_service.py +0 -34
- isa_model/inference/services/vision/base_vision_service.py +46 -2
- isa_model/inference/services/vision/isA_vision_service.py +402 -0
- isa_model/inference/services/vision/openai_vision_service.py +151 -9
- isa_model/inference/services/vision/replicate_image_gen_service.py +166 -38
- isa_model/inference/services/vision/replicate_vision_service.py +693 -0
- isa_model/serving/__init__.py +19 -0
- isa_model/serving/api/__init__.py +10 -0
- isa_model/serving/api/fastapi_server.py +84 -0
- isa_model/serving/api/middleware/__init__.py +9 -0
- isa_model/serving/api/middleware/request_logger.py +88 -0
- isa_model/serving/api/routes/__init__.py +5 -0
- isa_model/serving/api/routes/health.py +82 -0
- isa_model/serving/api/routes/llm.py +19 -0
- isa_model/serving/api/routes/ui_analysis.py +223 -0
- isa_model/serving/api/routes/vision.py +19 -0
- isa_model/serving/api/schemas/__init__.py +17 -0
- isa_model/serving/api/schemas/common.py +33 -0
- isa_model/serving/api/schemas/ui_analysis.py +78 -0
- {isa_model-0.3.4.dist-info → isa_model-0.3.5.dist-info}/METADATA +1 -1
- {isa_model-0.3.4.dist-info → isa_model-0.3.5.dist-info}/RECORD +49 -17
- {isa_model-0.3.4.dist-info → isa_model-0.3.5.dist-info}/WHEEL +0 -0
- {isa_model-0.3.4.dist-info → isa_model-0.3.5.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,426 @@
|
|
1
|
+
"""
|
2
|
+
Configuration system for stacked services
|
3
|
+
"""
|
4
|
+
|
5
|
+
from typing import Dict, Any, List
|
6
|
+
from dataclasses import dataclass, field
|
7
|
+
from enum import Enum
|
8
|
+
|
9
|
+
from .base_stacked_service import LayerConfig, LayerType
|
10
|
+
|
11
|
+
class WorkflowType(Enum):
|
12
|
+
"""Predefined workflow types"""
|
13
|
+
UI_ANALYSIS_FAST = "ui_analysis_fast"
|
14
|
+
UI_ANALYSIS_ACCURATE = "ui_analysis_accurate"
|
15
|
+
UI_ANALYSIS_COMPREHENSIVE = "ui_analysis_comprehensive"
|
16
|
+
SEARCH_PAGE_ANALYSIS = "search_page_analysis"
|
17
|
+
CONTENT_EXTRACTION = "content_extraction"
|
18
|
+
FORM_INTERACTION = "form_interaction"
|
19
|
+
NAVIGATION_ANALYSIS = "navigation_analysis"
|
20
|
+
CUSTOM = "custom"
|
21
|
+
|
22
|
+
@dataclass
|
23
|
+
class StackedServiceConfig:
|
24
|
+
"""Configuration for a stacked service workflow"""
|
25
|
+
name: str
|
26
|
+
workflow_type: WorkflowType
|
27
|
+
layers: List[LayerConfig] = field(default_factory=list)
|
28
|
+
global_timeout: float = 120.0
|
29
|
+
parallel_execution: bool = False
|
30
|
+
fail_fast: bool = False
|
31
|
+
metadata: Dict[str, Any] = field(default_factory=dict)
|
32
|
+
|
33
|
+
class ConfigManager:
|
34
|
+
"""Manager for stacked service configurations"""
|
35
|
+
|
36
|
+
PREDEFINED_CONFIGS = {
|
37
|
+
WorkflowType.UI_ANALYSIS_FAST: {
|
38
|
+
"name": "Fast UI Analysis",
|
39
|
+
"layers": [
|
40
|
+
LayerConfig(
|
41
|
+
name="page_intelligence",
|
42
|
+
layer_type=LayerType.INTELLIGENCE,
|
43
|
+
service_type="vision",
|
44
|
+
model_name="gpt-4.1-nano",
|
45
|
+
parameters={"max_tokens": 300},
|
46
|
+
depends_on=[],
|
47
|
+
timeout=10.0,
|
48
|
+
fallback_enabled=True
|
49
|
+
),
|
50
|
+
LayerConfig(
|
51
|
+
name="element_detection",
|
52
|
+
layer_type=LayerType.DETECTION,
|
53
|
+
service_type="vision",
|
54
|
+
model_name="omniparser",
|
55
|
+
parameters={
|
56
|
+
"imgsz": 480,
|
57
|
+
"box_threshold": 0.08,
|
58
|
+
"iou_threshold": 0.2
|
59
|
+
},
|
60
|
+
depends_on=["page_intelligence"],
|
61
|
+
timeout=15.0,
|
62
|
+
fallback_enabled=True
|
63
|
+
),
|
64
|
+
LayerConfig(
|
65
|
+
name="element_classification",
|
66
|
+
layer_type=LayerType.CLASSIFICATION,
|
67
|
+
service_type="vision",
|
68
|
+
model_name="gpt-4.1-nano",
|
69
|
+
parameters={"max_tokens": 200},
|
70
|
+
depends_on=["page_intelligence", "element_detection"],
|
71
|
+
timeout=20.0,
|
72
|
+
fallback_enabled=False
|
73
|
+
)
|
74
|
+
],
|
75
|
+
"global_timeout": 60.0,
|
76
|
+
"parallel_execution": False,
|
77
|
+
"fail_fast": False,
|
78
|
+
"metadata": {
|
79
|
+
"description": "Fast UI analysis optimized for speed",
|
80
|
+
"expected_time": "30-45 seconds",
|
81
|
+
"accuracy": "medium"
|
82
|
+
}
|
83
|
+
},
|
84
|
+
|
85
|
+
WorkflowType.UI_ANALYSIS_ACCURATE: {
|
86
|
+
"name": "Accurate UI Analysis",
|
87
|
+
"layers": [
|
88
|
+
LayerConfig(
|
89
|
+
name="page_intelligence",
|
90
|
+
layer_type=LayerType.INTELLIGENCE,
|
91
|
+
service_type="vision",
|
92
|
+
model_name="gpt-4-vision-preview",
|
93
|
+
parameters={"max_tokens": 800},
|
94
|
+
depends_on=[],
|
95
|
+
timeout=20.0,
|
96
|
+
fallback_enabled=True
|
97
|
+
),
|
98
|
+
LayerConfig(
|
99
|
+
name="element_detection",
|
100
|
+
layer_type=LayerType.DETECTION,
|
101
|
+
service_type="vision",
|
102
|
+
model_name="omniparser",
|
103
|
+
parameters={
|
104
|
+
"imgsz": 640,
|
105
|
+
"box_threshold": 0.05,
|
106
|
+
"iou_threshold": 0.1
|
107
|
+
},
|
108
|
+
depends_on=["page_intelligence"],
|
109
|
+
timeout=25.0,
|
110
|
+
fallback_enabled=True
|
111
|
+
),
|
112
|
+
LayerConfig(
|
113
|
+
name="element_classification",
|
114
|
+
layer_type=LayerType.CLASSIFICATION,
|
115
|
+
service_type="vision",
|
116
|
+
model_name="gpt-4-vision-preview",
|
117
|
+
parameters={"max_tokens": 500},
|
118
|
+
depends_on=["page_intelligence", "element_detection"],
|
119
|
+
timeout=30.0,
|
120
|
+
fallback_enabled=False
|
121
|
+
)
|
122
|
+
],
|
123
|
+
"global_timeout": 90.0,
|
124
|
+
"parallel_execution": False,
|
125
|
+
"fail_fast": False,
|
126
|
+
"metadata": {
|
127
|
+
"description": "Balanced UI analysis for production use",
|
128
|
+
"expected_time": "60-75 seconds",
|
129
|
+
"accuracy": "high"
|
130
|
+
}
|
131
|
+
},
|
132
|
+
|
133
|
+
WorkflowType.SEARCH_PAGE_ANALYSIS: {
|
134
|
+
"name": "Search Page Analysis",
|
135
|
+
"layers": [
|
136
|
+
LayerConfig(
|
137
|
+
name="page_intelligence",
|
138
|
+
layer_type=LayerType.INTELLIGENCE,
|
139
|
+
service_type="vision",
|
140
|
+
model_name="default",
|
141
|
+
parameters={
|
142
|
+
"task": "search_page_intelligence",
|
143
|
+
"max_tokens": 400
|
144
|
+
},
|
145
|
+
depends_on=[],
|
146
|
+
timeout=15.0,
|
147
|
+
fallback_enabled=True
|
148
|
+
),
|
149
|
+
LayerConfig(
|
150
|
+
name="element_detection",
|
151
|
+
layer_type=LayerType.DETECTION,
|
152
|
+
service_type="vision",
|
153
|
+
model_name="omniparser",
|
154
|
+
parameters={
|
155
|
+
"task": "element_detection",
|
156
|
+
"imgsz": 640,
|
157
|
+
"box_threshold": 0.05,
|
158
|
+
"iou_threshold": 0.1
|
159
|
+
},
|
160
|
+
depends_on=["page_intelligence"],
|
161
|
+
timeout=20.0,
|
162
|
+
fallback_enabled=True
|
163
|
+
),
|
164
|
+
LayerConfig(
|
165
|
+
name="element_classification",
|
166
|
+
layer_type=LayerType.CLASSIFICATION,
|
167
|
+
service_type="vision",
|
168
|
+
model_name="default",
|
169
|
+
parameters={
|
170
|
+
"task": "search_element_classification",
|
171
|
+
"max_tokens": 300
|
172
|
+
},
|
173
|
+
depends_on=["page_intelligence", "element_detection"],
|
174
|
+
timeout=25.0,
|
175
|
+
fallback_enabled=False
|
176
|
+
)
|
177
|
+
],
|
178
|
+
"global_timeout": 80.0,
|
179
|
+
"parallel_execution": False,
|
180
|
+
"fail_fast": False,
|
181
|
+
"metadata": {
|
182
|
+
"description": "Analysis for search pages (Google, Bing, etc.)",
|
183
|
+
"expected_time": "45-60 seconds",
|
184
|
+
"accuracy": "high",
|
185
|
+
"page_types": ["search", "query", "results"]
|
186
|
+
}
|
187
|
+
},
|
188
|
+
|
189
|
+
WorkflowType.CONTENT_EXTRACTION: {
|
190
|
+
"name": "Content Extraction",
|
191
|
+
"layers": [
|
192
|
+
LayerConfig(
|
193
|
+
name="page_intelligence",
|
194
|
+
layer_type=LayerType.INTELLIGENCE,
|
195
|
+
service_type="vision",
|
196
|
+
model_name="default",
|
197
|
+
parameters={
|
198
|
+
"task": "content_page_intelligence",
|
199
|
+
"max_tokens": 500
|
200
|
+
},
|
201
|
+
depends_on=[],
|
202
|
+
timeout=15.0,
|
203
|
+
fallback_enabled=True
|
204
|
+
),
|
205
|
+
LayerConfig(
|
206
|
+
name="content_detection",
|
207
|
+
layer_type=LayerType.DETECTION,
|
208
|
+
service_type="vision",
|
209
|
+
model_name="florence-2",
|
210
|
+
parameters={
|
211
|
+
"task": "<OPEN_VOCABULARY_DETECTION>",
|
212
|
+
"text_input": "article content, text blocks, headings, paragraphs, links"
|
213
|
+
},
|
214
|
+
depends_on=["page_intelligence"],
|
215
|
+
timeout=25.0,
|
216
|
+
fallback_enabled=True
|
217
|
+
),
|
218
|
+
LayerConfig(
|
219
|
+
name="content_classification",
|
220
|
+
layer_type=LayerType.CLASSIFICATION,
|
221
|
+
service_type="vision",
|
222
|
+
model_name="default",
|
223
|
+
parameters={
|
224
|
+
"task": "content_classification",
|
225
|
+
"max_tokens": 400
|
226
|
+
},
|
227
|
+
depends_on=["page_intelligence", "content_detection"],
|
228
|
+
timeout=30.0,
|
229
|
+
fallback_enabled=False
|
230
|
+
)
|
231
|
+
],
|
232
|
+
"global_timeout": 90.0,
|
233
|
+
"parallel_execution": False,
|
234
|
+
"fail_fast": False,
|
235
|
+
"metadata": {
|
236
|
+
"description": "Extract and analyze content from web pages",
|
237
|
+
"expected_time": "60-75 seconds",
|
238
|
+
"accuracy": "high",
|
239
|
+
"page_types": ["article", "blog", "news", "documentation"]
|
240
|
+
}
|
241
|
+
},
|
242
|
+
|
243
|
+
WorkflowType.UI_ANALYSIS_COMPREHENSIVE: {
|
244
|
+
"name": "Comprehensive UI Analysis",
|
245
|
+
"layers": [
|
246
|
+
LayerConfig(
|
247
|
+
name="page_intelligence",
|
248
|
+
layer_type=LayerType.INTELLIGENCE,
|
249
|
+
service_type="vision",
|
250
|
+
model_name="gpt-4-vision-preview",
|
251
|
+
parameters={"max_tokens": 1000},
|
252
|
+
depends_on=[],
|
253
|
+
timeout=25.0,
|
254
|
+
fallback_enabled=True
|
255
|
+
),
|
256
|
+
LayerConfig(
|
257
|
+
name="primary_detection",
|
258
|
+
layer_type=LayerType.DETECTION,
|
259
|
+
service_type="vision",
|
260
|
+
model_name="omniparser",
|
261
|
+
parameters={
|
262
|
+
"imgsz": 1024,
|
263
|
+
"box_threshold": 0.03,
|
264
|
+
"iou_threshold": 0.1
|
265
|
+
},
|
266
|
+
depends_on=["page_intelligence"],
|
267
|
+
timeout=30.0,
|
268
|
+
fallback_enabled=True
|
269
|
+
),
|
270
|
+
LayerConfig(
|
271
|
+
name="secondary_detection",
|
272
|
+
layer_type=LayerType.DETECTION,
|
273
|
+
service_type="vision",
|
274
|
+
model_name="florence-2",
|
275
|
+
parameters={
|
276
|
+
"task": "<OPEN_VOCABULARY_DETECTION>",
|
277
|
+
"text_input": "login form elements, input fields, buttons, checkboxes"
|
278
|
+
},
|
279
|
+
depends_on=["page_intelligence"],
|
280
|
+
timeout=25.0,
|
281
|
+
fallback_enabled=True
|
282
|
+
),
|
283
|
+
LayerConfig(
|
284
|
+
name="detection_fusion",
|
285
|
+
layer_type=LayerType.TRANSFORMATION,
|
286
|
+
service_type="custom",
|
287
|
+
model_name="fusion_algorithm",
|
288
|
+
parameters={"fusion_method": "confidence_weighted"},
|
289
|
+
depends_on=["primary_detection", "secondary_detection"],
|
290
|
+
timeout=5.0,
|
291
|
+
fallback_enabled=False
|
292
|
+
),
|
293
|
+
LayerConfig(
|
294
|
+
name="element_classification",
|
295
|
+
layer_type=LayerType.CLASSIFICATION,
|
296
|
+
service_type="vision",
|
297
|
+
model_name="gpt-4-vision-preview",
|
298
|
+
parameters={"max_tokens": 600},
|
299
|
+
depends_on=["page_intelligence", "detection_fusion"],
|
300
|
+
timeout=40.0,
|
301
|
+
fallback_enabled=False
|
302
|
+
),
|
303
|
+
LayerConfig(
|
304
|
+
name="result_validation",
|
305
|
+
layer_type=LayerType.VALIDATION,
|
306
|
+
service_type="vision",
|
307
|
+
model_name="gpt-4.1-nano",
|
308
|
+
parameters={"validation_criteria": ["completeness", "consistency", "accuracy"]},
|
309
|
+
depends_on=["element_classification"],
|
310
|
+
timeout=15.0,
|
311
|
+
fallback_enabled=True
|
312
|
+
)
|
313
|
+
],
|
314
|
+
"global_timeout": 180.0,
|
315
|
+
"parallel_execution": True, # Enable parallel execution for detection layers
|
316
|
+
"fail_fast": False,
|
317
|
+
"metadata": {
|
318
|
+
"description": "Most comprehensive UI analysis with multi-model fusion",
|
319
|
+
"expected_time": "120-150 seconds",
|
320
|
+
"accuracy": "very high"
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|
324
|
+
|
325
|
+
@classmethod
|
326
|
+
def get_config(cls, workflow_type: WorkflowType) -> StackedServiceConfig:
|
327
|
+
"""Get predefined configuration for a workflow type"""
|
328
|
+
if workflow_type not in cls.PREDEFINED_CONFIGS:
|
329
|
+
raise ValueError(f"Unknown workflow type: {workflow_type}")
|
330
|
+
|
331
|
+
config_data = cls.PREDEFINED_CONFIGS[workflow_type]
|
332
|
+
|
333
|
+
return StackedServiceConfig(
|
334
|
+
name=config_data["name"],
|
335
|
+
workflow_type=workflow_type,
|
336
|
+
layers=config_data["layers"],
|
337
|
+
global_timeout=config_data["global_timeout"],
|
338
|
+
parallel_execution=config_data["parallel_execution"],
|
339
|
+
fail_fast=config_data["fail_fast"],
|
340
|
+
metadata=config_data["metadata"]
|
341
|
+
)
|
342
|
+
|
343
|
+
@classmethod
|
344
|
+
def create_custom_config(
|
345
|
+
cls,
|
346
|
+
name: str,
|
347
|
+
layers: List[LayerConfig],
|
348
|
+
global_timeout: float = 120.0,
|
349
|
+
parallel_execution: bool = False,
|
350
|
+
fail_fast: bool = False,
|
351
|
+
metadata: Dict[str, Any] = None
|
352
|
+
) -> StackedServiceConfig:
|
353
|
+
"""Create a custom configuration"""
|
354
|
+
return StackedServiceConfig(
|
355
|
+
name=name,
|
356
|
+
workflow_type=WorkflowType.CUSTOM,
|
357
|
+
layers=layers,
|
358
|
+
global_timeout=global_timeout,
|
359
|
+
parallel_execution=parallel_execution,
|
360
|
+
fail_fast=fail_fast,
|
361
|
+
metadata=metadata or {}
|
362
|
+
)
|
363
|
+
|
364
|
+
@classmethod
|
365
|
+
def modify_config(
|
366
|
+
cls,
|
367
|
+
base_config: StackedServiceConfig,
|
368
|
+
modifications: Dict[str, Any]
|
369
|
+
) -> StackedServiceConfig:
|
370
|
+
"""Modify an existing configuration"""
|
371
|
+
# Create a copy
|
372
|
+
new_config = StackedServiceConfig(
|
373
|
+
name=base_config.name,
|
374
|
+
workflow_type=base_config.workflow_type,
|
375
|
+
layers=base_config.layers.copy(),
|
376
|
+
global_timeout=base_config.global_timeout,
|
377
|
+
parallel_execution=base_config.parallel_execution,
|
378
|
+
fail_fast=base_config.fail_fast,
|
379
|
+
metadata=base_config.metadata.copy()
|
380
|
+
)
|
381
|
+
|
382
|
+
# Apply modifications
|
383
|
+
for key, value in modifications.items():
|
384
|
+
if hasattr(new_config, key):
|
385
|
+
setattr(new_config, key, value)
|
386
|
+
elif key == "layer_modifications":
|
387
|
+
# Modify specific layers
|
388
|
+
for layer_name, layer_mods in value.items():
|
389
|
+
for layer in new_config.layers:
|
390
|
+
if layer.name == layer_name:
|
391
|
+
for mod_key, mod_value in layer_mods.items():
|
392
|
+
if hasattr(layer, mod_key):
|
393
|
+
setattr(layer, mod_key, mod_value)
|
394
|
+
elif mod_key == "parameters":
|
395
|
+
layer.parameters.update(mod_value)
|
396
|
+
|
397
|
+
return new_config
|
398
|
+
|
399
|
+
@classmethod
|
400
|
+
def get_available_workflows(cls) -> Dict[WorkflowType, Dict[str, Any]]:
|
401
|
+
"""Get information about all available workflows"""
|
402
|
+
workflows = {}
|
403
|
+
|
404
|
+
for workflow_type in cls.PREDEFINED_CONFIGS:
|
405
|
+
config_data = cls.PREDEFINED_CONFIGS[workflow_type]
|
406
|
+
workflows[workflow_type] = {
|
407
|
+
"name": config_data["name"],
|
408
|
+
"layer_count": len(config_data["layers"]),
|
409
|
+
"expected_time": config_data["metadata"].get("expected_time", "unknown"),
|
410
|
+
"accuracy": config_data["metadata"].get("accuracy", "unknown"),
|
411
|
+
"description": config_data["metadata"].get("description", "")
|
412
|
+
}
|
413
|
+
|
414
|
+
return workflows
|
415
|
+
|
416
|
+
# Convenience function for quick access
|
417
|
+
def get_ui_analysis_config(speed: str = "accurate") -> StackedServiceConfig:
|
418
|
+
"""Get UI analysis configuration by speed preference"""
|
419
|
+
speed_mapping = {
|
420
|
+
"fast": WorkflowType.UI_ANALYSIS_FAST,
|
421
|
+
"accurate": WorkflowType.UI_ANALYSIS_ACCURATE,
|
422
|
+
"comprehensive": WorkflowType.UI_ANALYSIS_COMPREHENSIVE
|
423
|
+
}
|
424
|
+
|
425
|
+
workflow_type = speed_mapping.get(speed.lower(), WorkflowType.UI_ANALYSIS_ACCURATE)
|
426
|
+
return ConfigManager.get_config(workflow_type)
|