isa-model 0.3.7__py3-none-any.whl → 0.3.9__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 +41 -5
- isa_model/core/pricing_manager.py +248 -1
- isa_model/inference/services/llm/ollama_llm_service.py +43 -0
- isa_model/inference/services/llm/openai_llm_service.py +7 -5
- isa_model/inference/services/llm/yyds_llm_service.py +43 -1
- {isa_model-0.3.7.dist-info → isa_model-0.3.9.dist-info}/METADATA +1 -1
- {isa_model-0.3.7.dist-info → isa_model-0.3.9.dist-info}/RECORD +10 -20
- isa_model/inference/providers/__init__.py +0 -19
- isa_model/inference/providers/base_provider.py +0 -77
- isa_model/inference/providers/ml_provider.py +0 -50
- isa_model/inference/providers/modal_provider.py +0 -109
- isa_model/inference/providers/model_cache_manager.py +0 -341
- isa_model/inference/providers/ollama_provider.py +0 -92
- isa_model/inference/providers/openai_provider.py +0 -130
- isa_model/inference/providers/replicate_provider.py +0 -119
- isa_model/inference/providers/triton_provider.py +0 -439
- isa_model/inference/providers/yyds_provider.py +0 -108
- {isa_model-0.3.7.dist-info → isa_model-0.3.9.dist-info}/WHEEL +0 -0
- {isa_model-0.3.7.dist-info → isa_model-0.3.9.dist-info}/top_level.txt +0 -0
@@ -1,108 +0,0 @@
|
|
1
|
-
from isa_model.inference.providers.base_provider import BaseProvider
|
2
|
-
from isa_model.inference.base import ModelType, Capability
|
3
|
-
from typing import Dict, List, Any
|
4
|
-
import logging
|
5
|
-
import os
|
6
|
-
|
7
|
-
logger = logging.getLogger(__name__)
|
8
|
-
|
9
|
-
class YydsProvider(BaseProvider):
|
10
|
-
"""Provider for YYDS API with proper API key management"""
|
11
|
-
|
12
|
-
def __init__(self, config=None):
|
13
|
-
"""Initialize the YYDS Provider with centralized config management"""
|
14
|
-
super().__init__(config)
|
15
|
-
self.name = "yyds"
|
16
|
-
|
17
|
-
logger.info(f"Initialized YydsProvider with URL: {self.config.get('base_url', 'https://api.yyds.com/v1')}")
|
18
|
-
|
19
|
-
if not self.has_valid_credentials():
|
20
|
-
logger.warning("YYDS API key not found. Set YYDS_API_KEY environment variable or pass api_key in config.")
|
21
|
-
|
22
|
-
def _load_provider_env_vars(self):
|
23
|
-
"""Load YYDS-specific environment variables"""
|
24
|
-
# Set defaults first
|
25
|
-
defaults = {
|
26
|
-
"base_url": "https://api.yyds.com/v1",
|
27
|
-
"timeout": 60,
|
28
|
-
"temperature": 0.7,
|
29
|
-
"top_p": 0.9,
|
30
|
-
"max_tokens": 1024
|
31
|
-
}
|
32
|
-
|
33
|
-
# Apply defaults only if not already set
|
34
|
-
for key, value in defaults.items():
|
35
|
-
if key not in self.config:
|
36
|
-
self.config[key] = value
|
37
|
-
|
38
|
-
# Load from environment variables (override config if present)
|
39
|
-
env_mappings = {
|
40
|
-
"api_key": "YYDS_API_KEY",
|
41
|
-
"base_url": "YYDS_API_BASE",
|
42
|
-
"organization": "YYDS_ORGANIZATION"
|
43
|
-
}
|
44
|
-
|
45
|
-
for config_key, env_var in env_mappings.items():
|
46
|
-
env_value = os.getenv(env_var)
|
47
|
-
if env_value:
|
48
|
-
self.config[config_key] = env_value
|
49
|
-
|
50
|
-
def _validate_config(self):
|
51
|
-
"""Validate YYDS configuration"""
|
52
|
-
if not self.config.get("api_key"):
|
53
|
-
logger.debug("YYDS API key not set - some functionality may not work")
|
54
|
-
|
55
|
-
def get_model_pricing(self, model_name: str) -> Dict[str, float]:
|
56
|
-
"""Get pricing information for a model - delegated to ModelManager"""
|
57
|
-
# Import here to avoid circular imports
|
58
|
-
from isa_model.core.model_manager import ModelManager
|
59
|
-
model_manager = ModelManager()
|
60
|
-
return model_manager.get_model_pricing("yyds", model_name)
|
61
|
-
|
62
|
-
def calculate_cost(self, model_name: str, input_tokens: int, output_tokens: int) -> float:
|
63
|
-
"""Calculate cost for a request - delegated to ModelManager"""
|
64
|
-
# Import here to avoid circular imports
|
65
|
-
from isa_model.core.model_manager import ModelManager
|
66
|
-
model_manager = ModelManager()
|
67
|
-
return model_manager.calculate_cost("yyds", model_name, input_tokens, output_tokens)
|
68
|
-
|
69
|
-
def set_api_key(self, api_key: str):
|
70
|
-
"""Set the API key after initialization"""
|
71
|
-
self.config["api_key"] = api_key
|
72
|
-
logger.info("YYDS API key updated")
|
73
|
-
|
74
|
-
def get_capabilities(self) -> Dict[ModelType, List[Capability]]:
|
75
|
-
"""Get provider capabilities by model type"""
|
76
|
-
return {
|
77
|
-
ModelType.LLM: [
|
78
|
-
Capability.CHAT,
|
79
|
-
Capability.COMPLETION
|
80
|
-
]
|
81
|
-
}
|
82
|
-
|
83
|
-
def get_models(self, model_type: ModelType) -> List[str]:
|
84
|
-
"""Get available models for given type"""
|
85
|
-
if model_type == ModelType.LLM:
|
86
|
-
return ["claude-sonnet-4-20250514", "claude-3-5-sonnet-20241022"]
|
87
|
-
else:
|
88
|
-
return []
|
89
|
-
|
90
|
-
def get_default_model(self, model_type: ModelType) -> str:
|
91
|
-
"""Get default model for a given type"""
|
92
|
-
if model_type == ModelType.LLM:
|
93
|
-
return "claude-sonnet-4-20250514"
|
94
|
-
else:
|
95
|
-
return ""
|
96
|
-
|
97
|
-
def get_config(self) -> Dict[str, Any]:
|
98
|
-
"""Get provider configuration"""
|
99
|
-
# Return a copy without sensitive information
|
100
|
-
config_copy = self.config.copy()
|
101
|
-
if "api_key" in config_copy:
|
102
|
-
config_copy["api_key"] = "***" if config_copy["api_key"] else ""
|
103
|
-
return config_copy
|
104
|
-
|
105
|
-
def is_reasoning_model(self, model_name: str) -> bool:
|
106
|
-
"""Check if the model is optimized for reasoning tasks"""
|
107
|
-
reasoning_models = ["claude-sonnet-4", "claude-3-5-sonnet"]
|
108
|
-
return any(rm in model_name.lower() for rm in reasoning_models)
|
File without changes
|
File without changes
|