Skip to content

Commit

Permalink
Make asynchronous calls consistent and enhance text parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Sep 27, 2024
1 parent 53b3b29 commit 9795e50
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/auto/scrape_table_data.genai.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ const page = await host.browse('https://example.com');
// Select a table element on the page by its test-id
const table = page.locator('table[data-testid="data-table"]');
// Convert the HTML of the table into Markdown format
const markdownTable = parsers.HTMLToMarkdown(await table.innerHTML());
const markdownTable = await parsers.HTMLToMarkdown(await table.innerHTML());
// Define the converted table for further processing
def('TABLE_MARKDOWN', markdownTable);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const page = await host.browse('https://bing.com');
const screenshot = await page.screenshot();
defImages(screenshot);
const text = parsers.HTMLToMarkdown(await page.content())
def('PAGE_TEXT', text);
$`Analyze the content of the page PAGE_TEXT and provide insights.`;
const page = await host.browse("https://bing.com")
const screenshot = await page.screenshot()
defImages(screenshot)
const text = await parsers.HTMLToMarkdown(await page.content())
def("PAGE_TEXT", text)
$`Analyze the content of the page PAGE_TEXT and provide insights.`
13 changes: 9 additions & 4 deletions packages/sample/genaisrc/rss.genai.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ const { rss } = XML.parse(await (await fetch("https://dev.to/feed")).text())

defData(
"ARTICLES",
rss.channel.item.map(({ title, description }) => ({
title,
description: parsers.HTMLToText(description, {}).slice(0, 2000),
}))
await Promise.all(
rss.channel.item.map(async ({ title, description }) => ({
title,
description: (await parsers.HTMLToText(description, {})).slice(
0,
2000
),
}))
)
)
$`
- Summarize ARTICLES
Expand Down

0 comments on commit 9795e50

Please sign in to comment.