Skip to content

Instantly share code, notes, and snippets.

@mplacona
Created October 8, 2024 14:37
Show Gist options
  • Save mplacona/7a53fcb32ca688d3e86a841b7eb7d91c to your computer and use it in GitHub Desktop.
Save mplacona/7a53fcb32ca688d3e86a841b7eb7d91c to your computer and use it in GitHub Desktop.
import { AirtopClient } from "@airtop/sdk";
import puppeteer from "puppeteer-core";
const apiKey = "YOUR_AIRTOP_API_KEY";
const client = new AirtopClient({ apiKey });
// Step 1: Create a session
const session = await client.sessions.create();
// Step 2: Connect to the browser
const browser = await puppeteer.connect({
browserWSEndpoint: session.data?.cdpWsUrl,
headers: { authorization: `Bearer ${apiKey}` },
});
// Step 3: Open a new page and navigate
const page = await browser.newPage();
await page.goto("https://www.airtop.ai");
// Step 4: Get window information
const windowInfo = await client.windows.getWindowInfoForPuppeteerPage(session.data, page);
// Step 5: Summarize content
const contentSummary = await client.windows.summarizeContent(session.data.id, windowInfo.data.windowId, {
prompt: 'Summarize the content of the page in 1 short paragraph up to 170 characters.'
});
console.log(contentSummary.data.modelResponse);
// Step 6: Clean up
await browser.close();
await client.sessions.terminate(session.id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment