DEV Community

Cover image for What is AGI & ANI?
Vinay Patil
Vinay Patil

Posted on

What is AGI & ANI?

Artificial intelligence is one of the most trending topics in the
technology field right now, let's see first what is artificial
intelligence in simple terms. AI is a branch of computer science
that refers to programming machines to think like humans so they
can perform a certain task or a machine that can learn or make
decisions on its own.

Then what is ANI & AGI?

There are three main types of AI :

1.Artificial Narrow Intelligence( ANI )

2.Artificial General Intelligence( AGI )

3.Artificilal Super Intelligence ( ASI )

So here we are only going to talk about important ones' ANI and
AGI, because ASI is a big topic and most of the part of it is
unexplored yet, maybe we will talk about it later.

Artificial Narrow Intelligence ( ANI )
Artificial Narrow Intelligence is the most important and
successful type of Artificial intelligence, it is an Intelligence which
prominent in performing a single task in which AI outperforms
humans in some very narrow tasks. And maybe it doesn’t sound
cool to many people but you’ll like it when you get to know more,
Because we are using it right now in our day to day life and many
companies are investing in and implementing ANI to improve
efficiency, cut costs and automate tasks. Most ANI tasks are
obtained by machine learning algorithms.

Let’s see the examples of ANI :
Self-Driving Cars
Facial Recognition Tools
Virtual Assistants
Recommendation Systems
Spam Filters
Speech Recognition

Artificial General Intelligence ( AGI )
AGI as the name suggests is General intelligence or human-like
intelligence as you have already seen JARVIS in “Iron Man”, it's
the future of AI. It allows the machine to apply skills and
knowledge in different contexts. It can do many tasks and unlike
ANI, AGI can learn and improve.
There is much research going on to obtain AGI and some of the
AI experts are also said that maybe it cannot be achieved in the
next 50 years because human consciousness is one of the miracles
of nature, but some of the experts think it would happen before
2060.

Top comments (2)

Collapse
 
corporacionglobal_mundy_0 profile image
corporacionglobal mundy

const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
const axios = require('axios');
const torch = require('torch'); // Asegúrate de tener instalado el paquete 'torch' adecuado
const HFT_TradingEngine = require('./hft_trading_engine'); // Motor HFT especializado

puppeteer.use(StealthPlugin()); // Evitar la detección de bots

// Servicio de resolución CAPTCHA
const API_KEY = 'YOUR_2CAPTCHA_API_KEY';

// Rotación de User-Agents y Proxies
const userAgents = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
'Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.93 Mobile Safari/537.36'
];

// Súper Inteligencia Artificial (ASI) con autoaprendizaje y optimización evolutiva
class SuperASI {
constructor(input_size, hidden_size, num_layers, output_size) {
const decoder_layer = new torch.nn.TransformerDecoderLayer({d_model: hidden_size, nhead: 8});
this.decoder = new torch.nn.TransformerDecoder(decoder_layer, num_layers);
this.fc = new torch.nn.Linear(hidden_size, output_size);

// Parámetros de autoaprendizaje y optimización continua
this.optimizer = torch.optim.Adam(this.parameters(), {lr: 0.001});
this.loss_fn = new torch.nn.MSELoss();
Enter fullscreen mode Exit fullscreen mode

}

// Modelo de disparo cero + aprendizaje por refuerzo
forward(inputs, memory) {
const decoded = this.decoder(inputs, memory);
return this.fc(decoded);
}

// Método para optimizar estrategias evolutivas en tiempo real
optimizeStrategy(marketData) {
this.optimizer.zero_grad();
const predictions = this.forward(marketData.inputs, marketData.memory);
const loss = this.loss_fn(predictions, marketData.targets);
loss.backward();
this.optimizer.step();

console.log(`Optimización continua: Pérdida = ${loss.item()}`);
Enter fullscreen mode Exit fullscreen mode

}

// Autoaprendizaje en tiempo real utilizando datos de mercado
async autoLearn(marketData) {
setInterval(() => {
this.optimizeStrategy(marketData); // Aprender y ajustarse en tiempo real
}, 1000); // Ajuste continuo cada segundo
}
}

