1
This commit is contained in:
@@ -158,6 +158,15 @@ class AICore:
|
|||||||
# Step 2: Determine model
|
# Step 2: Determine model
|
||||||
active_model = model or self._default_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
|
# Validate model is available and supported
|
||||||
if not active_model:
|
if not active_model:
|
||||||
error_msg = 'No AI model configured. Please configure a model in Integration Settings or Django settings.'
|
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_config = get_model_config(function_name, account=self.account)
|
||||||
model = model_config.get('model')
|
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"Calling {model or 'default'} model with {len(prompt)} char prompt")
|
||||||
self.console_tracker.ai_call(f"Function ID: {function_id}")
|
self.console_tracker.ai_call(f"Function ID: {function_id}")
|
||||||
|
|
||||||
|
|||||||
@@ -232,7 +232,8 @@ export function useProgressModal(): UseProgressModalReturn {
|
|||||||
`/v1/system/settings/task_progress/${taskId}/`
|
`/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 = () => {
|
const startAutoIncrement = () => {
|
||||||
// Clear any existing auto-increment interval
|
// Clear any existing auto-increment interval
|
||||||
if (autoIncrementIntervalRef.current) {
|
if (autoIncrementIntervalRef.current) {
|
||||||
@@ -240,8 +241,10 @@ export function useProgressModal(): UseProgressModalReturn {
|
|||||||
autoIncrementIntervalRef.current = null;
|
autoIncrementIntervalRef.current = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only start if we're below 80%
|
// Only start if we're below 80% and status is processing
|
||||||
if (displayedPercentageRef.current < 80) {
|
const current = displayedPercentageRef.current;
|
||||||
|
if (current < 80) {
|
||||||
|
// Use a slightly longer interval to avoid conflicts with backend updates
|
||||||
autoIncrementIntervalRef.current = setInterval(() => {
|
autoIncrementIntervalRef.current = setInterval(() => {
|
||||||
setProgress(prev => {
|
setProgress(prev => {
|
||||||
// Check current status - stop if not processing
|
// Check current status - stop if not processing
|
||||||
@@ -253,9 +256,10 @@ export function useProgressModal(): UseProgressModalReturn {
|
|||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
const current = displayedPercentageRef.current;
|
const currentPercent = displayedPercentageRef.current;
|
||||||
if (current < 80) {
|
// Only increment if still below 80%
|
||||||
const newPercentage = Math.min(current + 1, 80);
|
if (currentPercent < 80) {
|
||||||
|
const newPercentage = Math.min(currentPercent + 1, 80);
|
||||||
displayedPercentageRef.current = newPercentage;
|
displayedPercentageRef.current = newPercentage;
|
||||||
|
|
||||||
// Stop if we've reached 80%
|
// Stop if we've reached 80%
|
||||||
@@ -279,7 +283,7 @@ export function useProgressModal(): UseProgressModalReturn {
|
|||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 300);
|
}, 350); // Slightly longer interval to reduce conflicts
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -366,23 +370,35 @@ export function useProgressModal(): UseProgressModalReturn {
|
|||||||
const isNewStep = currentStepRef.current !== currentStep;
|
const isNewStep = currentStepRef.current !== currentStep;
|
||||||
const currentDisplayedPercentage = displayedPercentageRef.current;
|
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
|
// Clear any existing transition timeout or animation interval
|
||||||
if (stepTransitionTimeoutRef.current) {
|
if (stepTransitionTimeoutRef.current) {
|
||||||
clearTimeout(stepTransitionTimeoutRef.current);
|
clearTimeout(stepTransitionTimeoutRef.current);
|
||||||
stepTransitionTimeoutRef.current = null;
|
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
|
// Smooth progress animation: increment gradually until reaching target
|
||||||
// Use smaller increments and faster updates for smoother animation
|
// Use smaller increments and faster updates for smoother animation
|
||||||
if (targetPercentage > currentDisplayedPercentage) {
|
if (safeTargetPercentage > currentDisplayedPercentage) {
|
||||||
// Start smooth animation
|
// Start smooth animation
|
||||||
let animatedPercentage = currentDisplayedPercentage;
|
let animatedPercentage = currentDisplayedPercentage;
|
||||||
const animateProgress = () => {
|
const animateProgress = () => {
|
||||||
if (animatedPercentage < targetPercentage) {
|
if (animatedPercentage < safeTargetPercentage) {
|
||||||
// Calculate increment: smaller increments for smoother animation
|
// Calculate increment based on distance for smooth animation
|
||||||
const diff = targetPercentage - animatedPercentage;
|
const diff = safeTargetPercentage - animatedPercentage;
|
||||||
const increment = diff > 10 ? 2 : 1; // Larger jumps for big differences
|
// Use smaller increments for smoother feel
|
||||||
animatedPercentage = Math.min(animatedPercentage + increment, targetPercentage);
|
// 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;
|
displayedPercentageRef.current = animatedPercentage;
|
||||||
setProgress({
|
setProgress({
|
||||||
percentage: animatedPercentage,
|
percentage: animatedPercentage,
|
||||||
@@ -397,13 +413,15 @@ export function useProgressModal(): UseProgressModalReturn {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (animatedPercentage < targetPercentage) {
|
if (animatedPercentage < safeTargetPercentage) {
|
||||||
// Faster updates: 200ms for smoother feel
|
// Smooth updates: 150ms for better UX
|
||||||
stepTransitionTimeoutRef.current = setTimeout(animateProgress, 200);
|
stepTransitionTimeoutRef.current = setTimeout(animateProgress, 150);
|
||||||
} else {
|
} else {
|
||||||
stepTransitionTimeoutRef.current = null;
|
stepTransitionTimeoutRef.current = null;
|
||||||
// After reaching target, start auto-increment if below 80%
|
// After reaching target, start auto-increment if below 80% and no backend update pending
|
||||||
startAutoIncrement();
|
if (safeTargetPercentage < 80) {
|
||||||
|
startAutoIncrement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -413,32 +431,15 @@ export function useProgressModal(): UseProgressModalReturn {
|
|||||||
stepTransitionTimeoutRef.current = setTimeout(() => {
|
stepTransitionTimeoutRef.current = setTimeout(() => {
|
||||||
currentStepRef.current = currentStep;
|
currentStepRef.current = currentStep;
|
||||||
animateProgress();
|
animateProgress();
|
||||||
}, 300);
|
}, 200);
|
||||||
} else {
|
} else {
|
||||||
// Same step or first step - start animation immediately
|
// Same step or first step - start animation immediately
|
||||||
currentStepRef.current = currentStep;
|
currentStepRef.current = currentStep;
|
||||||
animateProgress();
|
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 {
|
} 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;
|
currentStepRef.current = currentStep;
|
||||||
setProgress(prev => ({
|
setProgress(prev => ({
|
||||||
...prev,
|
...prev,
|
||||||
@@ -451,8 +452,10 @@ export function useProgressModal(): UseProgressModalReturn {
|
|||||||
phase: meta.phase,
|
phase: meta.phase,
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
// Start auto-increment if below 80%
|
// Start auto-increment if below 80% and no backend update
|
||||||
startAutoIncrement();
|
if (currentDisplayedPercentage < 80 && safeTargetPercentage === currentDisplayedPercentage) {
|
||||||
|
startAutoIncrement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update step logs if available
|
// Update step logs if available
|
||||||
|
|||||||
Reference in New Issue
Block a user