Spaces:
Paused
Paused
Update graph_config.py
Browse files- graph_config.py +29 -82
graph_config.py
CHANGED
|
@@ -7,7 +7,7 @@ Modify these values to change graph behavior.
|
|
| 7 |
|
| 8 |
Author: AI Lab Team
|
| 9 |
Last Updated: 2025-10-10
|
| 10 |
-
Version: 3.
|
| 11 |
"""
|
| 12 |
|
| 13 |
import os
|
|
@@ -78,25 +78,22 @@ GPT4O_INPUT_COST_PER_1K_TOKENS = 0.005
|
|
| 78 |
GPT4O_OUTPUT_COST_PER_1K_TOKENS = 0.015
|
| 79 |
AVG_TOKENS_PER_CALL = 2000
|
| 80 |
|
| 81 |
-
# Budget multipliers (
|
| 82 |
-
BUDGET_BUFFER_MULTIPLIER = 1.20
|
| 83 |
-
MAX_COST_MULTIPLIER = 1.20
|
| 84 |
|
| 85 |
|
| 86 |
# ============================================================================
|
| 87 |
# LANGUAGE & CODING CONFIGURATION
|
| 88 |
# ============================================================================
|
| 89 |
|
| 90 |
-
# Default language
|
| 91 |
DEFAULT_LANGUAGE = "python"
|
| 92 |
|
| 93 |
-
# Supported languages
|
| 94 |
SUPPORTED_LANGUAGES = [
|
| 95 |
"python", "javascript", "typescript", "java",
|
| 96 |
"go", "rust", "cpp", "csharp", "php", "ruby"
|
| 97 |
]
|
| 98 |
|
| 99 |
-
# Language preference keywords
|
| 100 |
LANGUAGE_PREFERENCE_KEYWORDS = {
|
| 101 |
"python": ["python", "py", "prefer python", "use python"],
|
| 102 |
"javascript": ["javascript", "js", "node", "prefer javascript"],
|
|
@@ -106,14 +103,12 @@ LANGUAGE_PREFERENCE_KEYWORDS = {
|
|
| 106 |
"rust": ["rust", "prefer rust"]
|
| 107 |
}
|
| 108 |
|
| 109 |
-
# No-code indicators (requests that should NOT generate code)
|
| 110 |
NO_CODE_KEYWORDS = [
|
| 111 |
'what is', 'what are', 'explain', 'describe',
|
| 112 |
'summarize', 'list', 'tell me about',
|
| 113 |
'definition of', 'meaning of', 'overview of'
|
| 114 |
]
|
| 115 |
|
| 116 |
-
# Code indicators (requests that SHOULD generate code)
|
| 117 |
CODE_KEYWORDS = [
|
| 118 |
'script', 'function', 'api', 'backend', 'frontend',
|
| 119 |
'algorithm', 'program', 'code', 'implement',
|
|
@@ -125,7 +120,6 @@ CODE_KEYWORDS = [
|
|
| 125 |
# RESEARCH MODE CONFIGURATION
|
| 126 |
# ============================================================================
|
| 127 |
|
| 128 |
-
# Research detection keywords
|
| 129 |
RESEARCH_KEYWORDS = [
|
| 130 |
'research', 'analyze', 'study', 'investigate', 'explore',
|
| 131 |
'survey', 'review', 'compare', 'evaluate', 'assess',
|
|
@@ -133,21 +127,18 @@ RESEARCH_KEYWORDS = [
|
|
| 133 |
'comprehensive', 'detailed analysis', 'in-depth'
|
| 134 |
]
|
| 135 |
|
| 136 |
-
# Report indicators
|
| 137 |
REPORT_KEYWORDS = [
|
| 138 |
'report', 'summary', 'findings', 'document',
|
| 139 |
'write up', 'present', 'deliverable', 'brief'
|
| 140 |
]
|
| 141 |
|
| 142 |
-
# Citation configuration
|
| 143 |
REQUIRE_CITATIONS_FOR_RESEARCH = True
|
| 144 |
MIN_SOURCES_PER_RESEARCH = 3
|
| 145 |
MAX_SOURCES_PER_RESEARCH = 10
|
| 146 |
-
CITATION_FORMAT = "APA"
|
| 147 |
|
| 148 |
-
# Web search settings
|
| 149 |
WEB_SEARCH_ENABLED = True
|
| 150 |
-
WEB_SEARCH_API = "brave"
|
| 151 |
WEB_SEARCH_MAX_RESULTS = 10
|
| 152 |
WEB_SEARCH_TIMEOUT = 30 # seconds
|
| 153 |
|
|
@@ -156,13 +147,11 @@ WEB_SEARCH_TIMEOUT = 30 # seconds
|
|
| 156 |
# ARTIFACT TYPE CONFIGURATION
|
| 157 |
# ============================================================================
|
| 158 |
|
| 159 |
-
# Known artifact types
|
| 160 |
KNOWN_ARTIFACT_TYPES = {
|
| 161 |
"notebook", "script", "repo", "word",
|
| 162 |
"excel", "pdf", "image", "data"
|
| 163 |
}
|
| 164 |
|
| 165 |
-
# Artifact type detection keywords
|
| 166 |
ARTIFACT_TYPE_KEYWORDS = {
|
| 167 |
'notebook': ['notebook', 'jupyter', 'ipynb', 'visualization', 'chart', 'graph'],
|
| 168 |
'script': ['script', 'function', 'utility', 'tool'],
|
|
@@ -172,10 +161,7 @@ ARTIFACT_TYPE_KEYWORDS = {
|
|
| 172 |
'pdf': ['pdf', 'printable']
|
| 173 |
}
|
| 174 |
|
| 175 |
-
# Default artifact type for coding
|
| 176 |
DEFAULT_CODE_ARTIFACT = "script"
|
| 177 |
-
|
| 178 |
-
# Default artifact type for research
|
| 179 |
DEFAULT_RESEARCH_ARTIFACT = "word"
|
| 180 |
|
| 181 |
|
|
@@ -183,19 +169,16 @@ DEFAULT_RESEARCH_ARTIFACT = "word"
|
|
| 183 |
# FILE & ARTIFACT MANAGEMENT
|
| 184 |
# ============================================================================
|
| 185 |
|
| 186 |
-
# Directories
|
| 187 |
OUT_DIR = os.environ.get("OUT_DIR", "/tmp")
|
| 188 |
EXPORTS_DIR = os.path.join(OUT_DIR, "exports")
|
| 189 |
USER_ARTIFACTS_DIR = "outputs/user_artifacts"
|
| 190 |
FEEDBACK_STORAGE_DIR = "outputs/feedback"
|
| 191 |
|
| 192 |
-
# Artifact registry
|
| 193 |
ARTIFACT_REGISTRY_FILE = "outputs/artifact_registry.json"
|
| 194 |
ENSURE_ALL_ARTIFACTS_EXPORTED = True
|
| 195 |
ARTIFACT_RETENTION_DAYS = 30
|
| 196 |
MAX_ARTIFACT_SIZE_MB = 100
|
| 197 |
|
| 198 |
-
# File naming
|
| 199 |
UUID_LENGTH = 8
|
| 200 |
FILENAME_SEPARATOR = "_"
|
| 201 |
TIMESTAMP_FORMAT = "%Y%m%d_%H%M%S"
|
|
@@ -205,16 +188,12 @@ TIMESTAMP_FORMAT = "%Y%m%d_%H%M%S"
|
|
| 205 |
# CONVERSATION CONTEXT MANAGEMENT
|
| 206 |
# ============================================================================
|
| 207 |
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
CONTEXT_TOKEN_LIMIT = 4000 # Max tokens for context
|
| 211 |
INCLUDE_ARTIFACTS_IN_CONTEXT = True
|
| 212 |
-
|
| 213 |
-
# Context summarization
|
| 214 |
AUTO_SUMMARIZE_LONG_CONVERSATIONS = True
|
| 215 |
SUMMARIZE_AFTER_EXCHANGES = 5
|
| 216 |
|
| 217 |
-
# Follow-up detection keywords
|
| 218 |
FOLLOW_UP_KEYWORDS = [
|
| 219 |
'also', 'additionally', 'now', 'then', 'next',
|
| 220 |
'can you', 'please', 'what about', 'how about',
|
|
@@ -222,10 +201,8 @@ FOLLOW_UP_KEYWORDS = [
|
|
| 222 |
'update', 'improve', 'enhance', 'refine'
|
| 223 |
]
|
| 224 |
|
| 225 |
-
# Reference pronouns (indicate follow-up)
|
| 226 |
REFERENCE_PRONOUNS = ['it', 'that', 'this', 'they', 'them', 'those', 'these']
|
| 227 |
|
| 228 |
-
# Context indicator messages
|
| 229 |
SHOW_CONTEXT_INDICATOR = True
|
| 230 |
CONTEXT_INDICATOR_NEW = "📊 **New conversation**"
|
| 231 |
CONTEXT_INDICATOR_FOLLOW_UP = "🔄 Follow-up detected"
|
|
@@ -272,7 +249,6 @@ EXECUTION_MODES = {
|
|
| 272 |
# NODE STATUS MESSAGES
|
| 273 |
# ============================================================================
|
| 274 |
|
| 275 |
-
# Node status templates
|
| 276 |
NODE_STATUS = {
|
| 277 |
"memory": "Retrieving context...",
|
| 278 |
"intent": "Clarifying objective...",
|
|
@@ -286,7 +262,6 @@ NODE_STATUS = {
|
|
| 286 |
"archive": "Saving to memory..."
|
| 287 |
}
|
| 288 |
|
| 289 |
-
# Completion messages
|
| 290 |
COMPLETION_SUCCESS = "✅ Task completed successfully"
|
| 291 |
COMPLETION_WITH_WARNING = "⚠️ Task completed with limitations"
|
| 292 |
COMPLETION_FAILED = "❌ Task could not be completed"
|
|
@@ -296,14 +271,12 @@ COMPLETION_FAILED = "❌ Task could not be completed"
|
|
| 296 |
# ERROR HANDLING
|
| 297 |
# ============================================================================
|
| 298 |
|
| 299 |
-
# Error messages
|
| 300 |
ERROR_NO_LLM = "LLM not available"
|
| 301 |
ERROR_TIMEOUT = "Operation timed out"
|
| 302 |
ERROR_BUDGET_EXCEEDED = "Budget limit exceeded"
|
| 303 |
ERROR_PARSE_FAILED = "Failed to parse LLM response"
|
| 304 |
ERROR_ARTIFACT_CREATION = "Failed to create artifact"
|
| 305 |
|
| 306 |
-
# Retry settings
|
| 307 |
MAX_RETRIES = 3
|
| 308 |
RETRY_DELAY_SECONDS = 2
|
| 309 |
EXPONENTIAL_BACKOFF = True
|
|
@@ -313,18 +286,14 @@ EXPONENTIAL_BACKOFF = True
|
|
| 313 |
# LOGGING CONFIGURATION
|
| 314 |
# ============================================================================
|
| 315 |
|
| 316 |
-
# Log levels by tier
|
| 317 |
TIER_LOG_LEVELS = {
|
| 318 |
TIER_LITE: "WARNING",
|
| 319 |
TIER_STANDARD: "INFO",
|
| 320 |
TIER_FULL: "DEBUG"
|
| 321 |
}
|
| 322 |
|
| 323 |
-
# Log separators
|
| 324 |
LOG_SEPARATOR = "=" * 60
|
| 325 |
LOG_SEPARATOR_SHORT = "-" * 40
|
| 326 |
-
|
| 327 |
-
# Performance logging
|
| 328 |
LOG_PERFORMANCE_METRICS = True
|
| 329 |
LOG_TOKEN_USAGE = True
|
| 330 |
LOG_COST_TRACKING = True
|
|
@@ -340,78 +309,56 @@ def get_tier_config(tier: str) -> Dict[str, Any]:
|
|
| 340 |
|
| 341 |
|
| 342 |
def calculate_cost_per_call(tokens: int = None) -> float:
|
| 343 |
-
"""Calculate cost for an LLM call."""
|
| 344 |
tokens = tokens or AVG_TOKENS_PER_CALL
|
| 345 |
avg_cost_per_1k = (GPT4O_INPUT_COST_PER_1K_TOKENS + GPT4O_OUTPUT_COST_PER_1K_TOKENS) / 2.0
|
| 346 |
return (tokens / 1000.0) * avg_cost_per_1k
|
| 347 |
|
| 348 |
|
| 349 |
def is_tier_unlimited(tier: str) -> bool:
|
| 350 |
-
"""Check if tier has unlimited budget."""
|
| 351 |
config = get_tier_config(tier)
|
| 352 |
return config["max_cost"] is None
|
| 353 |
|
| 354 |
|
| 355 |
def get_max_rework_cycles(tier: str) -> int:
|
| 356 |
-
"""Get max rework cycles for tier."""
|
| 357 |
config = get_tier_config(tier)
|
| 358 |
return config["qa_rework_cycles"]
|
| 359 |
|
| 360 |
|
| 361 |
def should_include_monitoring(tier: str) -> bool:
|
| 362 |
-
"""Check if tier includes performance monitoring."""
|
| 363 |
config = get_tier_config(tier)
|
| 364 |
return config["includes_monitoring"]
|
| 365 |
|
| 366 |
|
| 367 |
def validate_tier(tier: str) -> str:
|
| 368 |
-
"""Validate and normalize tier name."""
|
| 369 |
tier_lower = tier.lower() if tier else DEFAULT_TIER
|
| 370 |
if tier_lower not in TIER_CONFIGS:
|
| 371 |
return DEFAULT_TIER
|
| 372 |
return tier_lower
|
| 373 |
|
| 374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
# ============================================================================
|
| 376 |
# EXPORTS
|
| 377 |
# ============================================================================
|
| 378 |
|
| 379 |
__all__ = [
|
| 380 |
-
|
| 381 |
-
'
|
| 382 |
-
'
|
| 383 |
-
'
|
| 384 |
-
'
|
| 385 |
-
'
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
'
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
# Language & coding
|
| 392 |
-
'DEFAULT_LANGUAGE',
|
| 393 |
-
'SUPPORTED_LANGUAGES',
|
| 394 |
-
'NO_CODE_KEYWORDS',
|
| 395 |
-
'CODE_KEYWORDS',
|
| 396 |
-
|
| 397 |
-
# Research mode
|
| 398 |
-
'RESEARCH_KEYWORDS',
|
| 399 |
-
'REQUIRE_CITATIONS_FOR_RESEARCH',
|
| 400 |
-
'WEB_SEARCH_ENABLED',
|
| 401 |
-
|
| 402 |
-
# Artifacts
|
| 403 |
-
'KNOWN_ARTIFACT_TYPES',
|
| 404 |
-
'USER_ARTIFACTS_DIR',
|
| 405 |
-
|
| 406 |
-
# Context management
|
| 407 |
-
'MAX_CONVERSATION_HISTORY',
|
| 408 |
-
'FOLLOW_UP_KEYWORDS',
|
| 409 |
-
|
| 410 |
-
# Helper functions
|
| 411 |
-
'get_tier_config',
|
| 412 |
-
'calculate_cost_per_call',
|
| 413 |
-
'is_tier_unlimited',
|
| 414 |
-
'get_max_rework_cycles',
|
| 415 |
-
'should_include_monitoring',
|
| 416 |
-
'validate_tier',
|
| 417 |
-
]
|
|
|
|
| 7 |
|
| 8 |
Author: AI Lab Team
|
| 9 |
Last Updated: 2025-10-10
|
| 10 |
+
Version: 3.1 - Added legacy compatibility constants
|
| 11 |
"""
|
| 12 |
|
| 13 |
import os
|
|
|
|
| 78 |
GPT4O_OUTPUT_COST_PER_1K_TOKENS = 0.015
|
| 79 |
AVG_TOKENS_PER_CALL = 2000
|
| 80 |
|
| 81 |
+
# Budget multipliers (legacy compatibility)
|
| 82 |
+
BUDGET_BUFFER_MULTIPLIER = 1.20
|
| 83 |
+
MAX_COST_MULTIPLIER = 1.20
|
| 84 |
|
| 85 |
|
| 86 |
# ============================================================================
|
| 87 |
# LANGUAGE & CODING CONFIGURATION
|
| 88 |
# ============================================================================
|
| 89 |
|
|
|
|
| 90 |
DEFAULT_LANGUAGE = "python"
|
| 91 |
|
|
|
|
| 92 |
SUPPORTED_LANGUAGES = [
|
| 93 |
"python", "javascript", "typescript", "java",
|
| 94 |
"go", "rust", "cpp", "csharp", "php", "ruby"
|
| 95 |
]
|
| 96 |
|
|
|
|
| 97 |
LANGUAGE_PREFERENCE_KEYWORDS = {
|
| 98 |
"python": ["python", "py", "prefer python", "use python"],
|
| 99 |
"javascript": ["javascript", "js", "node", "prefer javascript"],
|
|
|
|
| 103 |
"rust": ["rust", "prefer rust"]
|
| 104 |
}
|
| 105 |
|
|
|
|
| 106 |
NO_CODE_KEYWORDS = [
|
| 107 |
'what is', 'what are', 'explain', 'describe',
|
| 108 |
'summarize', 'list', 'tell me about',
|
| 109 |
'definition of', 'meaning of', 'overview of'
|
| 110 |
]
|
| 111 |
|
|
|
|
| 112 |
CODE_KEYWORDS = [
|
| 113 |
'script', 'function', 'api', 'backend', 'frontend',
|
| 114 |
'algorithm', 'program', 'code', 'implement',
|
|
|
|
| 120 |
# RESEARCH MODE CONFIGURATION
|
| 121 |
# ============================================================================
|
| 122 |
|
|
|
|
| 123 |
RESEARCH_KEYWORDS = [
|
| 124 |
'research', 'analyze', 'study', 'investigate', 'explore',
|
| 125 |
'survey', 'review', 'compare', 'evaluate', 'assess',
|
|
|
|
| 127 |
'comprehensive', 'detailed analysis', 'in-depth'
|
| 128 |
]
|
| 129 |
|
|
|
|
| 130 |
REPORT_KEYWORDS = [
|
| 131 |
'report', 'summary', 'findings', 'document',
|
| 132 |
'write up', 'present', 'deliverable', 'brief'
|
| 133 |
]
|
| 134 |
|
|
|
|
| 135 |
REQUIRE_CITATIONS_FOR_RESEARCH = True
|
| 136 |
MIN_SOURCES_PER_RESEARCH = 3
|
| 137 |
MAX_SOURCES_PER_RESEARCH = 10
|
| 138 |
+
CITATION_FORMAT = "APA"
|
| 139 |
|
|
|
|
| 140 |
WEB_SEARCH_ENABLED = True
|
| 141 |
+
WEB_SEARCH_API = "brave"
|
| 142 |
WEB_SEARCH_MAX_RESULTS = 10
|
| 143 |
WEB_SEARCH_TIMEOUT = 30 # seconds
|
| 144 |
|
|
|
|
| 147 |
# ARTIFACT TYPE CONFIGURATION
|
| 148 |
# ============================================================================
|
| 149 |
|
|
|
|
| 150 |
KNOWN_ARTIFACT_TYPES = {
|
| 151 |
"notebook", "script", "repo", "word",
|
| 152 |
"excel", "pdf", "image", "data"
|
| 153 |
}
|
| 154 |
|
|
|
|
| 155 |
ARTIFACT_TYPE_KEYWORDS = {
|
| 156 |
'notebook': ['notebook', 'jupyter', 'ipynb', 'visualization', 'chart', 'graph'],
|
| 157 |
'script': ['script', 'function', 'utility', 'tool'],
|
|
|
|
| 161 |
'pdf': ['pdf', 'printable']
|
| 162 |
}
|
| 163 |
|
|
|
|
| 164 |
DEFAULT_CODE_ARTIFACT = "script"
|
|
|
|
|
|
|
| 165 |
DEFAULT_RESEARCH_ARTIFACT = "word"
|
| 166 |
|
| 167 |
|
|
|
|
| 169 |
# FILE & ARTIFACT MANAGEMENT
|
| 170 |
# ============================================================================
|
| 171 |
|
|
|
|
| 172 |
OUT_DIR = os.environ.get("OUT_DIR", "/tmp")
|
| 173 |
EXPORTS_DIR = os.path.join(OUT_DIR, "exports")
|
| 174 |
USER_ARTIFACTS_DIR = "outputs/user_artifacts"
|
| 175 |
FEEDBACK_STORAGE_DIR = "outputs/feedback"
|
| 176 |
|
|
|
|
| 177 |
ARTIFACT_REGISTRY_FILE = "outputs/artifact_registry.json"
|
| 178 |
ENSURE_ALL_ARTIFACTS_EXPORTED = True
|
| 179 |
ARTIFACT_RETENTION_DAYS = 30
|
| 180 |
MAX_ARTIFACT_SIZE_MB = 100
|
| 181 |
|
|
|
|
| 182 |
UUID_LENGTH = 8
|
| 183 |
FILENAME_SEPARATOR = "_"
|
| 184 |
TIMESTAMP_FORMAT = "%Y%m%d_%H%M%S"
|
|
|
|
| 188 |
# CONVERSATION CONTEXT MANAGEMENT
|
| 189 |
# ============================================================================
|
| 190 |
|
| 191 |
+
MAX_CONVERSATION_HISTORY = 10
|
| 192 |
+
CONTEXT_TOKEN_LIMIT = 4000
|
|
|
|
| 193 |
INCLUDE_ARTIFACTS_IN_CONTEXT = True
|
|
|
|
|
|
|
| 194 |
AUTO_SUMMARIZE_LONG_CONVERSATIONS = True
|
| 195 |
SUMMARIZE_AFTER_EXCHANGES = 5
|
| 196 |
|
|
|
|
| 197 |
FOLLOW_UP_KEYWORDS = [
|
| 198 |
'also', 'additionally', 'now', 'then', 'next',
|
| 199 |
'can you', 'please', 'what about', 'how about',
|
|
|
|
| 201 |
'update', 'improve', 'enhance', 'refine'
|
| 202 |
]
|
| 203 |
|
|
|
|
| 204 |
REFERENCE_PRONOUNS = ['it', 'that', 'this', 'they', 'them', 'those', 'these']
|
| 205 |
|
|
|
|
| 206 |
SHOW_CONTEXT_INDICATOR = True
|
| 207 |
CONTEXT_INDICATOR_NEW = "📊 **New conversation**"
|
| 208 |
CONTEXT_INDICATOR_FOLLOW_UP = "🔄 Follow-up detected"
|
|
|
|
| 249 |
# NODE STATUS MESSAGES
|
| 250 |
# ============================================================================
|
| 251 |
|
|
|
|
| 252 |
NODE_STATUS = {
|
| 253 |
"memory": "Retrieving context...",
|
| 254 |
"intent": "Clarifying objective...",
|
|
|
|
| 262 |
"archive": "Saving to memory..."
|
| 263 |
}
|
| 264 |
|
|
|
|
| 265 |
COMPLETION_SUCCESS = "✅ Task completed successfully"
|
| 266 |
COMPLETION_WITH_WARNING = "⚠️ Task completed with limitations"
|
| 267 |
COMPLETION_FAILED = "❌ Task could not be completed"
|
|
|
|
| 271 |
# ERROR HANDLING
|
| 272 |
# ============================================================================
|
| 273 |
|
|
|
|
| 274 |
ERROR_NO_LLM = "LLM not available"
|
| 275 |
ERROR_TIMEOUT = "Operation timed out"
|
| 276 |
ERROR_BUDGET_EXCEEDED = "Budget limit exceeded"
|
| 277 |
ERROR_PARSE_FAILED = "Failed to parse LLM response"
|
| 278 |
ERROR_ARTIFACT_CREATION = "Failed to create artifact"
|
| 279 |
|
|
|
|
| 280 |
MAX_RETRIES = 3
|
| 281 |
RETRY_DELAY_SECONDS = 2
|
| 282 |
EXPONENTIAL_BACKOFF = True
|
|
|
|
| 286 |
# LOGGING CONFIGURATION
|
| 287 |
# ============================================================================
|
| 288 |
|
|
|
|
| 289 |
TIER_LOG_LEVELS = {
|
| 290 |
TIER_LITE: "WARNING",
|
| 291 |
TIER_STANDARD: "INFO",
|
| 292 |
TIER_FULL: "DEBUG"
|
| 293 |
}
|
| 294 |
|
|
|
|
| 295 |
LOG_SEPARATOR = "=" * 60
|
| 296 |
LOG_SEPARATOR_SHORT = "-" * 40
|
|
|
|
|
|
|
| 297 |
LOG_PERFORMANCE_METRICS = True
|
| 298 |
LOG_TOKEN_USAGE = True
|
| 299 |
LOG_COST_TRACKING = True
|
|
|
|
| 309 |
|
| 310 |
|
| 311 |
def calculate_cost_per_call(tokens: int = None) -> float:
|
|
|
|
| 312 |
tokens = tokens or AVG_TOKENS_PER_CALL
|
| 313 |
avg_cost_per_1k = (GPT4O_INPUT_COST_PER_1K_TOKENS + GPT4O_OUTPUT_COST_PER_1K_TOKENS) / 2.0
|
| 314 |
return (tokens / 1000.0) * avg_cost_per_1k
|
| 315 |
|
| 316 |
|
| 317 |
def is_tier_unlimited(tier: str) -> bool:
|
|
|
|
| 318 |
config = get_tier_config(tier)
|
| 319 |
return config["max_cost"] is None
|
| 320 |
|
| 321 |
|
| 322 |
def get_max_rework_cycles(tier: str) -> int:
|
|
|
|
| 323 |
config = get_tier_config(tier)
|
| 324 |
return config["qa_rework_cycles"]
|
| 325 |
|
| 326 |
|
| 327 |
def should_include_monitoring(tier: str) -> bool:
|
|
|
|
| 328 |
config = get_tier_config(tier)
|
| 329 |
return config["includes_monitoring"]
|
| 330 |
|
| 331 |
|
| 332 |
def validate_tier(tier: str) -> str:
|
|
|
|
| 333 |
tier_lower = tier.lower() if tier else DEFAULT_TIER
|
| 334 |
if tier_lower not in TIER_CONFIGS:
|
| 335 |
return DEFAULT_TIER
|
| 336 |
return tier_lower
|
| 337 |
|
| 338 |
|
| 339 |
+
# ============================================================================
|
| 340 |
+
# LEGACY COMPATIBILITY CONSTANTS (to prevent AttributeError)
|
| 341 |
+
# ============================================================================
|
| 342 |
+
|
| 343 |
+
# Maintain backward compatibility with older modules (e.g., app_gradio.py)
|
| 344 |
+
INITIAL_MAX_REWORK_CYCLES = get_max_rework_cycles(DEFAULT_TIER)
|
| 345 |
+
# Explicitly re-export legacy cost multipliers for older modules
|
| 346 |
+
LEGACY_BUDGET_BUFFER_MULTIPLIER = BUDGET_BUFFER_MULTIPLIER
|
| 347 |
+
LEGACY_MAX_COST_MULTIPLIER = MAX_COST_MULTIPLIER
|
| 348 |
+
|
| 349 |
+
|
| 350 |
# ============================================================================
|
| 351 |
# EXPORTS
|
| 352 |
# ============================================================================
|
| 353 |
|
| 354 |
__all__ = [
|
| 355 |
+
'TIER_LITE', 'TIER_STANDARD', 'TIER_FULL', 'TIER_CONFIGS', 'DEFAULT_TIER',
|
| 356 |
+
'MAX_EXECUTION_PATH_LENGTH', 'NODE_TIMEOUT_SECONDS',
|
| 357 |
+
'DEFAULT_LANGUAGE', 'SUPPORTED_LANGUAGES', 'NO_CODE_KEYWORDS', 'CODE_KEYWORDS',
|
| 358 |
+
'RESEARCH_KEYWORDS', 'REQUIRE_CITATIONS_FOR_RESEARCH', 'WEB_SEARCH_ENABLED',
|
| 359 |
+
'KNOWN_ARTIFACT_TYPES', 'USER_ARTIFACTS_DIR', 'MAX_CONVERSATION_HISTORY',
|
| 360 |
+
'FOLLOW_UP_KEYWORDS', 'get_tier_config', 'calculate_cost_per_call',
|
| 361 |
+
'is_tier_unlimited', 'get_max_rework_cycles', 'should_include_monitoring',
|
| 362 |
+
'validate_tier', 'INITIAL_MAX_REWORK_CYCLES',
|
| 363 |
+
'LEGACY_BUDGET_BUFFER_MULTIPLIER', 'LEGACY_MAX_COST_MULTIPLIER'
|
| 364 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|