npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ejfox/gpt-browser

v2.0.0

Published

A powerful Node.js package that fetches a webpage, breaks it into chunks, analyzes its content, and generates a summary using OpenAI's Chat API.

Downloads

248

Readme

GPT Browser

A powerful Node.js package that fetches a webpage, breaks it into chunks, analyzes its content, and generates a summary using OpenAI's Chat API.

https://github.com/ejfox/gpt-browser/assets/530073/e7a5a81e-40ca-44fb-8d2d-a1b0daa235b5

Features

  • Fetches and parses webpages using Puppeteer
  • Generates summaries using OpenAI's Chat API
  • Customizable summarization options (model, prompts, token limits)
  • Easy integration into your Node.js projects
  • Command-line interface using npx

Installation

To use GPT Browser in your project, install it from npm:

npm install @ejfox/gpt-browser

Usage

In a Node.js Project

Import the fetchAndSummarizeUrl function from the package and use it in your code:

const { fetchAndSummarizeUrl } = require('@ejfox/gpt-browser');

async function main() {
  const url = 'https://example.com';
  const options = {
    model: 'gpt-3.5-turbo',
    summaryPrompt: 'Summarize the key points from the webpage:',
  };

  const summary = await fetchAndSummarizeUrl(url, options);
  console.log(summary);
}

main();

Using npx

You can also use GPT Browser directly from the command line using npx:

npx @ejfox/gpt-browser --url https://example.com

Customization Options

You can customize the summarization process by passing additional options:

  • --model or -m: OpenAI model to use for summarization (default: "gpt-4-turbo-preview")
  • --chunkAmount or -c: Desired chunk size for text splitting (default: 12952)
  • --summaryPrompt or -sp: Prompt for generating the summary (default: "Please sort these facts from in order of importance, with the most important fact first")
  • --summaryMaxTokens or -smt: Maximum number of tokens for the summary (default: 4096)
  • --chunkPrompt or -cp: Prompt for processing text chunks (default: WEBPAGE_UNDERSTANDER_PROMPT)

Example with custom options:

npx @ejfox/gpt-browser --url https://example.com --model gpt-3.5-turbo --chunkAmount 8000 --summaryPrompt "Summarize the key points from the webpage:"

You can also store your prompts in local text files and echo them into the command:

npx @ejfox/gpt-browser --url https://example.com --summaryPrompt "$(cat summaryprompt1.txt)" --chunkPrompt "$(cat chunkprompt2.txt)"

Examples

  1. Summarize a Wikipedia article in your Node.js project:
const { fetchAndSummarizeUrl } = require('@ejfox/gpt-browser');

async function main() {
  const url = 'https://en.wikipedia.org/wiki/OpenAI';
  const summary = await fetchAndSummarizeUrl(url);
  console.log(summary);
}

main();
  1. Summarize a news article with a custom prompt using npx:
npx @ejfox/gpt-browser --url https://www.theatlantic.com/science/archive/2024/02/talking-whales-project-ceti --summaryPrompt "Provide a brief overview of the main events covered in the article:"
  1. Summarize a blog post using a different OpenAI model in your project:
const { fetchAndSummarizeUrl } = require('@ejfox/gpt-browser');

async function main() {
  const url = 'https://openai.com/blog/chatgpt';
  const options = {
    model: 'gpt-3.5-turbo',
  };

  const summary = await fetchAndSummarizeUrl(url, options);
  console.log(summary);
}

main();

License

This project is open-source and available under the MIT License.