1
This commit is contained in:
@@ -158,6 +158,15 @@ class AICore:
|
||||
# Step 2: Determine model
|
||||
active_model = model or self._default_model
|
||||
|
||||
# Debug logging: Show model from settings vs model used
|
||||
model_from_settings = self._default_model
|
||||
model_used = active_model
|
||||
logger.info(f"[AICore] Model Configuration Debug:")
|
||||
logger.info(f" - Model from IntegrationSettings: {model_from_settings}")
|
||||
logger.info(f" - Model parameter passed: {model}")
|
||||
logger.info(f" - Model actually used in request: {model_used}")
|
||||
tracker.ai_call(f"Model Debug - Settings: {model_from_settings}, Parameter: {model}, Using: {model_used}")
|
||||
|
||||
# Validate model is available and supported
|
||||
if not active_model:
|
||||
error_msg = 'No AI model configured. Please configure a model in Integration Settings or Django settings.'
|
||||
|
||||
@@ -92,6 +92,11 @@ class AIEngine:
|
||||
model_config = get_model_config(function_name, account=self.account)
|
||||
model = model_config.get('model')
|
||||
|
||||
# Debug logging: Show model configuration
|
||||
logger.info(f"[AIEngine] Model Configuration for {function_name}:")
|
||||
logger.info(f" - Model from get_model_config: {model}")
|
||||
logger.info(f" - Full model_config: {model_config}")
|
||||
self.console_tracker.ai_call(f"Model from settings: {model}")
|
||||
self.console_tracker.ai_call(f"Calling {model or 'default'} model with {len(prompt)} char prompt")
|
||||
self.console_tracker.ai_call(f"Function ID: {function_id}")
|
||||
|
||||
|
||||
@@ -232,7 +232,8 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
`/v1/system/settings/task_progress/${taskId}/`
|
||||
);
|
||||
|
||||
// Helper function to start auto-increment progress (1% every 300ms until 80%)
|
||||
// Helper function to start auto-increment progress (1% every 350ms until 80%)
|
||||
// Only runs when no backend updates are coming (smooth fill-in animation)
|
||||
const startAutoIncrement = () => {
|
||||
// Clear any existing auto-increment interval
|
||||
if (autoIncrementIntervalRef.current) {
|
||||
@@ -240,8 +241,10 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
autoIncrementIntervalRef.current = null;
|
||||
}
|
||||
|
||||
// Only start if we're below 80%
|
||||
if (displayedPercentageRef.current < 80) {
|
||||
// Only start if we're below 80% and status is processing
|
||||
const current = displayedPercentageRef.current;
|
||||
if (current < 80) {
|
||||
// Use a slightly longer interval to avoid conflicts with backend updates
|
||||
autoIncrementIntervalRef.current = setInterval(() => {
|
||||
setProgress(prev => {
|
||||
// Check current status - stop if not processing
|
||||
@@ -253,9 +256,10 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
return prev;
|
||||
}
|
||||
|
||||
const current = displayedPercentageRef.current;
|
||||
if (current < 80) {
|
||||
const newPercentage = Math.min(current + 1, 80);
|
||||
const currentPercent = displayedPercentageRef.current;
|
||||
// Only increment if still below 80%
|
||||
if (currentPercent < 80) {
|
||||
const newPercentage = Math.min(currentPercent + 1, 80);
|
||||
displayedPercentageRef.current = newPercentage;
|
||||
|
||||
// Stop if we've reached 80%
|
||||
@@ -279,7 +283,7 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
return prev;
|
||||
}
|
||||
});
|
||||
}, 300);
|
||||
}, 350); // Slightly longer interval to reduce conflicts
|
||||
}
|
||||
};
|
||||
|
||||
@@ -366,23 +370,35 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
const isNewStep = currentStepRef.current !== currentStep;
|
||||
const currentDisplayedPercentage = displayedPercentageRef.current;
|
||||
|
||||
// Stop auto-increment when backend sends an update (prevents conflicts)
|
||||
if (autoIncrementIntervalRef.current) {
|
||||
clearInterval(autoIncrementIntervalRef.current);
|
||||
autoIncrementIntervalRef.current = null;
|
||||
}
|
||||
|
||||
// Clear any existing transition timeout or animation interval
|
||||
if (stepTransitionTimeoutRef.current) {
|
||||
clearTimeout(stepTransitionTimeoutRef.current);
|
||||
stepTransitionTimeoutRef.current = null;
|
||||
}
|
||||
|
||||
// Improved progress logic: Only allow progress to increase, never decrease
|
||||
// This prevents jumping back and forth between percentages
|
||||
const safeTargetPercentage = Math.max(targetPercentage, currentDisplayedPercentage);
|
||||
|
||||
// Smooth progress animation: increment gradually until reaching target
|
||||
// Use smaller increments and faster updates for smoother animation
|
||||
if (targetPercentage > currentDisplayedPercentage) {
|
||||
if (safeTargetPercentage > currentDisplayedPercentage) {
|
||||
// Start smooth animation
|
||||
let animatedPercentage = currentDisplayedPercentage;
|
||||
const animateProgress = () => {
|
||||
if (animatedPercentage < targetPercentage) {
|
||||
// Calculate increment: smaller increments for smoother animation
|
||||
const diff = targetPercentage - animatedPercentage;
|
||||
const increment = diff > 10 ? 2 : 1; // Larger jumps for big differences
|
||||
animatedPercentage = Math.min(animatedPercentage + increment, targetPercentage);
|
||||
if (animatedPercentage < safeTargetPercentage) {
|
||||
// Calculate increment based on distance for smooth animation
|
||||
const diff = safeTargetPercentage - animatedPercentage;
|
||||
// Use smaller increments for smoother feel
|
||||
// If close (< 5%), increment by 1, otherwise by 2
|
||||
const increment = diff <= 5 ? 1 : Math.min(2, Math.ceil(diff / 10));
|
||||
animatedPercentage = Math.min(animatedPercentage + increment, safeTargetPercentage);
|
||||
displayedPercentageRef.current = animatedPercentage;
|
||||
setProgress({
|
||||
percentage: animatedPercentage,
|
||||
@@ -397,13 +413,15 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
},
|
||||
});
|
||||
|
||||
if (animatedPercentage < targetPercentage) {
|
||||
// Faster updates: 200ms for smoother feel
|
||||
stepTransitionTimeoutRef.current = setTimeout(animateProgress, 200);
|
||||
if (animatedPercentage < safeTargetPercentage) {
|
||||
// Smooth updates: 150ms for better UX
|
||||
stepTransitionTimeoutRef.current = setTimeout(animateProgress, 150);
|
||||
} else {
|
||||
stepTransitionTimeoutRef.current = null;
|
||||
// After reaching target, start auto-increment if below 80%
|
||||
startAutoIncrement();
|
||||
// After reaching target, start auto-increment if below 80% and no backend update pending
|
||||
if (safeTargetPercentage < 80) {
|
||||
startAutoIncrement();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -413,32 +431,15 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
stepTransitionTimeoutRef.current = setTimeout(() => {
|
||||
currentStepRef.current = currentStep;
|
||||
animateProgress();
|
||||
}, 300);
|
||||
}, 200);
|
||||
} else {
|
||||
// Same step or first step - start animation immediately
|
||||
currentStepRef.current = currentStep;
|
||||
animateProgress();
|
||||
}
|
||||
} else if (targetPercentage !== currentDisplayedPercentage) {
|
||||
// Percentage decreased or same - update immediately (shouldn't happen normally)
|
||||
currentStepRef.current = currentStep;
|
||||
displayedPercentageRef.current = targetPercentage;
|
||||
setProgress({
|
||||
percentage: targetPercentage,
|
||||
message: friendlyMessage,
|
||||
status: 'processing',
|
||||
details: {
|
||||
current: meta.current || 0,
|
||||
total: meta.total || 0,
|
||||
completed: meta.completed || 0,
|
||||
currentItem: meta.current_item,
|
||||
phase: meta.phase,
|
||||
},
|
||||
});
|
||||
// Start auto-increment if below 80%
|
||||
startAutoIncrement();
|
||||
} else {
|
||||
// Same percentage - just update message and details if needed
|
||||
// Target is same or less than current - just update message and details
|
||||
// Don't decrease percentage (prevents jumping back)
|
||||
currentStepRef.current = currentStep;
|
||||
setProgress(prev => ({
|
||||
...prev,
|
||||
@@ -451,8 +452,10 @@ export function useProgressModal(): UseProgressModalReturn {
|
||||
phase: meta.phase,
|
||||
},
|
||||
}));
|
||||
// Start auto-increment if below 80%
|
||||
startAutoIncrement();
|
||||
// Start auto-increment if below 80% and no backend update
|
||||
if (currentDisplayedPercentage < 80 && safeTargetPercentage === currentDisplayedPercentage) {
|
||||
startAutoIncrement();
|
||||
}
|
||||
}
|
||||
|
||||
// Update step logs if available
|
||||
|
||||
Reference in New Issue
Block a user