mirror of
https://github.com/thecyberlearn/quantum-ai-v2.git
synced 2026-08-18 19:32:59 +00:00
Fix agent network errors and remove debug logging
- Fix social ads generator updateWalletBalance function call - Fix weather reporter form submission URL and syntax errors - Add missing status endpoints for polling functionality - Remove debug logging from all agents - Clean up button styling consistency 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
bfbb7d3515
commit
f40450851b
@ -51,6 +51,7 @@ Please create platform-optimized ad copy that:
|
|||||||
request_obj.status = 'processing'
|
request_obj.status = 'processing'
|
||||||
request_obj.save()
|
request_obj.save()
|
||||||
|
|
||||||
|
|
||||||
# Handle array response from N8N (extract first item)
|
# Handle array response from N8N (extract first item)
|
||||||
if isinstance(response_data, list) and len(response_data) > 0:
|
if isinstance(response_data, list) and len(response_data) > 0:
|
||||||
response_data = response_data[0]
|
response_data = response_data[0]
|
||||||
|
|||||||
@ -102,7 +102,7 @@
|
|||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
<button onclick="copySocialAds()" class="btn btn-primary">📋 Copy Ads</button>
|
<button onclick="copySocialAds()" class="btn btn-primary">📋 Copy Ads</button>
|
||||||
<button onclick="downloadSocialAds()" class="btn btn-secondary">💾 Download Ads</button>
|
<button onclick="downloadSocialAds()" class="btn btn-secondary">💾 Download Ads</button>
|
||||||
<button onclick="resetForm()" class="btn" style="background: rgba(236, 72, 153, 1); color: white;">🔄 Create Another</button>
|
<button onclick="resetForm()" class="btn btn-secondary">🔄 Create Another</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -201,6 +201,7 @@
|
|||||||
|
|
||||||
// Display social ads results with engaging ad copy formatting
|
// Display social ads results with engaging ad copy formatting
|
||||||
function displayResults(result) {
|
function displayResults(result) {
|
||||||
|
|
||||||
const resultsContainer = document.getElementById('adResults');
|
const resultsContainer = document.getElementById('adResults');
|
||||||
const contentElement = document.getElementById('adContent');
|
const contentElement = document.getElementById('adContent');
|
||||||
|
|
||||||
@ -211,7 +212,7 @@
|
|||||||
|
|
||||||
// Update wallet balance if provided
|
// Update wallet balance if provided
|
||||||
if (result.wallet_balance !== undefined) {
|
if (result.wallet_balance !== undefined) {
|
||||||
updateWalletBalance(result.wallet_balance);
|
AgentUtils.updateWalletBalance(result.wallet_balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle errors
|
// Handle errors
|
||||||
|
|||||||
@ -138,19 +138,25 @@ def social_ads_generator_status(request, request_id):
|
|||||||
# Refresh user to get current wallet balance
|
# Refresh user to get current wallet balance
|
||||||
request.user.refresh_from_db()
|
request.user.refresh_from_db()
|
||||||
|
|
||||||
return JsonResponse({
|
ad_copy = getattr(response, 'ad_copy', None)
|
||||||
|
raw_response = getattr(response, 'raw_response', None)
|
||||||
|
|
||||||
|
|
||||||
|
json_response = {
|
||||||
'success': response.success,
|
'success': response.success,
|
||||||
'status': agent_request.status,
|
'status': agent_request.status,
|
||||||
'content': getattr(response, 'ad_copy', None),
|
'content': ad_copy,
|
||||||
'ad_copy_content': getattr(response, 'ad_copy', None),
|
'ad_copy_content': ad_copy,
|
||||||
'hashtags': getattr(response, 'hashtags', None),
|
'hashtags': getattr(response, 'hashtags', None),
|
||||||
'targeting_suggestions': getattr(response, 'targeting_suggestions', None),
|
'targeting_suggestions': getattr(response, 'targeting_suggestions', None),
|
||||||
'formatted_ad': getattr(response, 'formatted_ad', None),
|
'formatted_ad': getattr(response, 'formatted_ad', None),
|
||||||
'raw_response': getattr(response, 'raw_response', None),
|
'raw_response': raw_response,
|
||||||
'processing_time': float(response.processing_time) if response.processing_time else None,
|
'processing_time': float(response.processing_time) if response.processing_time else None,
|
||||||
'error_message': response.error_message,
|
'error_message': response.error_message,
|
||||||
'wallet_balance': float(request.user.wallet_balance)
|
'wallet_balance': float(request.user.wallet_balance)
|
||||||
})
|
}
|
||||||
|
|
||||||
|
return JsonResponse(json_response)
|
||||||
else:
|
else:
|
||||||
return JsonResponse({
|
return JsonResponse({
|
||||||
'success': False,
|
'success': False,
|
||||||
|
|||||||
@ -271,7 +271,7 @@
|
|||||||
|
|
||||||
// Update wallet balance if provided
|
// Update wallet balance if provided
|
||||||
if (result.wallet_balance !== undefined) {
|
if (result.wallet_balance !== undefined) {
|
||||||
updateWalletBalance(result.wallet_balance);
|
AgentUtils.updateWalletBalance(result.wallet_balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle errors
|
// Handle errors
|
||||||
@ -481,7 +481,7 @@
|
|||||||
// Submit form via AJAX
|
// Submit form via AJAX
|
||||||
const formData = new FormData(this);
|
const formData = new FormData(this);
|
||||||
|
|
||||||
fetch(window.location.href, {
|
fetch('/agents/weather-reporter/process/', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -6,5 +6,6 @@ app_name = 'weather_reporter'
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.weather_reporter_detail, name='detail'),
|
path('', views.weather_reporter_detail, name='detail'),
|
||||||
path('process/', views.WeatherReporterProcessView.as_view(), name='process'),
|
path('process/', views.WeatherReporterProcessView.as_view(), name='process'),
|
||||||
|
path('status/<uuid:request_id>/', views.weather_reporter_status, name='status'),
|
||||||
path('result/<uuid:request_id>/', views.weather_reporter_result, name='result'),
|
path('result/<uuid:request_id>/', views.weather_reporter_result, name='result'),
|
||||||
]
|
]
|
||||||
@ -57,8 +57,7 @@ class WeatherReporterProcessView(View):
|
|||||||
agent=agent,
|
agent=agent,
|
||||||
cost=agent.price,
|
cost=agent.price,
|
||||||
location=data.get('location', ''),
|
location=data.get('location', ''),
|
||||||
report_type=data.get('report_type', 'current'),
|
report_type=data.get('report_type', 'current')
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Process request immediately (API-based agent)
|
# Process request immediately (API-based agent)
|
||||||
@ -143,3 +142,45 @@ def weather_reporter_result(request, request_id):
|
|||||||
return JsonResponse({'error': 'Request not found'}, status=404)
|
return JsonResponse({'error': 'Request not found'}, status=404)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return JsonResponse({'error': str(e)}, status=500)
|
return JsonResponse({'error': str(e)}, status=500)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def weather_reporter_status(request, request_id):
|
||||||
|
"""Get status for a specific request (for polling)"""
|
||||||
|
try:
|
||||||
|
agent_request = WeatherReporterRequest.objects.get(
|
||||||
|
id=request_id,
|
||||||
|
user=request.user
|
||||||
|
)
|
||||||
|
|
||||||
|
if hasattr(agent_request, 'response'):
|
||||||
|
response = agent_request.response
|
||||||
|
# Refresh user to get current wallet balance
|
||||||
|
request.user.refresh_from_db()
|
||||||
|
|
||||||
|
return JsonResponse({
|
||||||
|
'success': response.success,
|
||||||
|
'status': agent_request.status,
|
||||||
|
'content': getattr(response, 'weather_data', None),
|
||||||
|
'weather_data': getattr(response, 'weather_data', None),
|
||||||
|
'temperature': getattr(response, 'temperature', None),
|
||||||
|
'description': getattr(response, 'description', None),
|
||||||
|
'humidity': getattr(response, 'humidity', None),
|
||||||
|
'wind_speed': getattr(response, 'wind_speed', None),
|
||||||
|
'formatted_report': getattr(response, 'formatted_report', None),
|
||||||
|
'raw_response': getattr(response, 'raw_response', None),
|
||||||
|
'processing_time': float(response.processing_time) if response.processing_time else None,
|
||||||
|
'error_message': response.error_message,
|
||||||
|
'wallet_balance': float(request.user.wallet_balance)
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
return JsonResponse({
|
||||||
|
'success': False,
|
||||||
|
'status': agent_request.status,
|
||||||
|
'message': 'Processing in progress...'
|
||||||
|
})
|
||||||
|
|
||||||
|
except WeatherReporterRequest.DoesNotExist:
|
||||||
|
return JsonResponse({'error': 'Request not found'}, status=404)
|
||||||
|
except Exception as e:
|
||||||
|
return JsonResponse({'error': str(e)}, status=500)
|
||||||
Loading…
Reference in New Issue
Block a user