From 3473080babb746e9dc7334bbe82b23254b242435 Mon Sep 17 00:00:00 2001 From: harshalmore31 Date: Tue, 5 Aug 2025 03:54:17 +0530 Subject: [PATCH] updates ! --- docs/swarms_cloud/cloudflare_workers.md | 131 +++++------------------- 1 file changed, 27 insertions(+), 104 deletions(-) diff --git a/docs/swarms_cloud/cloudflare_workers.md b/docs/swarms_cloud/cloudflare_workers.md index 4d339da9..fde8c094 100644 --- a/docs/swarms_cloud/cloudflare_workers.md +++ b/docs/swarms_cloud/cloudflare_workers.md @@ -96,10 +96,10 @@ export default { const res = await fetch('/execute'); const data = await res.json(); document.getElementById('result').innerHTML = data.result?.success - ? \`✅ Success: \${data.result.analysis}\` - : \`❌ Error: \${data.error}\`; + ? '✅ Success: ' + data.result.analysis + : '❌ Error: ' + data.error; } catch (e) { - document.getElementById('result').innerHTML = \`❌ Failed: \${e.message}\`; + document.getElementById('result').innerHTML = '❌ Failed: ' + e.message; } } @@ -156,7 +156,7 @@ async function executeAnalysis(event, env) { throw new Error('Autonomous data collection failed - no valid market intelligence gathered'); } - console.log(\`✅ Autonomous data collection successful: \${validData.length} sources\`); + console.log('✅ Autonomous data collection successful: ' + validData.length + ' sources'); // Step 2: Deploy Swarms AI agents for autonomous analysis console.log('🧠 Deploying Swarms AI agents for autonomous intelligence generation...'); @@ -222,14 +222,14 @@ async function executeAnalysis(event, env) { if (!response.ok) { const errorText = await response.text(); - throw new Error(\`Swarms API autonomous execution failed: \${response.status} - \${errorText}\`); + throw new Error('Swarms API autonomous execution failed: ' + response.status + ' - ' + errorText); } const analysisResult = await response.json(); const intelligenceReport = analysisResult.output; console.log('✅ Autonomous Swarms AI analysis completed successfully'); - console.log(\`💰 Autonomous execution cost: \${analysisResult.usage?.billing_info?.total_cost || 'N/A'}\`); + console.log('💰 Autonomous execution cost: ' + (analysisResult.usage?.billing_info?.total_cost || 'N/A')); // Step 3: Execute autonomous actions based on intelligence if (env.AUTONOMOUS_ALERTS_EMAIL) { @@ -272,7 +272,7 @@ async function collectMarketIntelligence() { // Autonomous data collection from Yahoo Finance API const response = await fetch( - \`https://query1.finance.yahoo.com/v8/finance/chart/\${symbol}\`, + 'https://query1.finance.yahoo.com/v8/finance/chart/' + symbol, { signal: controller.signal, headers: { @@ -283,7 +283,7 @@ async function collectMarketIntelligence() { clearTimeout(timeout); if (!response.ok) { - throw new Error(\`Autonomous data collection failed: HTTP \${response.status}\`); + throw new Error('Autonomous data collection failed: HTTP ' + response.status); } const data = await response.json(); @@ -299,7 +299,7 @@ async function collectMarketIntelligence() { const dayChange = currentPrice - previousClose; const changePercent = ((dayChange / previousClose) * 100).toFixed(2); - console.log(\`📈 \${symbol}: $\${currentPrice} (\${changePercent}%) - Autonomous collection successful\`); + console.log('📈 ' + symbol + ': $' + currentPrice + ' (' + changePercent + '%) - Autonomous collection successful'); return [symbol, { price: currentPrice, @@ -319,9 +319,9 @@ async function collectMarketIntelligence() { }]; } catch (error) { - console.error(\`❌ Autonomous collection failed for \${symbol}:\`, error.message); + console.error('❌ Autonomous collection failed for ' + symbol + ':', error.message); return [symbol, { - error: \`Autonomous collection failed: \${error.message}\`, + error: 'Autonomous collection failed: ' + error.message, autonomous_collection_time: new Date().toISOString(), data_quality: 'failed' }]; @@ -337,7 +337,7 @@ async function collectMarketIntelligence() { }); const successfulCollections = Object.keys(marketIntelligence).filter(k => !marketIntelligence[k]?.error).length; - console.log(\`📊 Autonomous intelligence collection completed: \${successfulCollections}/\${targetSymbols.length} successful\`); + console.log('📊 Autonomous intelligence collection completed: ' + successfulCollections + '/' + targetSymbols.length + ' successful'); return marketIntelligence; } @@ -353,113 +353,36 @@ async function executeAutonomousAlerts(env, intelligenceReport, marketIntelligen // Autonomous detection of significant market movements const significantMovements = Object.entries(marketIntelligence) .filter(([symbol, data]) => data.change_percent && Math.abs(parseFloat(data.change_percent)) > 3) - .map(([symbol, data]) => \`\${symbol}: \${data.change_percent}%\`) + .map(([symbol, data]) => symbol + ': ' + data.change_percent + '%') .join(', '); - const alertSubject = \`🤖 Autonomous Market Intelligence Alert - \${new Date().toLocaleDateString()}\`; + const alertSubject = '🤖 Autonomous Market Intelligence Alert - ' + new Date().toLocaleDateString(); - const alertBody = \` - + const alertBody = ` - - - - -
-
-

🤖 Autonomous Market Intelligence

-

AI-Powered Autonomous Financial Analysis • Swarms API

-
- Autonomous - Real-time - AI-Powered - Global Edge -
-

Generated: \${new Date().toLocaleString()}

-
+ +

🤖 Market Intelligence Alert

+

Date: ${new Date().toLocaleString()}

+

Movements: ${significantMovements || 'Normal volatility'}

-
-
-

🚀 Autonomous Analysis Execution Complete

-

Significant Market Movements Detected: \${significantMovements || 'Market within normal volatility parameters'}

-

Next Autonomous Cycle: Scheduled automatically

-
- -
-

🧠 Autonomous AI Intelligence Report

-

Generated by autonomous Swarms AI agents with real-time market intelligence:

-
\${intelligenceReport}
-
- -
-

📊 Real-Time Market Intelligence

- - - - - - - - - - - - - \${Object.entries(marketIntelligence) - .filter(([symbol, data]) => !data.error) - .map(([symbol, data]) => \` - - - - - - - - - \`).join('')} - -
SymbolPriceChangeVolumeMarket StateData Quality
\${symbol}$\${data.price?.toFixed(2) || 'N/A'} - \${parseFloat(data.change_percent) >= 0 ? '+' : ''}\${data.change_percent}% - \${data.volume?.toLocaleString() || 'N/A'}\${data.market_state || 'N/A'}\${data.data_quality || 'N/A'}
-
-
+

Analysis Report:

+
${intelligenceReport}
- -
- +

Powered by Swarms API

+ - \`; + `; const formData = new FormData(); - formData.append('from', \`Autonomous Market Intelligence \`); + formData.append('from', 'Autonomous Market Intelligence '); formData.append('to', env.AUTONOMOUS_ALERTS_EMAIL); formData.append('subject', alertSubject); formData.append('html', alertBody); - const response = await fetch(\`https://api.mailgun.net/v3/\${env.MAILGUN_DOMAIN}/messages\`, { + const response = await fetch('https://api.mailgun.net/v3/' + env.MAILGUN_DOMAIN + '/messages', { method: 'POST', headers: { - 'Authorization': \`Basic \${btoa(\`api:\${env.MAILGUN_API_KEY}\`)}\` + 'Authorization': 'Basic ' + btoa('api:' + env.MAILGUN_API_KEY) }, body: formData });