unrealon 1.0.9__py3-none-any.whl → 1.1.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.
- unrealon/__init__.py +23 -21
- unrealon-1.1.0.dist-info/METADATA +164 -0
- unrealon-1.1.0.dist-info/RECORD +82 -0
- {unrealon-1.0.9.dist-info → unrealon-1.1.0.dist-info}/WHEEL +1 -1
- unrealon-1.1.0.dist-info/entry_points.txt +9 -0
- {unrealon-1.0.9.dist-info → unrealon-1.1.0.dist-info/licenses}/LICENSE +1 -1
- unrealon_bridge/__init__.py +114 -0
- unrealon_bridge/cli.py +316 -0
- unrealon_bridge/client/__init__.py +93 -0
- unrealon_bridge/client/base.py +78 -0
- unrealon_bridge/client/commands.py +89 -0
- unrealon_bridge/client/connection.py +90 -0
- unrealon_bridge/client/events.py +65 -0
- unrealon_bridge/client/health.py +38 -0
- unrealon_bridge/client/html_parser.py +146 -0
- unrealon_bridge/client/logging.py +139 -0
- unrealon_bridge/client/proxy.py +70 -0
- unrealon_bridge/client/scheduler.py +450 -0
- unrealon_bridge/client/session.py +70 -0
- unrealon_bridge/configs/__init__.py +14 -0
- unrealon_bridge/configs/bridge_config.py +212 -0
- unrealon_bridge/configs/bridge_config.yaml +39 -0
- unrealon_bridge/models/__init__.py +138 -0
- unrealon_bridge/models/base.py +28 -0
- unrealon_bridge/models/command.py +41 -0
- unrealon_bridge/models/events.py +40 -0
- unrealon_bridge/models/html_parser.py +79 -0
- unrealon_bridge/models/logging.py +55 -0
- unrealon_bridge/models/parser.py +63 -0
- unrealon_bridge/models/proxy.py +41 -0
- unrealon_bridge/models/requests.py +95 -0
- unrealon_bridge/models/responses.py +88 -0
- unrealon_bridge/models/scheduler.py +592 -0
- unrealon_bridge/models/session.py +28 -0
- unrealon_bridge/server/__init__.py +91 -0
- unrealon_bridge/server/base.py +171 -0
- unrealon_bridge/server/handlers/__init__.py +23 -0
- unrealon_bridge/server/handlers/command.py +110 -0
- unrealon_bridge/server/handlers/html_parser.py +139 -0
- unrealon_bridge/server/handlers/logging.py +95 -0
- unrealon_bridge/server/handlers/parser.py +95 -0
- unrealon_bridge/server/handlers/proxy.py +75 -0
- unrealon_bridge/server/handlers/scheduler.py +545 -0
- unrealon_bridge/server/handlers/session.py +66 -0
- unrealon_browser/__init__.py +61 -18
- unrealon_browser/{src/cli → cli}/browser_cli.py +6 -13
- unrealon_browser/{src/cli → cli}/cookies_cli.py +5 -1
- unrealon_browser/{src/core → core}/browser_manager.py +2 -2
- unrealon_browser/{src/managers → managers}/captcha.py +1 -1
- unrealon_browser/{src/managers → managers}/cookies.py +1 -1
- unrealon_browser/managers/logger_bridge.py +231 -0
- unrealon_browser/{src/managers → managers}/profile.py +1 -1
- unrealon_driver/__init__.py +73 -19
- unrealon_driver/browser/__init__.py +8 -0
- unrealon_driver/browser/config.py +74 -0
- unrealon_driver/browser/manager.py +416 -0
- unrealon_driver/exceptions.py +28 -0
- unrealon_driver/parser/__init__.py +55 -0
- unrealon_driver/parser/cli_manager.py +141 -0
- unrealon_driver/parser/daemon_manager.py +227 -0
- unrealon_driver/parser/managers/__init__.py +46 -0
- unrealon_driver/parser/managers/browser.py +51 -0
- unrealon_driver/parser/managers/config.py +281 -0
- unrealon_driver/parser/managers/error.py +412 -0
- unrealon_driver/parser/managers/html.py +732 -0
- unrealon_driver/parser/managers/logging.py +609 -0
- unrealon_driver/parser/managers/result.py +321 -0
- unrealon_driver/parser/parser_manager.py +628 -0
- unrealon/sdk_config.py +0 -88
- unrealon-1.0.9.dist-info/METADATA +0 -810
- unrealon-1.0.9.dist-info/RECORD +0 -246
- unrealon_browser/pyproject.toml +0 -182
- unrealon_browser/src/__init__.py +0 -62
- unrealon_browser/src/managers/logger_bridge.py +0 -395
- unrealon_driver/README.md +0 -204
- unrealon_driver/pyproject.toml +0 -187
- unrealon_driver/src/__init__.py +0 -90
- unrealon_driver/src/cli/__init__.py +0 -10
- unrealon_driver/src/cli/main.py +0 -66
- unrealon_driver/src/cli/simple.py +0 -510
- unrealon_driver/src/config/__init__.py +0 -11
- unrealon_driver/src/config/auto_config.py +0 -478
- unrealon_driver/src/core/__init__.py +0 -18
- unrealon_driver/src/core/exceptions.py +0 -289
- unrealon_driver/src/core/parser.py +0 -638
- unrealon_driver/src/dto/__init__.py +0 -66
- unrealon_driver/src/dto/cli.py +0 -119
- unrealon_driver/src/dto/config.py +0 -18
- unrealon_driver/src/dto/events.py +0 -237
- unrealon_driver/src/dto/execution.py +0 -313
- unrealon_driver/src/dto/services.py +0 -311
- unrealon_driver/src/execution/__init__.py +0 -23
- unrealon_driver/src/execution/daemon_mode.py +0 -317
- unrealon_driver/src/execution/interactive_mode.py +0 -88
- unrealon_driver/src/execution/modes.py +0 -45
- unrealon_driver/src/execution/scheduled_mode.py +0 -209
- unrealon_driver/src/execution/test_mode.py +0 -250
- unrealon_driver/src/logging/__init__.py +0 -24
- unrealon_driver/src/logging/driver_logger.py +0 -512
- unrealon_driver/src/services/__init__.py +0 -24
- unrealon_driver/src/services/browser_service.py +0 -726
- unrealon_driver/src/services/llm/__init__.py +0 -15
- unrealon_driver/src/services/llm/browser_llm_service.py +0 -363
- unrealon_driver/src/services/llm/llm.py +0 -195
- unrealon_driver/src/services/logger_service.py +0 -232
- unrealon_driver/src/services/metrics_service.py +0 -185
- unrealon_driver/src/services/scheduler_service.py +0 -489
- unrealon_driver/src/services/websocket_service.py +0 -362
- unrealon_driver/src/utils/__init__.py +0 -16
- unrealon_driver/src/utils/service_factory.py +0 -317
- unrealon_driver/src/utils/time_formatter.py +0 -338
- unrealon_llm/README.md +0 -44
- unrealon_llm/__init__.py +0 -26
- unrealon_llm/pyproject.toml +0 -154
- unrealon_llm/src/__init__.py +0 -228
- unrealon_llm/src/cli/__init__.py +0 -0
- unrealon_llm/src/core/__init__.py +0 -11
- unrealon_llm/src/core/smart_client.py +0 -438
- unrealon_llm/src/dto/__init__.py +0 -155
- unrealon_llm/src/dto/models/__init__.py +0 -0
- unrealon_llm/src/dto/models/config.py +0 -343
- unrealon_llm/src/dto/models/core.py +0 -328
- unrealon_llm/src/dto/models/enums.py +0 -123
- unrealon_llm/src/dto/models/html_analysis.py +0 -345
- unrealon_llm/src/dto/models/statistics.py +0 -473
- unrealon_llm/src/dto/models/translation.py +0 -383
- unrealon_llm/src/dto/models/type_conversion.py +0 -462
- unrealon_llm/src/dto/schemas/__init__.py +0 -0
- unrealon_llm/src/exceptions.py +0 -392
- unrealon_llm/src/llm_config/__init__.py +0 -20
- unrealon_llm/src/llm_config/logging_config.py +0 -178
- unrealon_llm/src/llm_logging/__init__.py +0 -42
- unrealon_llm/src/llm_logging/llm_events.py +0 -107
- unrealon_llm/src/llm_logging/llm_logger.py +0 -466
- unrealon_llm/src/managers/__init__.py +0 -15
- unrealon_llm/src/managers/cache_manager.py +0 -67
- unrealon_llm/src/managers/cost_manager.py +0 -107
- unrealon_llm/src/managers/request_manager.py +0 -298
- unrealon_llm/src/modules/__init__.py +0 -0
- unrealon_llm/src/modules/html_processor/__init__.py +0 -25
- unrealon_llm/src/modules/html_processor/base_processor.py +0 -415
- unrealon_llm/src/modules/html_processor/details_processor.py +0 -85
- unrealon_llm/src/modules/html_processor/listing_processor.py +0 -91
- unrealon_llm/src/modules/html_processor/models/__init__.py +0 -20
- unrealon_llm/src/modules/html_processor/models/processing_models.py +0 -40
- unrealon_llm/src/modules/html_processor/models/universal_model.py +0 -56
- unrealon_llm/src/modules/html_processor/processor.py +0 -102
- unrealon_llm/src/modules/llm/__init__.py +0 -0
- unrealon_llm/src/modules/translator/__init__.py +0 -0
- unrealon_llm/src/provider.py +0 -116
- unrealon_llm/src/utils/__init__.py +0 -95
- unrealon_llm/src/utils/common.py +0 -64
- unrealon_llm/src/utils/data_extractor.py +0 -188
- unrealon_llm/src/utils/html_cleaner.py +0 -767
- unrealon_llm/src/utils/language_detector.py +0 -308
- unrealon_llm/src/utils/models_cache.py +0 -592
- unrealon_llm/src/utils/smart_counter.py +0 -229
- unrealon_llm/src/utils/token_counter.py +0 -189
- unrealon_sdk/README.md +0 -25
- unrealon_sdk/__init__.py +0 -30
- unrealon_sdk/pyproject.toml +0 -231
- unrealon_sdk/src/__init__.py +0 -150
- unrealon_sdk/src/cli/__init__.py +0 -12
- unrealon_sdk/src/cli/commands/__init__.py +0 -22
- unrealon_sdk/src/cli/commands/benchmark.py +0 -42
- unrealon_sdk/src/cli/commands/diagnostics.py +0 -573
- unrealon_sdk/src/cli/commands/health.py +0 -46
- unrealon_sdk/src/cli/commands/integration.py +0 -498
- unrealon_sdk/src/cli/commands/reports.py +0 -43
- unrealon_sdk/src/cli/commands/security.py +0 -36
- unrealon_sdk/src/cli/commands/server.py +0 -483
- unrealon_sdk/src/cli/commands/servers.py +0 -56
- unrealon_sdk/src/cli/commands/tests.py +0 -55
- unrealon_sdk/src/cli/main.py +0 -126
- unrealon_sdk/src/cli/utils/reporter.py +0 -519
- unrealon_sdk/src/clients/openapi.yaml +0 -3347
- unrealon_sdk/src/clients/python_http/__init__.py +0 -3
- unrealon_sdk/src/clients/python_http/api_config.py +0 -228
- unrealon_sdk/src/clients/python_http/models/BaseModel.py +0 -12
- unrealon_sdk/src/clients/python_http/models/BroadcastDeliveryStats.py +0 -33
- unrealon_sdk/src/clients/python_http/models/BroadcastMessage.py +0 -17
- unrealon_sdk/src/clients/python_http/models/BroadcastMessageRequest.py +0 -35
- unrealon_sdk/src/clients/python_http/models/BroadcastPriority.py +0 -10
- unrealon_sdk/src/clients/python_http/models/BroadcastResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/BroadcastResultResponse.py +0 -33
- unrealon_sdk/src/clients/python_http/models/BroadcastTarget.py +0 -11
- unrealon_sdk/src/clients/python_http/models/ConnectionStats.py +0 -27
- unrealon_sdk/src/clients/python_http/models/ConnectionsResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/DeveloperMessageResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ErrorResponse.py +0 -25
- unrealon_sdk/src/clients/python_http/models/HTTPValidationError.py +0 -16
- unrealon_sdk/src/clients/python_http/models/HealthResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/HealthStatus.py +0 -33
- unrealon_sdk/src/clients/python_http/models/LogLevel.py +0 -10
- unrealon_sdk/src/clients/python_http/models/LoggingRequest.py +0 -27
- unrealon_sdk/src/clients/python_http/models/LoggingResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/MaintenanceMode.py +0 -9
- unrealon_sdk/src/clients/python_http/models/MaintenanceModeRequest.py +0 -33
- unrealon_sdk/src/clients/python_http/models/MaintenanceStatusResponse.py +0 -39
- unrealon_sdk/src/clients/python_http/models/ParserCommandRequest.py +0 -25
- unrealon_sdk/src/clients/python_http/models/ParserMessageResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/ParserRegistrationRequest.py +0 -28
- unrealon_sdk/src/clients/python_http/models/ParserRegistrationResponse.py +0 -25
- unrealon_sdk/src/clients/python_http/models/ParserType.py +0 -10
- unrealon_sdk/src/clients/python_http/models/ProxyBlockRequest.py +0 -19
- unrealon_sdk/src/clients/python_http/models/ProxyEndpointResponse.py +0 -20
- unrealon_sdk/src/clients/python_http/models/ProxyListResponse.py +0 -19
- unrealon_sdk/src/clients/python_http/models/ProxyProvider.py +0 -10
- unrealon_sdk/src/clients/python_http/models/ProxyPurchaseRequest.py +0 -25
- unrealon_sdk/src/clients/python_http/models/ProxyResponse.py +0 -47
- unrealon_sdk/src/clients/python_http/models/ProxyRotationRequest.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ProxyStatus.py +0 -10
- unrealon_sdk/src/clients/python_http/models/ProxyUsageRequest.py +0 -19
- unrealon_sdk/src/clients/python_http/models/ProxyUsageStatsResponse.py +0 -26
- unrealon_sdk/src/clients/python_http/models/ServiceRegistrationDto.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ServiceStatsResponse.py +0 -31
- unrealon_sdk/src/clients/python_http/models/SessionStartRequest.py +0 -23
- unrealon_sdk/src/clients/python_http/models/SuccessResponse.py +0 -25
- unrealon_sdk/src/clients/python_http/models/SystemNotificationResponse.py +0 -23
- unrealon_sdk/src/clients/python_http/models/ValidationError.py +0 -18
- unrealon_sdk/src/clients/python_http/models/ValidationErrorResponse.py +0 -21
- unrealon_sdk/src/clients/python_http/models/WebSocketMetrics.py +0 -21
- unrealon_sdk/src/clients/python_http/models/__init__.py +0 -44
- unrealon_sdk/src/clients/python_http/services/None_service.py +0 -35
- unrealon_sdk/src/clients/python_http/services/ParserManagement_service.py +0 -190
- unrealon_sdk/src/clients/python_http/services/ProxyManagement_service.py +0 -289
- unrealon_sdk/src/clients/python_http/services/SocketLogging_service.py +0 -187
- unrealon_sdk/src/clients/python_http/services/SystemHealth_service.py +0 -119
- unrealon_sdk/src/clients/python_http/services/WebSocketAPI_service.py +0 -198
- unrealon_sdk/src/clients/python_http/services/__init__.py +0 -0
- unrealon_sdk/src/clients/python_http/services/admin_service.py +0 -125
- unrealon_sdk/src/clients/python_http/services/async_None_service.py +0 -35
- unrealon_sdk/src/clients/python_http/services/async_ParserManagement_service.py +0 -190
- unrealon_sdk/src/clients/python_http/services/async_ProxyManagement_service.py +0 -289
- unrealon_sdk/src/clients/python_http/services/async_SocketLogging_service.py +0 -189
- unrealon_sdk/src/clients/python_http/services/async_SystemHealth_service.py +0 -123
- unrealon_sdk/src/clients/python_http/services/async_WebSocketAPI_service.py +0 -200
- unrealon_sdk/src/clients/python_http/services/async_admin_service.py +0 -125
- unrealon_sdk/src/clients/python_websocket/__init__.py +0 -28
- unrealon_sdk/src/clients/python_websocket/client.py +0 -490
- unrealon_sdk/src/clients/python_websocket/events.py +0 -732
- unrealon_sdk/src/clients/python_websocket/example.py +0 -136
- unrealon_sdk/src/clients/python_websocket/types.py +0 -871
- unrealon_sdk/src/core/__init__.py +0 -64
- unrealon_sdk/src/core/client.py +0 -556
- unrealon_sdk/src/core/config.py +0 -465
- unrealon_sdk/src/core/exceptions.py +0 -239
- unrealon_sdk/src/core/metadata.py +0 -191
- unrealon_sdk/src/core/models.py +0 -142
- unrealon_sdk/src/core/types.py +0 -68
- unrealon_sdk/src/dto/__init__.py +0 -268
- unrealon_sdk/src/dto/authentication.py +0 -108
- unrealon_sdk/src/dto/cache.py +0 -208
- unrealon_sdk/src/dto/common.py +0 -19
- unrealon_sdk/src/dto/concurrency.py +0 -393
- unrealon_sdk/src/dto/events.py +0 -108
- unrealon_sdk/src/dto/health.py +0 -339
- unrealon_sdk/src/dto/load_balancing.py +0 -336
- unrealon_sdk/src/dto/logging.py +0 -230
- unrealon_sdk/src/dto/performance.py +0 -165
- unrealon_sdk/src/dto/rate_limiting.py +0 -295
- unrealon_sdk/src/dto/resource_pooling.py +0 -128
- unrealon_sdk/src/dto/structured_logging.py +0 -112
- unrealon_sdk/src/dto/task_scheduling.py +0 -121
- unrealon_sdk/src/dto/websocket.py +0 -55
- unrealon_sdk/src/enterprise/__init__.py +0 -59
- unrealon_sdk/src/enterprise/authentication.py +0 -401
- unrealon_sdk/src/enterprise/cache_manager.py +0 -578
- unrealon_sdk/src/enterprise/error_recovery.py +0 -494
- unrealon_sdk/src/enterprise/event_system.py +0 -549
- unrealon_sdk/src/enterprise/health_monitor.py +0 -747
- unrealon_sdk/src/enterprise/load_balancer.py +0 -964
- unrealon_sdk/src/enterprise/logging/__init__.py +0 -68
- unrealon_sdk/src/enterprise/logging/cleanup.py +0 -156
- unrealon_sdk/src/enterprise/logging/development.py +0 -744
- unrealon_sdk/src/enterprise/logging/service.py +0 -410
- unrealon_sdk/src/enterprise/multithreading_manager.py +0 -853
- unrealon_sdk/src/enterprise/performance_monitor.py +0 -539
- unrealon_sdk/src/enterprise/proxy_manager.py +0 -696
- unrealon_sdk/src/enterprise/rate_limiter.py +0 -652
- unrealon_sdk/src/enterprise/resource_pool.py +0 -763
- unrealon_sdk/src/enterprise/task_scheduler.py +0 -709
- unrealon_sdk/src/internal/__init__.py +0 -10
- unrealon_sdk/src/internal/command_router.py +0 -497
- unrealon_sdk/src/internal/connection_manager.py +0 -397
- unrealon_sdk/src/internal/http_client.py +0 -446
- unrealon_sdk/src/internal/websocket_client.py +0 -420
- unrealon_sdk/src/provider.py +0 -471
- unrealon_sdk/src/utils.py +0 -234
- /unrealon_browser/{src/cli → cli}/__init__.py +0 -0
- /unrealon_browser/{src/cli → cli}/interactive_mode.py +0 -0
- /unrealon_browser/{src/cli → cli}/main.py +0 -0
- /unrealon_browser/{src/core → core}/__init__.py +0 -0
- /unrealon_browser/{src/dto → dto}/__init__.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/config.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/core.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/dataclasses.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/detection.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/enums.py +0 -0
- /unrealon_browser/{src/dto → dto}/models/statistics.py +0 -0
- /unrealon_browser/{src/managers → managers}/__init__.py +0 -0
- /unrealon_browser/{src/managers → managers}/stealth.py +0 -0
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Smart Token Counter
|
|
3
|
-
|
|
4
|
-
Intelligent token counting and cost estimation using ModelsCache.
|
|
5
|
-
Combines pure token counting with live model data.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import logging
|
|
9
|
-
from typing import List, Optional, Tuple
|
|
10
|
-
|
|
11
|
-
from unrealon_llm.src.dto import ChatMessage
|
|
12
|
-
from unrealon_llm.src.exceptions import ValidationError
|
|
13
|
-
from unrealon_llm.src.utils.models_cache import ModelsCache, ModelInfo
|
|
14
|
-
from unrealon_llm.src.utils.token_counter import TokenCounter
|
|
15
|
-
|
|
16
|
-
logger = logging.getLogger(__name__)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class SmartTokenCounter:
|
|
20
|
-
"""
|
|
21
|
-
Intelligent token counter with model-aware cost estimation
|
|
22
|
-
"""
|
|
23
|
-
|
|
24
|
-
def __init__(self, models_cache: ModelsCache):
|
|
25
|
-
"""
|
|
26
|
-
Initialize smart counter
|
|
27
|
-
|
|
28
|
-
Args:
|
|
29
|
-
models_cache: Models cache for pricing information
|
|
30
|
-
"""
|
|
31
|
-
self.models_cache = models_cache
|
|
32
|
-
self.token_counter = TokenCounter()
|
|
33
|
-
|
|
34
|
-
async def count_and_estimate(
|
|
35
|
-
self,
|
|
36
|
-
text: str,
|
|
37
|
-
model: str,
|
|
38
|
-
estimated_output_tokens: int = 0
|
|
39
|
-
) -> Tuple[int, float]:
|
|
40
|
-
"""
|
|
41
|
-
Count tokens and estimate cost
|
|
42
|
-
|
|
43
|
-
Args:
|
|
44
|
-
text: Input text
|
|
45
|
-
model: Model name
|
|
46
|
-
estimated_output_tokens: Expected output tokens
|
|
47
|
-
|
|
48
|
-
Returns:
|
|
49
|
-
Tuple of (input_tokens, estimated_cost_usd)
|
|
50
|
-
"""
|
|
51
|
-
# Count input tokens
|
|
52
|
-
input_tokens = self.token_counter.count_tokens(text, model)
|
|
53
|
-
|
|
54
|
-
# Get model info for cost estimation
|
|
55
|
-
if self.models_cache:
|
|
56
|
-
await self.models_cache.fetch_all_models()
|
|
57
|
-
model_info = self.models_cache.get_model(model)
|
|
58
|
-
else:
|
|
59
|
-
model_info = None
|
|
60
|
-
|
|
61
|
-
if model_info:
|
|
62
|
-
cost = model_info.estimate_cost(input_tokens, estimated_output_tokens)
|
|
63
|
-
else:
|
|
64
|
-
# Fallback estimation
|
|
65
|
-
cost = self._fallback_cost_estimation(input_tokens, estimated_output_tokens)
|
|
66
|
-
logger.warning(f"Model {model} not found in cache, using fallback pricing")
|
|
67
|
-
|
|
68
|
-
return input_tokens, cost
|
|
69
|
-
|
|
70
|
-
async def count_messages_and_estimate(
|
|
71
|
-
self,
|
|
72
|
-
messages: List[ChatMessage],
|
|
73
|
-
model: str,
|
|
74
|
-
estimated_output_tokens: int = 0
|
|
75
|
-
) -> Tuple[int, float]:
|
|
76
|
-
"""
|
|
77
|
-
Count message tokens and estimate cost
|
|
78
|
-
|
|
79
|
-
Args:
|
|
80
|
-
messages: Chat messages
|
|
81
|
-
model: Model name
|
|
82
|
-
estimated_output_tokens: Expected output tokens
|
|
83
|
-
|
|
84
|
-
Returns:
|
|
85
|
-
Tuple of (total_tokens, estimated_cost_usd)
|
|
86
|
-
"""
|
|
87
|
-
# Count tokens including message overhead
|
|
88
|
-
total_tokens = self.token_counter.count_message_tokens(messages, model)
|
|
89
|
-
|
|
90
|
-
# Get model info for cost estimation
|
|
91
|
-
if self.models_cache:
|
|
92
|
-
await self.models_cache.fetch_all_models()
|
|
93
|
-
model_info = self.models_cache.get_model(model)
|
|
94
|
-
else:
|
|
95
|
-
model_info = None
|
|
96
|
-
|
|
97
|
-
if model_info:
|
|
98
|
-
cost = model_info.estimate_cost(total_tokens, estimated_output_tokens)
|
|
99
|
-
else:
|
|
100
|
-
# Fallback estimation
|
|
101
|
-
cost = self._fallback_cost_estimation(total_tokens, estimated_output_tokens)
|
|
102
|
-
logger.warning(f"Model {model} not found in cache, using fallback pricing")
|
|
103
|
-
|
|
104
|
-
return total_tokens, cost
|
|
105
|
-
|
|
106
|
-
async def optimize_for_budget(
|
|
107
|
-
self,
|
|
108
|
-
text: str,
|
|
109
|
-
model: str,
|
|
110
|
-
max_cost_usd: float,
|
|
111
|
-
estimated_output_tokens: int = 0
|
|
112
|
-
) -> str:
|
|
113
|
-
"""
|
|
114
|
-
Optimize text to fit within budget
|
|
115
|
-
|
|
116
|
-
Args:
|
|
117
|
-
text: Input text
|
|
118
|
-
model: Model name
|
|
119
|
-
max_cost_usd: Maximum allowed cost
|
|
120
|
-
estimated_output_tokens: Expected output tokens
|
|
121
|
-
|
|
122
|
-
Returns:
|
|
123
|
-
Optimized text that fits budget
|
|
124
|
-
"""
|
|
125
|
-
# Get model pricing - first fetch models, then get model info
|
|
126
|
-
if self.models_cache:
|
|
127
|
-
await self.models_cache.fetch_all_models()
|
|
128
|
-
model_info = self.models_cache.get_model(model)
|
|
129
|
-
else:
|
|
130
|
-
model_info = None
|
|
131
|
-
|
|
132
|
-
if not model_info:
|
|
133
|
-
logger.warning(f"Model {model} not found, using fallback optimization")
|
|
134
|
-
return self.token_counter.optimize_text_for_tokens(text, 1000, model)
|
|
135
|
-
|
|
136
|
-
# Calculate max input tokens for budget
|
|
137
|
-
output_cost = (estimated_output_tokens / 1_000_000) * model_info.completion_price
|
|
138
|
-
remaining_budget = max_cost_usd - output_cost
|
|
139
|
-
|
|
140
|
-
if remaining_budget <= 0:
|
|
141
|
-
raise ValidationError("Budget too low even for output tokens")
|
|
142
|
-
|
|
143
|
-
max_input_tokens = int((remaining_budget / model_info.prompt_price) * 1_000_000)
|
|
144
|
-
|
|
145
|
-
# Optimize text for token limit
|
|
146
|
-
return self.token_counter.optimize_text_for_tokens(text, max_input_tokens, model)
|
|
147
|
-
|
|
148
|
-
async def get_model_context_limit(self, model: str) -> Optional[int]:
|
|
149
|
-
"""Get context length limit for model"""
|
|
150
|
-
if self.models_cache:
|
|
151
|
-
await self.models_cache.fetch_all_models()
|
|
152
|
-
model_info = self.models_cache.get_model(model)
|
|
153
|
-
return model_info.context_length if model_info else None
|
|
154
|
-
return None
|
|
155
|
-
|
|
156
|
-
async def suggest_cheaper_alternative(
|
|
157
|
-
self,
|
|
158
|
-
current_model: str,
|
|
159
|
-
input_tokens: int,
|
|
160
|
-
output_tokens: int
|
|
161
|
-
) -> Optional[Tuple[str, float, float]]:
|
|
162
|
-
"""
|
|
163
|
-
Suggest cheaper model alternative
|
|
164
|
-
|
|
165
|
-
Returns:
|
|
166
|
-
Tuple of (model_name, current_cost, suggested_cost) or None
|
|
167
|
-
"""
|
|
168
|
-
if self.models_cache:
|
|
169
|
-
await self.models_cache.fetch_all_models()
|
|
170
|
-
current_info = self.models_cache.get_model(current_model)
|
|
171
|
-
else:
|
|
172
|
-
current_info = None
|
|
173
|
-
|
|
174
|
-
if not current_info:
|
|
175
|
-
return None
|
|
176
|
-
|
|
177
|
-
current_cost = current_info.estimate_cost(input_tokens, output_tokens)
|
|
178
|
-
|
|
179
|
-
# Find cheaper models with similar context length
|
|
180
|
-
min_context = min(current_info.context_length, input_tokens + output_tokens)
|
|
181
|
-
|
|
182
|
-
# Note: get_budget_models is not an async method, let's check if models_cache has this method
|
|
183
|
-
# For now, we'll implement a simple fallback
|
|
184
|
-
budget_models = []
|
|
185
|
-
if self.models_cache:
|
|
186
|
-
# Find models with lower pricing
|
|
187
|
-
all_models = list(self.models_cache.models.values())
|
|
188
|
-
max_price = current_info.prompt_price * 0.8 # 20% cheaper
|
|
189
|
-
budget_models = [
|
|
190
|
-
m for m in all_models
|
|
191
|
-
if m.prompt_price <= max_price and m.context_length >= min_context and m.is_available
|
|
192
|
-
]
|
|
193
|
-
|
|
194
|
-
for model_info in budget_models:
|
|
195
|
-
if model_info.context_length >= min_context:
|
|
196
|
-
suggested_cost = model_info.estimate_cost(input_tokens, output_tokens)
|
|
197
|
-
if suggested_cost < current_cost:
|
|
198
|
-
return model_info.id, current_cost, suggested_cost
|
|
199
|
-
|
|
200
|
-
return None
|
|
201
|
-
|
|
202
|
-
def _fallback_cost_estimation(self, input_tokens: int, output_tokens: int) -> float:
|
|
203
|
-
"""Fallback cost estimation when model not found"""
|
|
204
|
-
# Conservative estimation: $0.002 per 1K tokens (GPT-3.5-turbo-like pricing)
|
|
205
|
-
total_tokens = input_tokens + output_tokens
|
|
206
|
-
return (total_tokens / 1000) * 0.002
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
# Convenience functions for backward compatibility
|
|
210
|
-
async def smart_count_tokens(
|
|
211
|
-
text: str,
|
|
212
|
-
model: str,
|
|
213
|
-
models_cache: ModelsCache,
|
|
214
|
-
estimate_output: int = 0
|
|
215
|
-
) -> Tuple[int, float]:
|
|
216
|
-
"""Quick smart token counting with cost estimation"""
|
|
217
|
-
counter = SmartTokenCounter(models_cache)
|
|
218
|
-
return await counter.count_and_estimate(text, model, estimate_output)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
async def smart_count_messages(
|
|
222
|
-
messages: List[ChatMessage],
|
|
223
|
-
model: str,
|
|
224
|
-
models_cache: ModelsCache,
|
|
225
|
-
estimate_output: int = 0
|
|
226
|
-
) -> Tuple[int, float]:
|
|
227
|
-
"""Quick smart message counting with cost estimation"""
|
|
228
|
-
counter = SmartTokenCounter(models_cache)
|
|
229
|
-
return await counter.count_messages_and_estimate(messages, model, estimate_output)
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Token Counting Utilities
|
|
3
|
-
|
|
4
|
-
Pure token counting with tiktoken - no hardcoded models.
|
|
5
|
-
Works with ModelsCache for model information.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import re
|
|
9
|
-
from typing import Dict, List, Optional
|
|
10
|
-
|
|
11
|
-
import tiktoken
|
|
12
|
-
|
|
13
|
-
from unrealon_llm.src.dto import ChatMessage
|
|
14
|
-
from unrealon_llm.src.exceptions import ValidationError
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class TokenCounter:
|
|
18
|
-
"""Pure token counting utility - no model knowledge"""
|
|
19
|
-
|
|
20
|
-
def __init__(self):
|
|
21
|
-
"""Initialize token counter"""
|
|
22
|
-
# Cache for encoding objects
|
|
23
|
-
self._encoding_cache: Dict[str, any] = {}
|
|
24
|
-
|
|
25
|
-
# Universal encoding for all models
|
|
26
|
-
self._universal_encoding = "cl100k_base"
|
|
27
|
-
|
|
28
|
-
# Language ratios for character-based estimation
|
|
29
|
-
self._language_ratios = {
|
|
30
|
-
"english": 0.25, # ~4 chars per token
|
|
31
|
-
"korean": 0.33, # ~3 chars per token
|
|
32
|
-
"chinese": 0.5, # ~2 chars per token
|
|
33
|
-
"japanese": 0.4, # ~2.5 chars per token
|
|
34
|
-
"russian": 0.25, # ~4 chars per token
|
|
35
|
-
"default": 0.25 # Conservative estimate
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
def count_tokens(self, text: str, model: str = "gpt-3.5-turbo") -> int:
|
|
39
|
-
"""
|
|
40
|
-
Count tokens in text for specified model
|
|
41
|
-
|
|
42
|
-
Args:
|
|
43
|
-
text: Text to count tokens for
|
|
44
|
-
model: Model name
|
|
45
|
-
|
|
46
|
-
Returns:
|
|
47
|
-
Number of tokens
|
|
48
|
-
"""
|
|
49
|
-
if not isinstance(text, str):
|
|
50
|
-
raise ValidationError("Text must be a string")
|
|
51
|
-
|
|
52
|
-
if not text:
|
|
53
|
-
return 0
|
|
54
|
-
|
|
55
|
-
# Try tiktoken first
|
|
56
|
-
try:
|
|
57
|
-
return self._count_with_tiktoken(text, model)
|
|
58
|
-
except Exception:
|
|
59
|
-
# Fallback to estimation
|
|
60
|
-
return self._estimate_tokens(text)
|
|
61
|
-
|
|
62
|
-
def count_message_tokens(self, messages: List[ChatMessage], model: str = "gpt-3.5-turbo") -> int:
|
|
63
|
-
"""
|
|
64
|
-
Count tokens for chat messages including formatting overhead
|
|
65
|
-
|
|
66
|
-
Args:
|
|
67
|
-
messages: List of chat messages
|
|
68
|
-
model: Model name
|
|
69
|
-
|
|
70
|
-
Returns:
|
|
71
|
-
Total tokens including overhead
|
|
72
|
-
"""
|
|
73
|
-
if not messages:
|
|
74
|
-
return 0
|
|
75
|
-
|
|
76
|
-
total_tokens = 0
|
|
77
|
-
|
|
78
|
-
# Count tokens for each message
|
|
79
|
-
for message in messages:
|
|
80
|
-
# Content tokens
|
|
81
|
-
total_tokens += self.count_tokens(message.content, model)
|
|
82
|
-
|
|
83
|
-
# Role tokens
|
|
84
|
-
total_tokens += self.count_tokens(message.role.value, model)
|
|
85
|
-
|
|
86
|
-
# Name tokens if present
|
|
87
|
-
if message.name:
|
|
88
|
-
total_tokens += self.count_tokens(message.name, model)
|
|
89
|
-
|
|
90
|
-
# Message formatting overhead
|
|
91
|
-
total_tokens += self._get_message_overhead(model)
|
|
92
|
-
|
|
93
|
-
# Conversation overhead
|
|
94
|
-
total_tokens += self._get_conversation_overhead(model)
|
|
95
|
-
|
|
96
|
-
return total_tokens
|
|
97
|
-
|
|
98
|
-
def optimize_text_for_tokens(self, text: str, max_tokens: int, model: str = "gpt-3.5-turbo") -> str:
|
|
99
|
-
"""
|
|
100
|
-
Truncate text to fit within token limit
|
|
101
|
-
|
|
102
|
-
Args:
|
|
103
|
-
text: Input text
|
|
104
|
-
max_tokens: Maximum allowed tokens
|
|
105
|
-
model: Model name
|
|
106
|
-
|
|
107
|
-
Returns:
|
|
108
|
-
Truncated text
|
|
109
|
-
"""
|
|
110
|
-
current_tokens = self.count_tokens(text, model)
|
|
111
|
-
|
|
112
|
-
if current_tokens <= max_tokens:
|
|
113
|
-
return text
|
|
114
|
-
|
|
115
|
-
# Binary search for optimal length
|
|
116
|
-
left, right = 0, len(text)
|
|
117
|
-
best_text = ""
|
|
118
|
-
|
|
119
|
-
while left <= right:
|
|
120
|
-
mid = (left + right) // 2
|
|
121
|
-
candidate = text[:mid]
|
|
122
|
-
|
|
123
|
-
if self.count_tokens(candidate, model) <= max_tokens:
|
|
124
|
-
best_text = candidate
|
|
125
|
-
left = mid + 1
|
|
126
|
-
else:
|
|
127
|
-
right = mid - 1
|
|
128
|
-
|
|
129
|
-
return best_text
|
|
130
|
-
|
|
131
|
-
def _count_with_tiktoken(self, text: str, model: str) -> int:
|
|
132
|
-
"""Count tokens using tiktoken (universal encoding)"""
|
|
133
|
-
encoding_name = self._universal_encoding
|
|
134
|
-
|
|
135
|
-
if encoding_name not in self._encoding_cache:
|
|
136
|
-
self._encoding_cache[encoding_name] = tiktoken.get_encoding(encoding_name)
|
|
137
|
-
|
|
138
|
-
encoding = self._encoding_cache[encoding_name]
|
|
139
|
-
return len(encoding.encode(text))
|
|
140
|
-
|
|
141
|
-
def _estimate_tokens(self, text: str) -> int:
|
|
142
|
-
"""Fallback token estimation"""
|
|
143
|
-
language = self._detect_language(text)
|
|
144
|
-
ratio = self._language_ratios.get(language, self._language_ratios["default"])
|
|
145
|
-
|
|
146
|
-
char_count = len(re.sub(r'\s+', '', text))
|
|
147
|
-
estimated_tokens = int(char_count * ratio)
|
|
148
|
-
|
|
149
|
-
return max(1, estimated_tokens)
|
|
150
|
-
|
|
151
|
-
def _detect_language(self, text: str) -> str:
|
|
152
|
-
"""Simple language detection for estimation"""
|
|
153
|
-
if re.search(r'[가-힣]', text):
|
|
154
|
-
return "korean"
|
|
155
|
-
elif re.search(r'[\u4e00-\u9fff]', text):
|
|
156
|
-
return "chinese"
|
|
157
|
-
elif re.search(r'[ひらがなカタカナ\u3040-\u309f\u30a0-\u30ff]', text):
|
|
158
|
-
return "japanese"
|
|
159
|
-
elif re.search(r'[а-яё]', text, re.IGNORECASE):
|
|
160
|
-
return "russian"
|
|
161
|
-
else:
|
|
162
|
-
return "english"
|
|
163
|
-
|
|
164
|
-
def _get_message_overhead(self, model: str) -> int:
|
|
165
|
-
"""Message formatting overhead (universal)"""
|
|
166
|
-
return 3 # Universal overhead for all models
|
|
167
|
-
|
|
168
|
-
def _get_conversation_overhead(self, model: str) -> int:
|
|
169
|
-
"""Conversation formatting overhead (universal)"""
|
|
170
|
-
return 2 # Universal overhead for all models
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
# Convenience functions
|
|
174
|
-
def count_tokens(text: str, model: str = "gpt-3.5-turbo") -> int:
|
|
175
|
-
"""Quick token counting"""
|
|
176
|
-
counter = TokenCounter()
|
|
177
|
-
return counter.count_tokens(text, model)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
def count_message_tokens(messages: List[ChatMessage], model: str = "gpt-3.5-turbo") -> int:
|
|
181
|
-
"""Quick message token counting"""
|
|
182
|
-
counter = TokenCounter()
|
|
183
|
-
return counter.count_message_tokens(messages, model)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
def optimize_for_tokens(text: str, max_tokens: int, model: str = "gpt-3.5-turbo") -> str:
|
|
187
|
-
"""Quick text optimization for token limits"""
|
|
188
|
-
counter = TokenCounter()
|
|
189
|
-
return counter.optimize_text_for_tokens(text, max_tokens, model)
|
unrealon_sdk/README.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# UnrealOn SDK
|
|
2
|
-
|
|
3
|
-
Core SDK for UnrealOn parser development with WebSocket communication and enterprise services.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- WebSocket client for real-time communication
|
|
8
|
-
- Auto-generated API models
|
|
9
|
-
- Enterprise services (proxy, monitoring, etc.)
|
|
10
|
-
- CLI tools for SDK management
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
pip install unrealon-sdk
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
```python
|
|
21
|
-
from unrealon_sdk import AdapterClient, AdapterConfig
|
|
22
|
-
|
|
23
|
-
config = AdapterConfig()
|
|
24
|
-
client = AdapterClient(config)
|
|
25
|
-
```
|
unrealon_sdk/__init__.py
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
🚀 UnrealOn SDK v1.0 - Enterprise Parsing Platform
|
|
3
|
-
|
|
4
|
-
The most advanced SDK for building enterprise-grade parsing solutions with:
|
|
5
|
-
- 90% code reduction through intelligent automation
|
|
6
|
-
- Type-safe operations with auto-generated models
|
|
7
|
-
- Production-ready features out of the box
|
|
8
|
-
- Real-time communication and monitoring
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
# Import everything from src
|
|
12
|
-
from .src import *
|
|
13
|
-
|
|
14
|
-
# Description
|
|
15
|
-
__description__ = "Enterprise Parsing Platform SDK for UnrealOn"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# Import from centralized config
|
|
19
|
-
from unrealon.sdk_config import (
|
|
20
|
-
VERSION as __version__,
|
|
21
|
-
AUTHOR as __author__,
|
|
22
|
-
AUTHOR_EMAIL as __email__,
|
|
23
|
-
LICENSE as __license__,
|
|
24
|
-
PROJECT_URL as __url__,
|
|
25
|
-
VERSION_INFO,
|
|
26
|
-
PROJECT_INFO,
|
|
27
|
-
get_version,
|
|
28
|
-
is_debug_mode,
|
|
29
|
-
check_compatibility,
|
|
30
|
-
)
|
unrealon_sdk/pyproject.toml
DELETED
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["poetry-core"]
|
|
3
|
-
build-backend = "poetry.core.masonry.api"
|
|
4
|
-
|
|
5
|
-
[tool.poetry]
|
|
6
|
-
name = "unrealon-sdk"
|
|
7
|
-
version = "1.0.0"
|
|
8
|
-
description = "UnrealOn SDK Core - WebSocket, enterprise services, auto-generated models"
|
|
9
|
-
authors = ["UnrealOn SDK Team <sdk@unrealon.com>"]
|
|
10
|
-
readme = "README.md"
|
|
11
|
-
license = "MIT"
|
|
12
|
-
homepage = "https://github.com/unrealon/unrealon-sdk"
|
|
13
|
-
repository = "https://github.com/unrealon/unrealon-sdk"
|
|
14
|
-
documentation = "https://docs.unrealon.com/sdk"
|
|
15
|
-
keywords = ["websocket", "enterprise", "sdk", "parsing", "automation"]
|
|
16
|
-
classifiers = [
|
|
17
|
-
"Development Status :: 5 - Production/Stable",
|
|
18
|
-
"Intended Audience :: Developers",
|
|
19
|
-
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
20
|
-
"Topic :: System :: Networking",
|
|
21
|
-
"Topic :: Internet :: WWW/HTTP",
|
|
22
|
-
"Programming Language :: Python :: 3",
|
|
23
|
-
"Programming Language :: Python :: 3.9",
|
|
24
|
-
"Programming Language :: Python :: 3.10",
|
|
25
|
-
"Programming Language :: Python :: 3.11",
|
|
26
|
-
"Programming Language :: Python :: 3.12",
|
|
27
|
-
"License :: OSI Approved :: MIT License",
|
|
28
|
-
"Operating System :: OS Independent",
|
|
29
|
-
]
|
|
30
|
-
packages = [{include = "*", from = "src"}]
|
|
31
|
-
|
|
32
|
-
[tool.poetry.dependencies]
|
|
33
|
-
# CORE SDK DEPENDENCIES
|
|
34
|
-
python = "^3.9"
|
|
35
|
-
|
|
36
|
-
# Core Pydantic v2 requirement (MANDATORY)
|
|
37
|
-
pydantic = "^2.0.0"
|
|
38
|
-
pydantic-settings = "^2.0.0"
|
|
39
|
-
|
|
40
|
-
# WebSocket and Network Core
|
|
41
|
-
python-socketio = "^5.0"
|
|
42
|
-
websockets = "^12.0"
|
|
43
|
-
aiohttp = "^3.8.0"
|
|
44
|
-
httpx = ">=0.23.0,<0.24.0"
|
|
45
|
-
|
|
46
|
-
# Type System
|
|
47
|
-
typing-extensions = "^4.0"
|
|
48
|
-
|
|
49
|
-
# Configuration and Data
|
|
50
|
-
PyYAML = "^6.0"
|
|
51
|
-
python-dateutil = "^2.8"
|
|
52
|
-
|
|
53
|
-
[tool.poetry.group.dev.dependencies]
|
|
54
|
-
# Testing Framework (SDK Core)
|
|
55
|
-
pytest = "^7.4.0"
|
|
56
|
-
pytest-asyncio = "^0.21.0"
|
|
57
|
-
pytest-cov = "^4.1.0"
|
|
58
|
-
pytest-mock = "^3.11.0"
|
|
59
|
-
pytest-benchmark = "^4.0.0"
|
|
60
|
-
pytest-html = "^4.0.0"
|
|
61
|
-
pytest-xdist = "^3.3.0"
|
|
62
|
-
pytest-timeout = "^2.1.0"
|
|
63
|
-
|
|
64
|
-
# Type Checking (SDK Core)
|
|
65
|
-
mypy = "^1.5.0"
|
|
66
|
-
types-PyYAML = "^6.0"
|
|
67
|
-
types-python-dateutil = "^2.8"
|
|
68
|
-
|
|
69
|
-
# Security Testing
|
|
70
|
-
bandit = "^1.7.5"
|
|
71
|
-
safety = "^2.3.0"
|
|
72
|
-
|
|
73
|
-
# Code Quality
|
|
74
|
-
black = "^23.7.0"
|
|
75
|
-
isort = "^5.12.0"
|
|
76
|
-
flake8 = "^6.0.0"
|
|
77
|
-
pylint = "^2.17.0"
|
|
78
|
-
|
|
79
|
-
# Performance Testing
|
|
80
|
-
locust = "^2.0.0"
|
|
81
|
-
|
|
82
|
-
# Mock and Test Utilities
|
|
83
|
-
responses = "^0.23.0"
|
|
84
|
-
aioresponses = "^0.7.4"
|
|
85
|
-
|
|
86
|
-
[tool.poetry.scripts]
|
|
87
|
-
# SDK CLI entry points (when used standalone)
|
|
88
|
-
unrealon-sdk = "unrealon_sdk.cli.main:cli"
|
|
89
|
-
|
|
90
|
-
# SDK management utilities
|
|
91
|
-
sdk-health = "unrealon_sdk.cli.commands.health:main"
|
|
92
|
-
sdk-benchmark = "unrealon_sdk.cli.commands.benchmark:main"
|
|
93
|
-
sdk-diagnostics = "unrealon_sdk.cli.commands.diagnostics:main"
|
|
94
|
-
sdk-integration = "unrealon_sdk.cli.commands.integration:main"
|
|
95
|
-
sdk-security = "unrealon_sdk.cli.commands.security:main"
|
|
96
|
-
sdk-server = "unrealon_sdk.cli.commands.server:main"
|
|
97
|
-
|
|
98
|
-
[tool.mypy]
|
|
99
|
-
# SDK Core type checking (Strictest)
|
|
100
|
-
python_version = "3.9"
|
|
101
|
-
strict = true
|
|
102
|
-
warn_return_any = true
|
|
103
|
-
warn_unused_configs = true
|
|
104
|
-
disallow_any_generics = true
|
|
105
|
-
disallow_subclassing_any = true
|
|
106
|
-
disallow_untyped_calls = true
|
|
107
|
-
disallow_untyped_defs = true
|
|
108
|
-
disallow_incomplete_defs = true
|
|
109
|
-
check_untyped_defs = true
|
|
110
|
-
disallow_untyped_decorators = true
|
|
111
|
-
no_implicit_optional = true
|
|
112
|
-
warn_redundant_casts = true
|
|
113
|
-
warn_unused_ignores = true
|
|
114
|
-
warn_no_return = true
|
|
115
|
-
warn_unreachable = true
|
|
116
|
-
strict_equality = true
|
|
117
|
-
show_error_codes = true
|
|
118
|
-
|
|
119
|
-
[[tool.mypy.overrides]]
|
|
120
|
-
module = [
|
|
121
|
-
"socketio.*",
|
|
122
|
-
"aiohttp.*",
|
|
123
|
-
"locust.*",
|
|
124
|
-
"responses.*",
|
|
125
|
-
"aioresponses.*",
|
|
126
|
-
]
|
|
127
|
-
ignore_missing_imports = true
|
|
128
|
-
|
|
129
|
-
[tool.black]
|
|
130
|
-
# SDK Core formatting
|
|
131
|
-
line-length = 100
|
|
132
|
-
target-version = ['py39']
|
|
133
|
-
include = '\.pyi?$'
|
|
134
|
-
|
|
135
|
-
[tool.isort]
|
|
136
|
-
# SDK Core import sorting
|
|
137
|
-
profile = "black"
|
|
138
|
-
line_length = 100
|
|
139
|
-
multi_line_output = 3
|
|
140
|
-
include_trailing_comma = true
|
|
141
|
-
force_grid_wrap = 0
|
|
142
|
-
use_parentheses = true
|
|
143
|
-
ensure_newline_before_comments = true
|
|
144
|
-
known_first_party = ["unrealon_sdk"]
|
|
145
|
-
known_third_party = ["socketio", "aiohttp", "httpx", "pydantic", "yaml"]
|
|
146
|
-
|
|
147
|
-
[tool.pytest.ini_options]
|
|
148
|
-
# SDK Core testing (Strictest requirements)
|
|
149
|
-
minversion = "7.0"
|
|
150
|
-
testpaths = ["tests"]
|
|
151
|
-
python_files = ["test_*.py", "*_test.py"]
|
|
152
|
-
python_classes = ["Test*"]
|
|
153
|
-
python_functions = ["test_*"]
|
|
154
|
-
addopts = [
|
|
155
|
-
"--strict-markers",
|
|
156
|
-
"--strict-config",
|
|
157
|
-
"--cov=unrealon_sdk",
|
|
158
|
-
"--cov-report=term-missing",
|
|
159
|
-
"--cov-report=html:htmlcov_sdk",
|
|
160
|
-
"--cov-report=xml:coverage_sdk.xml",
|
|
161
|
-
"--cov-fail-under=100", # SDK requires 100% coverage
|
|
162
|
-
"--cov-branch",
|
|
163
|
-
"--benchmark-disable",
|
|
164
|
-
"--timeout=30",
|
|
165
|
-
"-v",
|
|
166
|
-
"-ra",
|
|
167
|
-
]
|
|
168
|
-
markers = [
|
|
169
|
-
"unit: Unit tests (fast, no external dependencies)",
|
|
170
|
-
"integration: Integration tests (slower, external dependencies)",
|
|
171
|
-
"websocket: WebSocket communication tests",
|
|
172
|
-
"enterprise: Enterprise features tests",
|
|
173
|
-
"performance: Performance and benchmark tests",
|
|
174
|
-
"security: Security and vulnerability tests",
|
|
175
|
-
"slow: Slow tests (> 5 seconds)",
|
|
176
|
-
"network: Tests requiring network access",
|
|
177
|
-
]
|
|
178
|
-
asyncio_mode = "auto"
|
|
179
|
-
timeout = 30
|
|
180
|
-
filterwarnings = [
|
|
181
|
-
"error",
|
|
182
|
-
"ignore::UserWarning",
|
|
183
|
-
"ignore::DeprecationWarning",
|
|
184
|
-
]
|
|
185
|
-
|
|
186
|
-
[tool.coverage.run]
|
|
187
|
-
# SDK Core coverage (100% requirement)
|
|
188
|
-
source = ["unrealon_sdk"]
|
|
189
|
-
branch = true
|
|
190
|
-
omit = [
|
|
191
|
-
"*/tests/*",
|
|
192
|
-
"*/test_*",
|
|
193
|
-
"*/__pycache__/*",
|
|
194
|
-
"*/examples/*",
|
|
195
|
-
]
|
|
196
|
-
|
|
197
|
-
[tool.coverage.report]
|
|
198
|
-
# SDK Core coverage reporting
|
|
199
|
-
precision = 2
|
|
200
|
-
show_missing = true
|
|
201
|
-
skip_covered = false
|
|
202
|
-
exclude_lines = [
|
|
203
|
-
"pragma: no cover",
|
|
204
|
-
"def __repr__",
|
|
205
|
-
"if self.debug:",
|
|
206
|
-
"if settings.DEBUG",
|
|
207
|
-
"raise AssertionError",
|
|
208
|
-
"raise NotImplementedError",
|
|
209
|
-
"if 0:",
|
|
210
|
-
"if __name__ == .__main__.:",
|
|
211
|
-
"class .*\\bProtocol\\):",
|
|
212
|
-
"@(abc\\.)?abstractmethod",
|
|
213
|
-
]
|
|
214
|
-
|
|
215
|
-
[tool.bandit]
|
|
216
|
-
# SDK Core security scanning
|
|
217
|
-
exclude_dirs = ["tests", "examples"]
|
|
218
|
-
skips = ["B101", "B601"]
|
|
219
|
-
|
|
220
|
-
[tool.pylint.messages_control]
|
|
221
|
-
# SDK Core code quality
|
|
222
|
-
disable = [
|
|
223
|
-
"too-few-public-methods",
|
|
224
|
-
"too-many-arguments",
|
|
225
|
-
"too-many-instance-attributes",
|
|
226
|
-
"line-too-long",
|
|
227
|
-
"missing-docstring",
|
|
228
|
-
]
|
|
229
|
-
|
|
230
|
-
[tool.pylint.format]
|
|
231
|
-
max-line-length = 100
|