Implement V2 AI functions and enhance progress handling

- Added support for new V2 functions: `auto_cluster_v2` and `generate_ideas_v2`, including backend logic and API endpoints.
- Updated model configuration to ensure V2 functions validate the presence of models before execution.
- Enhanced progress modal to provide better feedback during asynchronous tasks, including task IDs for debugging.
- Updated frontend components to integrate new V2 functionalities and improve user experience with clustering and idea generation.
This commit is contained in:
Desktop
2025-11-10 22:16:02 +05:00
parent 46f5bb4d62
commit e2f2d79d4c
12 changed files with 920 additions and 58 deletions

View File

@@ -82,10 +82,8 @@ class AIEngine:
ai_core = AICore(account=self.account)
function_name = fn.get_name()
# Generate function_id for tracking (ai-{function_name}-01)
# Normalize underscores to hyphens to match frontend tracking IDs
function_id_base = function_name.replace('_', '-')
function_id = f"ai-{function_id_base}-01-desktop"
# Generate function_id for tracking (ai_{function_name})
function_id = f"ai_{function_name}"
# Get model config from settings (Stage 4 requirement)
# Pass account to read model from IntegrationSettings
@@ -111,6 +109,18 @@ class AIEngine:
exc_info=True,
)
# For V2 functions: Validate model exists - no default, only execute if model is present
if function_name.endswith('_v2'):
if not model_from_integration or not model:
error_msg = "AI model not configured. Please configure OpenAI model in Integration settings."
self.console_tracker.error('ModelError', error_msg)
self.step_tracker.add_request_step("PREP", "error", error_msg)
self.tracker.error(error_msg, meta=self.step_tracker.get_meta())
return {
'success': False,
'error': error_msg
}
# Track configured model information so it shows in the progress modal
self.step_tracker.add_request_step(
"PREP",