isa-model 0.3.9__py3-none-any.whl → 0.4.0__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 +1 -1
- isa_model/client.py +732 -565
- isa_model/core/cache/redis_cache.py +401 -0
- isa_model/core/config/config_manager.py +53 -10
- isa_model/core/config.py +1 -1
- isa_model/core/database/__init__.py +1 -0
- isa_model/core/database/migrations.py +277 -0
- isa_model/core/database/supabase_client.py +123 -0
- isa_model/core/models/__init__.py +37 -0
- isa_model/core/models/model_billing_tracker.py +60 -88
- isa_model/core/models/model_manager.py +36 -18
- isa_model/core/models/model_repo.py +44 -38
- isa_model/core/models/model_statistics_tracker.py +234 -0
- isa_model/core/models/model_storage.py +0 -1
- isa_model/core/models/model_version_manager.py +959 -0
- isa_model/core/pricing_manager.py +2 -249
- isa_model/core/resilience/circuit_breaker.py +366 -0
- isa_model/core/security/secrets.py +358 -0
- isa_model/core/services/__init__.py +2 -4
- isa_model/core/services/intelligent_model_selector.py +101 -370
- isa_model/core/storage/hf_storage.py +1 -1
- isa_model/core/types.py +7 -0
- isa_model/deployment/cloud/modal/isa_audio_chatTTS_service.py +520 -0
- isa_model/deployment/cloud/modal/isa_audio_fish_service.py +0 -0
- isa_model/deployment/cloud/modal/isa_audio_openvoice_service.py +758 -0
- isa_model/deployment/cloud/modal/isa_audio_service_v2.py +1044 -0
- isa_model/deployment/cloud/modal/isa_embed_rerank_service.py +296 -0
- isa_model/deployment/cloud/modal/isa_video_hunyuan_service.py +423 -0
- isa_model/deployment/cloud/modal/isa_vision_ocr_service.py +519 -0
- isa_model/deployment/cloud/modal/isa_vision_qwen25_service.py +709 -0
- isa_model/deployment/cloud/modal/isa_vision_table_service.py +467 -323
- isa_model/deployment/cloud/modal/isa_vision_ui_service.py +607 -180
- isa_model/deployment/cloud/modal/isa_vision_ui_service_optimized.py +660 -0
- isa_model/deployment/core/deployment_manager.py +6 -4
- isa_model/deployment/services/auto_hf_modal_deployer.py +894 -0
- isa_model/eval/benchmarks/__init__.py +27 -0
- isa_model/eval/benchmarks/multimodal_datasets.py +460 -0
- isa_model/eval/benchmarks.py +244 -12
- isa_model/eval/evaluators/__init__.py +8 -2
- isa_model/eval/evaluators/audio_evaluator.py +727 -0
- isa_model/eval/evaluators/embedding_evaluator.py +742 -0
- isa_model/eval/evaluators/vision_evaluator.py +564 -0
- isa_model/eval/example_evaluation.py +395 -0
- isa_model/eval/factory.py +272 -5
- isa_model/eval/isa_benchmarks.py +700 -0
- isa_model/eval/isa_integration.py +582 -0
- isa_model/eval/metrics.py +159 -6
- isa_model/eval/tests/unit/test_basic.py +396 -0
- isa_model/inference/ai_factory.py +44 -8
- isa_model/inference/services/audio/__init__.py +21 -0
- isa_model/inference/services/audio/base_realtime_service.py +225 -0
- isa_model/inference/services/audio/isa_tts_service.py +0 -0
- isa_model/inference/services/audio/openai_realtime_service.py +320 -124
- isa_model/inference/services/audio/openai_stt_service.py +32 -6
- isa_model/inference/services/base_service.py +17 -1
- isa_model/inference/services/embedding/__init__.py +13 -0
- isa_model/inference/services/embedding/base_embed_service.py +111 -8
- isa_model/inference/services/embedding/isa_embed_service.py +305 -0
- isa_model/inference/services/embedding/openai_embed_service.py +2 -4
- isa_model/inference/services/embedding/tests/test_embedding.py +222 -0
- isa_model/inference/services/img/__init__.py +2 -2
- isa_model/inference/services/img/base_image_gen_service.py +24 -7
- isa_model/inference/services/img/replicate_image_gen_service.py +84 -422
- isa_model/inference/services/img/services/replicate_face_swap.py +193 -0
- isa_model/inference/services/img/services/replicate_flux.py +226 -0
- isa_model/inference/services/img/services/replicate_flux_kontext.py +219 -0
- isa_model/inference/services/img/services/replicate_sticker_maker.py +249 -0
- isa_model/inference/services/img/tests/test_img_client.py +297 -0
- isa_model/inference/services/llm/base_llm_service.py +30 -6
- isa_model/inference/services/llm/helpers/llm_adapter.py +63 -9
- isa_model/inference/services/llm/ollama_llm_service.py +2 -1
- isa_model/inference/services/llm/openai_llm_service.py +652 -55
- isa_model/inference/services/llm/yyds_llm_service.py +2 -1
- isa_model/inference/services/vision/__init__.py +5 -5
- isa_model/inference/services/vision/base_vision_service.py +118 -185
- isa_model/inference/services/vision/helpers/image_utils.py +11 -5
- isa_model/inference/services/vision/isa_vision_service.py +573 -0
- isa_model/inference/services/vision/tests/test_ocr_client.py +284 -0
- isa_model/serving/api/fastapi_server.py +88 -16
- isa_model/serving/api/middleware/auth.py +311 -0
- isa_model/serving/api/middleware/security.py +278 -0
- isa_model/serving/api/routes/analytics.py +486 -0
- isa_model/serving/api/routes/deployments.py +339 -0
- isa_model/serving/api/routes/evaluations.py +579 -0
- isa_model/serving/api/routes/logs.py +430 -0
- isa_model/serving/api/routes/settings.py +582 -0
- isa_model/serving/api/routes/unified.py +324 -165
- isa_model/serving/api/startup.py +304 -0
- isa_model/serving/modal_proxy_server.py +249 -0
- isa_model/training/__init__.py +100 -6
- isa_model/training/core/__init__.py +4 -1
- isa_model/training/examples/intelligent_training_example.py +281 -0
- isa_model/training/intelligent/__init__.py +25 -0
- isa_model/training/intelligent/decision_engine.py +643 -0
- isa_model/training/intelligent/intelligent_factory.py +888 -0
- isa_model/training/intelligent/knowledge_base.py +751 -0
- isa_model/training/intelligent/resource_optimizer.py +839 -0
- isa_model/training/intelligent/task_classifier.py +576 -0
- isa_model/training/storage/__init__.py +24 -0
- isa_model/training/storage/core_integration.py +439 -0
- isa_model/training/storage/training_repository.py +552 -0
- isa_model/training/storage/training_storage.py +628 -0
- {isa_model-0.3.9.dist-info → isa_model-0.4.0.dist-info}/METADATA +13 -1
- isa_model-0.4.0.dist-info/RECORD +182 -0
- isa_model/deployment/cloud/modal/isa_vision_doc_service.py +0 -766
- isa_model/deployment/cloud/modal/register_models.py +0 -321
- isa_model/inference/adapter/unified_api.py +0 -248
- isa_model/inference/services/helpers/stacked_config.py +0 -148
- isa_model/inference/services/img/flux_professional_service.py +0 -603
- isa_model/inference/services/img/helpers/base_stacked_service.py +0 -274
- isa_model/inference/services/others/table_transformer_service.py +0 -61
- isa_model/inference/services/vision/doc_analysis_service.py +0 -640
- isa_model/inference/services/vision/helpers/base_stacked_service.py +0 -274
- isa_model/inference/services/vision/ui_analysis_service.py +0 -823
- isa_model/scripts/inference_tracker.py +0 -283
- isa_model/scripts/mlflow_manager.py +0 -379
- isa_model/scripts/model_registry.py +0 -465
- isa_model/scripts/register_models.py +0 -370
- isa_model/scripts/register_models_with_embeddings.py +0 -510
- isa_model/scripts/start_mlflow.py +0 -95
- isa_model/scripts/training_tracker.py +0 -257
- isa_model-0.3.9.dist-info/RECORD +0 -138
- {isa_model-0.3.9.dist-info → isa_model-0.4.0.dist-info}/WHEEL +0 -0
- {isa_model-0.3.9.dist-info → isa_model-0.4.0.dist-info}/top_level.txt +0 -0
@@ -427,15 +427,69 @@ class StandardMessageAdapter:
|
|
427
427
|
|
428
428
|
def from_openai_format(self, response: Union[str, Any], original_input: Any) -> Any:
|
429
429
|
"""从 OpenAI 格式转换回原始格式"""
|
430
|
-
#
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
else:
|
436
|
-
# Handle simple string response
|
430
|
+
# For consistency, always return a message object similar to LangChain
|
431
|
+
try:
|
432
|
+
from langchain_core.messages import AIMessage
|
433
|
+
|
434
|
+
# Extract content
|
437
435
|
content = response if isinstance(response, str) else getattr(response, 'content', str(response))
|
438
|
-
|
436
|
+
|
437
|
+
# Handle tool_calls if present
|
438
|
+
if hasattr(response, 'tool_calls') and response.tool_calls:
|
439
|
+
# Convert to LangChain format tool_calls
|
440
|
+
tool_calls = []
|
441
|
+
for tc in response.tool_calls:
|
442
|
+
if hasattr(tc, 'function'):
|
443
|
+
# OpenAI format: tc.function.name, tc.function.arguments
|
444
|
+
try:
|
445
|
+
import json
|
446
|
+
args = json.loads(tc.function.arguments) if tc.function.arguments else {}
|
447
|
+
except:
|
448
|
+
args = {}
|
449
|
+
|
450
|
+
tool_call = {
|
451
|
+
"name": tc.function.name,
|
452
|
+
"args": args,
|
453
|
+
"id": getattr(tc, 'id', 'unknown'),
|
454
|
+
"type": "tool_call"
|
455
|
+
}
|
456
|
+
tool_calls.append(tool_call)
|
457
|
+
|
458
|
+
return AIMessage(content=content, tool_calls=tool_calls)
|
459
|
+
else:
|
460
|
+
return AIMessage(content=content)
|
461
|
+
|
462
|
+
except ImportError:
|
463
|
+
# Fallback: create a simple message object
|
464
|
+
class SimpleAIMessage:
|
465
|
+
def __init__(self, content, tool_calls=None):
|
466
|
+
self.content = content
|
467
|
+
self.type = "ai"
|
468
|
+
self.tool_calls = tool_calls or []
|
469
|
+
|
470
|
+
# Handle tool_calls if present
|
471
|
+
if hasattr(response, 'tool_calls') and response.tool_calls:
|
472
|
+
tool_calls = []
|
473
|
+
for tc in response.tool_calls:
|
474
|
+
if hasattr(tc, 'function'):
|
475
|
+
try:
|
476
|
+
import json
|
477
|
+
args = json.loads(tc.function.arguments) if tc.function.arguments else {}
|
478
|
+
except:
|
479
|
+
args = {}
|
480
|
+
|
481
|
+
tool_call = {
|
482
|
+
"name": tc.function.name,
|
483
|
+
"args": args,
|
484
|
+
"id": getattr(tc, 'id', 'unknown'),
|
485
|
+
"type": "tool_call"
|
486
|
+
}
|
487
|
+
tool_calls.append(tool_call)
|
488
|
+
|
489
|
+
return SimpleAIMessage(content, tool_calls)
|
490
|
+
else:
|
491
|
+
content = response if isinstance(response, str) else getattr(response, 'content', str(response))
|
492
|
+
return SimpleAIMessage(content)
|
439
493
|
|
440
494
|
|
441
495
|
# ============= 适配器管理器 =============
|
@@ -504,7 +558,7 @@ class AdapterManager:
|
|
504
558
|
# 不应该到这里,因为有回退适配器
|
505
559
|
return [{"role": "user", "content": str(input_data)}]
|
506
560
|
|
507
|
-
def format_response(self, response: str, original_input: Any) -> Any:
|
561
|
+
def format_response(self, response: Union[str, Any], original_input: Any) -> Any:
|
508
562
|
"""格式化响应"""
|
509
563
|
for adapter in self.message_adapters:
|
510
564
|
if adapter.can_handle(original_input):
|
@@ -143,7 +143,8 @@ class OllamaLLMService(BaseLLMService):
|
|
143
143
|
async def chat(
|
144
144
|
self,
|
145
145
|
input_data: Union[str, List[Dict[str, str]], Any],
|
146
|
-
max_tokens: Optional[int] = None
|
146
|
+
max_tokens: Optional[int] = None,
|
147
|
+
show_reasoning: bool = False
|
147
148
|
) -> Dict[str, Any]:
|
148
149
|
"""
|
149
150
|
Chat method that wraps ainvoke for compatibility with base class
|