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
unrealon_llm/src/exceptions.py
DELETED
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
UnrealOn LLM Exceptions
|
|
3
|
-
|
|
4
|
-
Custom exception classes for UnrealOn LLM platform with detailed error information.
|
|
5
|
-
All exceptions follow KISS methodology with clear error messages and context.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from typing import Any, Dict, Optional
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class LLMError(Exception):
|
|
12
|
-
"""Base exception for all LLM operations"""
|
|
13
|
-
|
|
14
|
-
def __init__(
|
|
15
|
-
self,
|
|
16
|
-
message: str,
|
|
17
|
-
error_code: Optional[str] = None,
|
|
18
|
-
context: Optional[Dict[str, Any]] = None
|
|
19
|
-
):
|
|
20
|
-
super().__init__(message)
|
|
21
|
-
self.message = message
|
|
22
|
-
self.error_code = error_code
|
|
23
|
-
self.context = context or {}
|
|
24
|
-
|
|
25
|
-
def __str__(self) -> str:
|
|
26
|
-
error_info = f"LLMError: {self.message}"
|
|
27
|
-
if self.error_code:
|
|
28
|
-
error_info += f" (Code: {self.error_code})"
|
|
29
|
-
return error_info
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class APIError(LLMError):
|
|
33
|
-
"""Base class for API-related errors"""
|
|
34
|
-
pass
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class OpenRouterAPIError(APIError):
|
|
38
|
-
"""OpenRouter API specific errors"""
|
|
39
|
-
pass
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
class OpenAIAPIError(APIError):
|
|
43
|
-
"""OpenAI API specific errors"""
|
|
44
|
-
pass
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
class AnthropicAPIError(APIError):
|
|
48
|
-
"""Anthropic API specific errors"""
|
|
49
|
-
pass
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
class RateLimitError(APIError):
|
|
53
|
-
"""API rate limit exceeded"""
|
|
54
|
-
|
|
55
|
-
def __init__(
|
|
56
|
-
self,
|
|
57
|
-
message: str = "API rate limit exceeded",
|
|
58
|
-
retry_after: Optional[int] = None,
|
|
59
|
-
**kwargs
|
|
60
|
-
):
|
|
61
|
-
super().__init__(message, **kwargs)
|
|
62
|
-
self.retry_after = retry_after
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
class APIQuotaExceededError(APIError):
|
|
66
|
-
"""API quota exceeded"""
|
|
67
|
-
pass
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
class ModelUnavailableError(APIError):
|
|
71
|
-
"""Requested model is not available"""
|
|
72
|
-
|
|
73
|
-
def __init__(
|
|
74
|
-
self,
|
|
75
|
-
model_name: str,
|
|
76
|
-
available_models: Optional[list] = None,
|
|
77
|
-
**kwargs
|
|
78
|
-
):
|
|
79
|
-
message = f"Model '{model_name}' is not available"
|
|
80
|
-
super().__init__(message, **kwargs)
|
|
81
|
-
self.model_name = model_name
|
|
82
|
-
self.available_models = available_models or []
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
class NetworkError(APIError):
|
|
86
|
-
"""Network connectivity issues"""
|
|
87
|
-
pass
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
class AuthenticationError(APIError):
|
|
91
|
-
"""API authentication failed"""
|
|
92
|
-
pass
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
class CostLimitExceededError(LLMError):
|
|
96
|
-
"""Cost limit exceeded"""
|
|
97
|
-
|
|
98
|
-
def __init__(
|
|
99
|
-
self,
|
|
100
|
-
current_cost: float,
|
|
101
|
-
limit: float,
|
|
102
|
-
**kwargs
|
|
103
|
-
):
|
|
104
|
-
message = f"Cost limit exceeded: ${current_cost:.4f} > ${limit:.4f}"
|
|
105
|
-
super().__init__(message, **kwargs)
|
|
106
|
-
self.current_cost = current_cost
|
|
107
|
-
self.limit = limit
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
class TokenLimitExceededError(LLMError):
|
|
111
|
-
"""Token limit exceeded"""
|
|
112
|
-
|
|
113
|
-
def __init__(
|
|
114
|
-
self,
|
|
115
|
-
token_count: int,
|
|
116
|
-
limit: int,
|
|
117
|
-
**kwargs
|
|
118
|
-
):
|
|
119
|
-
message = f"Token limit exceeded: {token_count} > {limit}"
|
|
120
|
-
super().__init__(message, **kwargs)
|
|
121
|
-
self.token_count = token_count
|
|
122
|
-
self.limit = limit
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
class ValidationError(LLMError):
|
|
126
|
-
"""Data validation errors"""
|
|
127
|
-
pass
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
class HTMLParsingError(LLMError):
|
|
131
|
-
"""HTML parsing and analysis errors"""
|
|
132
|
-
pass
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
class HTMLTooLargeError(HTMLParsingError):
|
|
136
|
-
"""HTML content too large for processing"""
|
|
137
|
-
|
|
138
|
-
def __init__(
|
|
139
|
-
self,
|
|
140
|
-
html_size: int,
|
|
141
|
-
max_size: int,
|
|
142
|
-
**kwargs
|
|
143
|
-
):
|
|
144
|
-
message = f"HTML too large: {html_size} bytes > {max_size} bytes limit"
|
|
145
|
-
super().__init__(message, **kwargs)
|
|
146
|
-
self.html_size = html_size
|
|
147
|
-
self.max_size = max_size
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
class PatternDetectionError(HTMLParsingError):
|
|
151
|
-
"""Pattern detection failed"""
|
|
152
|
-
pass
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
class SelectorGenerationError(HTMLParsingError):
|
|
156
|
-
"""Selector generation failed"""
|
|
157
|
-
pass
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
class SelectorValidationError(HTMLParsingError):
|
|
161
|
-
"""Selector validation failed"""
|
|
162
|
-
|
|
163
|
-
def __init__(
|
|
164
|
-
self,
|
|
165
|
-
selector: str,
|
|
166
|
-
validation_message: str,
|
|
167
|
-
**kwargs
|
|
168
|
-
):
|
|
169
|
-
message = f"Selector validation failed: '{selector}' - {validation_message}"
|
|
170
|
-
super().__init__(message, **kwargs)
|
|
171
|
-
self.selector = selector
|
|
172
|
-
self.validation_message = validation_message
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
class TranslationError(LLMError):
|
|
176
|
-
"""Translation operation errors"""
|
|
177
|
-
pass
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
class LanguageDetectionError(TranslationError):
|
|
181
|
-
"""Language detection failed"""
|
|
182
|
-
pass
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
class TranslationQualityError(TranslationError):
|
|
186
|
-
"""Translation quality below threshold"""
|
|
187
|
-
|
|
188
|
-
def __init__(
|
|
189
|
-
self,
|
|
190
|
-
quality_score: float,
|
|
191
|
-
threshold: float,
|
|
192
|
-
**kwargs
|
|
193
|
-
):
|
|
194
|
-
message = f"Translation quality too low: {quality_score:.2f} < {threshold:.2f}"
|
|
195
|
-
super().__init__(message, **kwargs)
|
|
196
|
-
self.quality_score = quality_score
|
|
197
|
-
self.threshold = threshold
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
class SchemaGenerationError(LLMError):
|
|
201
|
-
"""Schema generation errors"""
|
|
202
|
-
pass
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
class TypeInferenceError(SchemaGenerationError):
|
|
206
|
-
"""Type inference failed"""
|
|
207
|
-
pass
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
class CodeGenerationError(SchemaGenerationError):
|
|
211
|
-
"""Generated code is invalid"""
|
|
212
|
-
|
|
213
|
-
def __init__(
|
|
214
|
-
self,
|
|
215
|
-
code_type: str,
|
|
216
|
-
syntax_error: str,
|
|
217
|
-
**kwargs
|
|
218
|
-
):
|
|
219
|
-
message = f"{code_type} code generation failed: {syntax_error}"
|
|
220
|
-
super().__init__(message, **kwargs)
|
|
221
|
-
self.code_type = code_type
|
|
222
|
-
self.syntax_error = syntax_error
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
class CacheError(LLMError):
|
|
226
|
-
"""Cache operation errors"""
|
|
227
|
-
pass
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
class CacheCorruptionError(CacheError):
|
|
231
|
-
"""Cache data is corrupted"""
|
|
232
|
-
pass
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
class ConfigurationError(LLMError):
|
|
236
|
-
"""Configuration errors"""
|
|
237
|
-
pass
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
class MissingAPIKeyError(ConfigurationError):
|
|
241
|
-
"""API key is missing"""
|
|
242
|
-
|
|
243
|
-
def __init__(
|
|
244
|
-
self,
|
|
245
|
-
provider: str,
|
|
246
|
-
**kwargs
|
|
247
|
-
):
|
|
248
|
-
message = f"API key missing for provider: {provider}"
|
|
249
|
-
super().__init__(message, **kwargs)
|
|
250
|
-
self.provider = provider
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
class InvalidConfigurationError(ConfigurationError):
|
|
254
|
-
"""Configuration is invalid"""
|
|
255
|
-
pass
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
class TestingError(LLMError):
|
|
259
|
-
"""Testing infrastructure errors"""
|
|
260
|
-
pass
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
class MockSetupError(TestingError):
|
|
264
|
-
"""Mock setup failed"""
|
|
265
|
-
pass
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
class CostSimulationError(TestingError):
|
|
269
|
-
"""Cost simulation failed"""
|
|
270
|
-
pass
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
class ResponseParsingError(LLMError):
|
|
274
|
-
"""Failed to parse LLM response"""
|
|
275
|
-
|
|
276
|
-
def __init__(
|
|
277
|
-
self,
|
|
278
|
-
response_content: str,
|
|
279
|
-
expected_format: str,
|
|
280
|
-
**kwargs
|
|
281
|
-
):
|
|
282
|
-
message = f"Failed to parse response as {expected_format}"
|
|
283
|
-
super().__init__(message, **kwargs)
|
|
284
|
-
self.response_content = response_content[:200] + "..." if len(response_content) > 200 else response_content
|
|
285
|
-
self.expected_format = expected_format
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
class ProcessingPipelineError(LLMError):
|
|
289
|
-
"""Processing pipeline errors"""
|
|
290
|
-
|
|
291
|
-
def __init__(
|
|
292
|
-
self,
|
|
293
|
-
stage: str,
|
|
294
|
-
stage_error: Exception,
|
|
295
|
-
**kwargs
|
|
296
|
-
):
|
|
297
|
-
message = f"Pipeline failed at stage '{stage}': {str(stage_error)}"
|
|
298
|
-
super().__init__(message, **kwargs)
|
|
299
|
-
self.stage = stage
|
|
300
|
-
self.stage_error = stage_error
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
class RetryExhaustedError(LLMError):
|
|
304
|
-
"""All retry attempts exhausted"""
|
|
305
|
-
|
|
306
|
-
def __init__(
|
|
307
|
-
self,
|
|
308
|
-
operation: str,
|
|
309
|
-
attempts: int,
|
|
310
|
-
last_error: Exception,
|
|
311
|
-
**kwargs
|
|
312
|
-
):
|
|
313
|
-
message = f"Operation '{operation}' failed after {attempts} attempts"
|
|
314
|
-
super().__init__(message, **kwargs)
|
|
315
|
-
self.operation = operation
|
|
316
|
-
self.attempts = attempts
|
|
317
|
-
self.last_error = last_error
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
# Convenience functions for common error patterns
|
|
321
|
-
def raise_if_cost_exceeded(current_cost: float, limit: float) -> None:
|
|
322
|
-
"""Raise CostLimitExceededError if cost exceeds limit"""
|
|
323
|
-
if current_cost > limit:
|
|
324
|
-
raise CostLimitExceededError(current_cost, limit)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
def raise_if_tokens_exceeded(token_count: int, limit: int) -> None:
|
|
328
|
-
"""Raise TokenLimitExceededError if tokens exceed limit"""
|
|
329
|
-
if token_count > limit:
|
|
330
|
-
raise TokenLimitExceededError(token_count, limit)
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
def raise_if_html_too_large(html_size: int, max_size: int) -> None:
|
|
334
|
-
"""Raise HTMLTooLargeError if HTML exceeds size limit"""
|
|
335
|
-
if html_size > max_size:
|
|
336
|
-
raise HTMLTooLargeError(html_size, max_size)
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
def wrap_api_error(provider: str, original_error: Exception) -> APIError:
|
|
340
|
-
"""Wrap provider-specific API errors"""
|
|
341
|
-
error_message = str(original_error)
|
|
342
|
-
|
|
343
|
-
if provider.lower() == "openrouter":
|
|
344
|
-
return OpenRouterAPIError(error_message, context={"original_error": original_error})
|
|
345
|
-
elif provider.lower() == "openai":
|
|
346
|
-
return OpenAIAPIError(error_message, context={"original_error": original_error})
|
|
347
|
-
elif provider.lower() == "anthropic":
|
|
348
|
-
return AnthropicAPIError(error_message, context={"original_error": original_error})
|
|
349
|
-
else:
|
|
350
|
-
return APIError(error_message, context={"provider": provider, "original_error": original_error})
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
# Error code constants
|
|
354
|
-
class ErrorCodes:
|
|
355
|
-
"""Standard error codes for LLM operations"""
|
|
356
|
-
|
|
357
|
-
# API errors
|
|
358
|
-
RATE_LIMIT = "RATE_LIMIT"
|
|
359
|
-
QUOTA_EXCEEDED = "QUOTA_EXCEEDED"
|
|
360
|
-
MODEL_UNAVAILABLE = "MODEL_UNAVAILABLE"
|
|
361
|
-
AUTHENTICATION_FAILED = "AUTH_FAILED"
|
|
362
|
-
NETWORK_ERROR = "NETWORK_ERROR"
|
|
363
|
-
|
|
364
|
-
# Cost errors
|
|
365
|
-
COST_LIMIT_EXCEEDED = "COST_LIMIT"
|
|
366
|
-
TOKEN_LIMIT_EXCEEDED = "TOKEN_LIMIT"
|
|
367
|
-
|
|
368
|
-
# HTML errors
|
|
369
|
-
HTML_TOO_LARGE = "HTML_TOO_LARGE"
|
|
370
|
-
PATTERN_DETECTION_FAILED = "PATTERN_FAILED"
|
|
371
|
-
SELECTOR_GENERATION_FAILED = "SELECTOR_FAILED"
|
|
372
|
-
SELECTOR_VALIDATION_FAILED = "SELECTOR_INVALID"
|
|
373
|
-
|
|
374
|
-
# Translation errors
|
|
375
|
-
LANGUAGE_DETECTION_FAILED = "LANG_DETECT_FAILED"
|
|
376
|
-
TRANSLATION_QUALITY_LOW = "TRANSLATION_LOW_QUALITY"
|
|
377
|
-
|
|
378
|
-
# Schema errors
|
|
379
|
-
TYPE_INFERENCE_FAILED = "TYPE_INFERENCE_FAILED"
|
|
380
|
-
CODE_GENERATION_FAILED = "CODE_GEN_FAILED"
|
|
381
|
-
|
|
382
|
-
# Cache errors
|
|
383
|
-
CACHE_CORRUPTED = "CACHE_CORRUPTED"
|
|
384
|
-
|
|
385
|
-
# Config errors
|
|
386
|
-
MISSING_API_KEY = "MISSING_API_KEY"
|
|
387
|
-
INVALID_CONFIG = "INVALID_CONFIG"
|
|
388
|
-
|
|
389
|
-
# Processing errors
|
|
390
|
-
PIPELINE_FAILED = "PIPELINE_FAILED"
|
|
391
|
-
RETRY_EXHAUSTED = "RETRY_EXHAUSTED"
|
|
392
|
-
RESPONSE_PARSING_FAILED = "RESPONSE_PARSE_FAILED"
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
UnrealOn LLM Configuration
|
|
3
|
-
|
|
4
|
-
Configuration management for UnrealOn LLM including logging setup,
|
|
5
|
-
environment variable handling, and runtime configuration.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from .logging_config import (
|
|
9
|
-
LoggingConfig,
|
|
10
|
-
setup_llm_logging,
|
|
11
|
-
get_logging_config_from_env,
|
|
12
|
-
configure_llm_logging,
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
__all__ = [
|
|
16
|
-
"LoggingConfig",
|
|
17
|
-
"setup_llm_logging",
|
|
18
|
-
"get_logging_config_from_env",
|
|
19
|
-
"configure_llm_logging",
|
|
20
|
-
]
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Logging Configuration for UnrealOn LLM
|
|
3
|
-
|
|
4
|
-
Provides configuration management for the integrated SDK logging system.
|
|
5
|
-
Handles environment variables, default settings, and initialization.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
import os
|
|
9
|
-
from typing import Optional
|
|
10
|
-
from pydantic import BaseModel, Field, ConfigDict
|
|
11
|
-
from unrealon_sdk.src.dto.logging import SDKSeverity
|
|
12
|
-
from unrealon_llm.src.llm_logging import initialize_llm_logger, get_llm_logger, LLMLogger
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class LoggingConfig(BaseModel):
|
|
16
|
-
"""Configuration for UnrealOn LLM logging system."""
|
|
17
|
-
|
|
18
|
-
# Basic logging settings
|
|
19
|
-
log_level: str = Field(default="INFO", description="Logging level (TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL)")
|
|
20
|
-
enable_console: bool = Field(default=True, description="Enable console logging output")
|
|
21
|
-
enable_websocket: bool = Field(default=True, description="Enable WebSocket logging for real-time streaming")
|
|
22
|
-
|
|
23
|
-
# Session management
|
|
24
|
-
session_id: Optional[str] = Field(default=None, description="Custom session ID for tracking")
|
|
25
|
-
|
|
26
|
-
# Log filtering and performance
|
|
27
|
-
min_cost_threshold_usd: float = Field(default=0.0001, description="Minimum cost to log (filters micro-transactions)")
|
|
28
|
-
log_token_details: bool = Field(default=True, description="Include token count details in logs")
|
|
29
|
-
log_html_size_details: bool = Field(default=True, description="Include HTML size details in logs")
|
|
30
|
-
|
|
31
|
-
# Development settings
|
|
32
|
-
verbose_errors: bool = Field(default=True, description="Include full error traces in logs")
|
|
33
|
-
log_cache_operations: bool = Field(default=True, description="Log cache hits/misses/stores")
|
|
34
|
-
log_performance_metrics: bool = Field(default=True, description="Log performance metrics and thresholds")
|
|
35
|
-
|
|
36
|
-
model_config = ConfigDict(
|
|
37
|
-
env_prefix="UNREALON_LLM_LOG_",
|
|
38
|
-
extra="ignore"
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def get_logging_config_from_env() -> LoggingConfig:
|
|
43
|
-
"""
|
|
44
|
-
Create logging configuration from environment variables.
|
|
45
|
-
|
|
46
|
-
Environment variables:
|
|
47
|
-
- UNREALON_LLM_LOG_LEVEL: Logging level (default: INFO)
|
|
48
|
-
- UNREALON_LLM_LOG_ENABLE_CONSOLE: Enable console output (default: true)
|
|
49
|
-
- UNREALON_LLM_LOG_ENABLE_WEBSOCKET: Enable WebSocket output (default: true)
|
|
50
|
-
- UNREALON_LLM_LOG_SESSION_ID: Custom session ID
|
|
51
|
-
- UNREALON_LLM_LOG_MIN_COST_THRESHOLD_USD: Minimum cost to log (default: 0.0001)
|
|
52
|
-
- UNREALON_LLM_LOG_TOKEN_DETAILS: Log token details (default: true)
|
|
53
|
-
- UNREALON_LLM_LOG_HTML_SIZE_DETAILS: Log HTML size details (default: true)
|
|
54
|
-
- UNREALON_LLM_LOG_VERBOSE_ERRORS: Include full error traces (default: true)
|
|
55
|
-
- UNREALON_LLM_LOG_CACHE_OPERATIONS: Log cache operations (default: true)
|
|
56
|
-
- UNREALON_LLM_LOG_PERFORMANCE_METRICS: Log performance metrics (default: true)
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
# Helper function to parse boolean env vars
|
|
60
|
-
def parse_bool(value: str) -> bool:
|
|
61
|
-
return value.lower() in ("true", "1", "yes", "on")
|
|
62
|
-
|
|
63
|
-
config_data = {}
|
|
64
|
-
|
|
65
|
-
# Get values from environment
|
|
66
|
-
if log_level := os.getenv("UNREALON_LLM_LOG_LEVEL"):
|
|
67
|
-
config_data["log_level"] = log_level.upper()
|
|
68
|
-
|
|
69
|
-
if enable_console := os.getenv("UNREALON_LLM_LOG_ENABLE_CONSOLE"):
|
|
70
|
-
config_data["enable_console"] = parse_bool(enable_console)
|
|
71
|
-
|
|
72
|
-
if enable_websocket := os.getenv("UNREALON_LLM_LOG_ENABLE_WEBSOCKET"):
|
|
73
|
-
config_data["enable_websocket"] = parse_bool(enable_websocket)
|
|
74
|
-
|
|
75
|
-
if session_id := os.getenv("UNREALON_LLM_LOG_SESSION_ID"):
|
|
76
|
-
config_data["session_id"] = session_id
|
|
77
|
-
|
|
78
|
-
if min_cost_threshold := os.getenv("UNREALON_LLM_LOG_MIN_COST_THRESHOLD_USD"):
|
|
79
|
-
try:
|
|
80
|
-
config_data["min_cost_threshold_usd"] = float(min_cost_threshold)
|
|
81
|
-
except ValueError:
|
|
82
|
-
pass # Use default if invalid
|
|
83
|
-
|
|
84
|
-
if log_token_details := os.getenv("UNREALON_LLM_LOG_TOKEN_DETAILS"):
|
|
85
|
-
config_data["log_token_details"] = parse_bool(log_token_details)
|
|
86
|
-
|
|
87
|
-
if log_html_size_details := os.getenv("UNREALON_LLM_LOG_HTML_SIZE_DETAILS"):
|
|
88
|
-
config_data["log_html_size_details"] = parse_bool(log_html_size_details)
|
|
89
|
-
|
|
90
|
-
if verbose_errors := os.getenv("UNREALON_LLM_LOG_VERBOSE_ERRORS"):
|
|
91
|
-
config_data["verbose_errors"] = parse_bool(verbose_errors)
|
|
92
|
-
|
|
93
|
-
if log_cache_operations := os.getenv("UNREALON_LLM_LOG_CACHE_OPERATIONS"):
|
|
94
|
-
config_data["log_cache_operations"] = parse_bool(log_cache_operations)
|
|
95
|
-
|
|
96
|
-
if log_performance_metrics := os.getenv("UNREALON_LLM_LOG_PERFORMANCE_METRICS"):
|
|
97
|
-
config_data["log_performance_metrics"] = parse_bool(log_performance_metrics)
|
|
98
|
-
|
|
99
|
-
return LoggingConfig(**config_data)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def setup_llm_logging(config: Optional[LoggingConfig] = None) -> LLMLogger:
|
|
103
|
-
"""
|
|
104
|
-
Set up UnrealOn LLM logging with the given configuration.
|
|
105
|
-
|
|
106
|
-
Args:
|
|
107
|
-
config: Logging configuration. If None, loads from environment.
|
|
108
|
-
|
|
109
|
-
Returns:
|
|
110
|
-
Initialized LLM logger instance.
|
|
111
|
-
|
|
112
|
-
Example:
|
|
113
|
-
>>> from unrealon_llm.src.llm_config import setup_llm_logging
|
|
114
|
-
>>> logger = setup_llm_logging()
|
|
115
|
-
>>> # Now all LLM operations will be logged
|
|
116
|
-
"""
|
|
117
|
-
if config is None:
|
|
118
|
-
config = get_logging_config_from_env()
|
|
119
|
-
|
|
120
|
-
# Check if logger is already initialized
|
|
121
|
-
existing_logger = get_llm_logger()
|
|
122
|
-
if existing_logger:
|
|
123
|
-
return existing_logger
|
|
124
|
-
|
|
125
|
-
# Initialize with config
|
|
126
|
-
return initialize_llm_logger(
|
|
127
|
-
session_id=config.session_id,
|
|
128
|
-
log_level=config.log_level,
|
|
129
|
-
enable_console=config.enable_console,
|
|
130
|
-
enable_websocket=config.enable_websocket,
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
def configure_llm_logging(
|
|
135
|
-
log_level: str = "INFO",
|
|
136
|
-
enable_console: bool = True,
|
|
137
|
-
enable_websocket: bool = True,
|
|
138
|
-
session_id: Optional[str] = None,
|
|
139
|
-
) -> LLMLogger:
|
|
140
|
-
"""
|
|
141
|
-
Quick configuration function for UnrealOn LLM logging.
|
|
142
|
-
|
|
143
|
-
Args:
|
|
144
|
-
log_level: Logging level (TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL)
|
|
145
|
-
enable_console: Enable console output
|
|
146
|
-
enable_websocket: Enable WebSocket output
|
|
147
|
-
session_id: Custom session ID
|
|
148
|
-
|
|
149
|
-
Returns:
|
|
150
|
-
Initialized LLM logger instance.
|
|
151
|
-
|
|
152
|
-
Example:
|
|
153
|
-
>>> from unrealon_llm.src.llm_config import configure_llm_logging
|
|
154
|
-
>>> logger = configure_llm_logging(log_level="DEBUG", session_id="my-session")
|
|
155
|
-
"""
|
|
156
|
-
config = LoggingConfig(
|
|
157
|
-
log_level=log_level,
|
|
158
|
-
enable_console=enable_console,
|
|
159
|
-
enable_websocket=enable_websocket,
|
|
160
|
-
session_id=session_id,
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
return setup_llm_logging(config)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
# Auto-initialize logging if environment variables are present
|
|
167
|
-
def _auto_initialize():
|
|
168
|
-
"""Auto-initialize logging if environment variables indicate it should be enabled."""
|
|
169
|
-
if os.getenv("UNREALON_LLM_AUTO_INIT_LOGGING", "false").lower() in ("true", "1", "yes", "on"):
|
|
170
|
-
try:
|
|
171
|
-
setup_llm_logging()
|
|
172
|
-
except Exception:
|
|
173
|
-
# Silently fail auto-initialization to avoid breaking imports
|
|
174
|
-
pass
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
# Run auto-initialization on module import
|
|
178
|
-
_auto_initialize()
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
UnrealOn LLM Logging Integration
|
|
3
|
-
|
|
4
|
-
Integrates enterprise-grade logging from UnrealOn SDK with LLM-specific functionality.
|
|
5
|
-
Provides structured logging for AI operations, cost tracking, and performance monitoring.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
|
-
from unrealon_sdk.src.enterprise.logging.development import (
|
|
9
|
-
DevelopmentLogger,
|
|
10
|
-
initialize_development_logger,
|
|
11
|
-
get_development_logger,
|
|
12
|
-
track_development_operation,
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
from unrealon_sdk.src.dto.logging import (
|
|
16
|
-
SDKEventType,
|
|
17
|
-
SDKSeverity,
|
|
18
|
-
SDKContext,
|
|
19
|
-
SDKDevelopmentEvent,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
from .llm_events import LLMEventType, LLMContext
|
|
23
|
-
from .llm_logger import LLMLogger, initialize_llm_logger, get_llm_logger
|
|
24
|
-
|
|
25
|
-
__all__ = [
|
|
26
|
-
# SDK Logger components
|
|
27
|
-
"DevelopmentLogger",
|
|
28
|
-
"initialize_development_logger",
|
|
29
|
-
"get_development_logger",
|
|
30
|
-
"track_development_operation",
|
|
31
|
-
"SDKEventType",
|
|
32
|
-
"SDKSeverity",
|
|
33
|
-
"SDKContext",
|
|
34
|
-
"SDKDevelopmentEvent",
|
|
35
|
-
|
|
36
|
-
# LLM-specific components
|
|
37
|
-
"LLMEventType",
|
|
38
|
-
"LLMContext",
|
|
39
|
-
"LLMLogger",
|
|
40
|
-
"initialize_llm_logger",
|
|
41
|
-
"get_llm_logger",
|
|
42
|
-
]
|