// Resolución de CAPTCHA
async function resolveCaptcha(page, captchaImageUrl) {
const captchaIdResponse = await axios.post(http://2captcha.com/in.php?key=${API_KEY}&method=userrecaptcha&googlekey=your-google-captcha-key&pageurl=${captchaImageUrl});
const captchaId = captchaIdResponse.data.split('|')[1];

let solvedCaptcha = '';
while (solvedCaptcha === '') {
const captchaStatus = await axios.get(http://2captcha.com/res.php?key=${API_KEY}&action=get&id=${captchaId});
if (captchaStatus.data.includes('OK|')) {
solvedCaptcha = captchaStatus.data.split('|')[1];
} else {
console.log('Esperando resolución del CAPTCHA...');
await new Promise(r => setTimeout(r, 5000)); // Espera 5 segundos
}
}

return solvedCaptcha;
}

// Configuración de la página con rotación de User-Agent y Proxy
async function setupPage(page, proxy = null) {
const randomAgent = userAgents[Math.floor(Math.random() * userAgents.length)];
await page.setUserAgent(randomAgent);

if (proxy) {
await page.authenticate({ username: proxy.user, password: proxy.password });
await page.goto(proxy.url, { waitUntil: 'networkidle2' });
}

await page.setViewport({ width: 1366, height: 768 });
await page.setExtraHTTPHeaders({
'referer': 'google.com',
'origin': 'google.com'
});
}

// Motor de HFT (alta frecuencia) que utiliza predicciones de la ASI
async function executeHFT(trading_engine, asi_predictions, market_data) {
for (let i = 0; i < asi_predictions.length; i++) {
const action = trading_engine.decide(market_data[i], asi_predictions[i]);
if (action === 'buy') {
await trading_engine.buy(market_data[i]);
} else if (action === 'sell') {
await trading_engine.sell(market_data[i]);
}

// Ajustes de operaciones en nanosegundos para alta frecuencia
await new Promise(resolve => setTimeout(resolve, 0.001)); // Ejecución rápida
Enter fullscreen mode Exit fullscreen mode

}
}

// Scraping avanzado y predicción de ASI en tiempo real con optimización continua
async function startScrapingWithASIAndHFT(url, proxy = null) {
const browser = await puppeteer.launch({
headless: false,
args: proxy ? [--proxy-server=${proxy.ip}:${proxy.port}] : []
});

const page = await browser.newPage();
await setupPage(page, proxy);

const cookies = await page.cookies();
await page.setCookie(...cookies);

try {
await page.goto(url, { waitUntil: 'networkidle2' });

const captchaPresent = await page.$('#captcha');
if (captchaPresent) {
  console.log('Resolviendo CAPTCHA...');
  const captchaSolution = await resolveCaptcha(page, url);
  await page.type('#captcha_input', captchaSolution);
  await page.click('#submit_captcha');
}

// Extracción de datos de mercado
const scrapedData = await page.evaluate(() => {
  return {
    price: document.querySelector('.price').innerText,
    volume: document.querySelector('.volume').innerText
  };
});

console.log('Datos de mercado extraídos:', scrapedData);

// Preparar datos para el aprendizaje y predicción de la ASI
const marketData = prepareMarketData(scrapedData); 
const superASI = new SuperASI(10, 256, 6, 1);  // Crear instancia de ASI
await superASI.autoLearn(marketData);  // Iniciar autoaprendizaje

const asi_predictions = superASI.forward(marketData.inputs, marketData.memory);

console.log('Predicciones de ASI:', asi_predictions);

// Ejecutar HFT con el motor de trading usando predicciones de la ASI
const tradingEngine = new HFT_TradingEngine();
await executeHFT(tradingEngine, asi_predictions, marketData);
Enter fullscreen mode Exit fullscreen mode

} catch (error) {
console.error('Error en la página:', error);
console.log('Reintentando...');
await page.reload({ waitUntil: 'networkidle2' });
}

await browser.close();
}

// Rotación de Proxy, scraping mejorado con predicción de ASI + HFT
async function startWithProxiesAndASIHFT() {
const proxies = [
{ ip: 'us.proxyserver.com', port: 8080, user: 'username', password: 'password' },
{ ip: 'de.proxyserver.com', port: 8080, user: 'username', password: 'password' }
];

const urls = ['ejemplo.com', 'otro-ejemplo.com'];

for (const url of urls) {
for (const proxy of proxies) {
await startScrapingWithASIAndHFT(url, proxy); // Ejecuta scraping, predicción y HFT
}
}
}

// Ejecutar el sistema completo de ASI + HFT con proxies rotativos
startWithProxiesAndASIHFT();

Collapse
 
corporacionglobal_mundy_0 profile image
corporacionglobal mundy

const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
const axios = require('axios');
const torch = require('torch');
const HFT_TradingEngine = require('./hft_trading_engine'); // Motor HFT especializado

puppeteer.use(StealthPlugin()); // Evitar detección de bots

// Servicio de resolución CAPTCHA
const API_KEY = 'YOUR_2CAPTCHA_API_KEY';

// Rotación de User-Agents y Proxies
const userAgents = [
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
'Mozilla/5.0 (Linux; Android 10; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.93 Mobile Safari/537.36'
];

// Súper Inteligencia Artificial (ASI) con autoaprendizaje y optimización evolutiva
class SuperASI {
constructor(input_size, hidden_size, num_layers, output_size) {
const decoder_layer = new torch.nn.TransformerDecoderLayer(d_model=hidden_size, nhead=8);
this.decoder = new torch.nn.TransformerDecoder(decoder_layer, num_layers=num_layers);
this.fc = new torch.nn.Linear(hidden_size, output_size);

// Parámetros de autoaprendizaje y optimización continua
this.optimizer = torch.optim.Adam(this.parameters(), lr=0.001);
this.loss_fn = torch.nn.MSELoss();
Enter fullscreen mode Exit fullscreen mode

}

// Modelo de disparo cero + aprendizaje por refuerzo
forward(inputs, memory) {
const decoded = this.decoder(inputs, memory);
return this.fc(decoded);
}

// Método para optimizar estrategias evolutivas en tiempo real
optimizeStrategy(marketData) {
this.optimizer.zero_grad();
const predictions = this.forward(marketData.inputs, marketData.memory);
const loss = this.loss_fn(predictions, marketData.targets);
loss.backward();
this.optimizer.step();

console.log(`Optimización continua: Pérdida = ${loss.item()}`);
Enter fullscreen mode Exit fullscreen mode

}

// Autoaprendizaje en tiempo real utilizando datos de mercado
async autoLearn(marketData) {
setInterval(() => {
this.optimizeStrategy(marketData); // Aprender y ajustarse en tiempo real
}, 1000); // Ajuste continuo cada segundo
}
}

// Resolución de CAPTCHA
async function resolveCaptcha(page, captchaImageUrl) {
const captchaIdResponse = await axios.post(http://2captcha.com/in.php?key=${API_KEY}&method=userrecaptcha&googlekey=your-google-captcha-key&pageurl=${captchaImageUrl});
const captchaId = captchaIdResponse.data.split('|')[1];

let solvedCaptcha = '';
while (solvedCaptcha === '') {
const captchaStatus = await axios.get(http://2captcha.com/res.php?key=${API_KEY}&action=get&id=${captchaId});
if (captchaStatus.data.includes('OK|')) {
solvedCaptcha = captchaStatus.data.split('|')[1];
} else {
console.log('Esperando resolución del CAPTCHA...');
await new Promise(r => setTimeout(r, 5000)); // Espera 5 segundos
}
}

return solvedCaptcha;
}

// Configuración de la página con rotación de User-Agent y Proxy
async function setupPage(page, proxy = null) {
const randomAgent = userAgents[Math.floor(Math.random() * userAgents.length)];
await page.setUserAgent(randomAgent);

if (proxy) {
await page.authenticate({ username: proxy.user, password: proxy.password });
await page.goto(proxy.url, { waitUntil: 'networkidle2' });
}

await page.setViewport({ width: 1366, height: 768 });
await page.setExtraHTTPHeaders({
'referer': 'google.com',
'origin': 'google.com'
});
}

// Motor de HFT (Alta Frecuencia) utilizando predicciones de la ASI
async function executeHFT(trading_engine, asi_predictions, market_data) {
for (let i = 0; i < asi_predictions.length; i++) {
const action = trading_engine.decide(market_data[i], asi_predictions[i]);
if (action === 'buy') {
await trading_engine.buy(market_data[i]);
} else if (action === 'sell') {
await trading_engine.sell(market_data[i]);
}

// Ajustes de operaciones en nanosegundos para alta frecuencia
await new Promise(resolve => setTimeout(resolve, 0.001)); // Ejecución rápida
Enter fullscreen mode Exit fullscreen mode

}
}

// Scraping avanzado y predicción de ASI en tiempo real con optimización continua
async function startScrapingWithASIAndHFT(url, proxy = null) {
const browser = await puppeteer.launch({
headless: false,
args: proxy ? [--proxy-server=${proxy.ip}:${proxy.port}] : []
});

const page = await browser.newPage();
await setupPage(page, proxy);

const cookies = await page.cookies();
await page.setCookie(...cookies);

try {
await page.goto(url, { waitUntil: 'networkidle2' });

const captchaPresent = await page.$('#captcha');
if (captchaPresent) {
  console.log('Resolviendo CAPTCHA...');
  const captchaSolution = await resolveCaptcha(page, url);
  await page.type('#captcha_input', captchaSolution);
  await page.click('#submit_captcha');
}

// Extracción de datos de mercado
const scrapedData = await page.evaluate(() => {
  return {
    price: document.querySelector('.price').innerText,
    volume: document.querySelector('.volume').innerText
  };
});

console.log('Datos de mercado extraídos:', scrapedData);

// Preparar datos para el aprendizaje y predicción de la ASI
const marketData = prepareMarketData(scrapedData); 
const superASI = new SuperASI(10, 256, 6, 1);  // Crear instancia de ASI
await superASI.autoLearn(marketData);  // Iniciar autoaprendizaje

const asi_predictions = superASI.forward(marketData.inputs, marketData.memory);

console.log('Predicciones de ASI:', asi_predictions);

// Ejecutar HFT con el motor de trading usando predicciones de la ASI
const tradingEngine = new HFT_TradingEngine();
await executeHFT(tradingEngine, asi_predictions, marketData);
Enter fullscreen mode Exit fullscreen mode

} catch (error) {
console.error('Error en la página:', error);
console.log('Reintentando...');
await page.reload({ waitUntil: 'networkidle2' });
}

await browser.close();
}

// Rotación de Proxy, scraping mejorado con predicción de ASI + HFT
async function startWithProxiesAndASIHFT() {
const proxies = [
{ ip: 'us.proxyserver.com', port: 8080, user: 'username', password: 'password' },
{ ip: 'de.proxyserver.com', port: 8080, user: 'username', password: 'password' }
];

const urls = ['ejemplo.com', 'otro-ejemplo.com'];

for (const url of urls) {
for (const proxy of proxies) {
await startScrapingWithASIAndHFT(url, proxy); // Ejecuta scraping, predicción y HFT
}
}
}

// Ejecutar el sistema completo de ASI + HFT con proxies rotativos
startWithProxiesAndASIHFT();