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

console-ai

v1.0.0

Published

Console-ai is a Node.js module that boosts console functionality with a new method, console.ai(). It harnesses OpenAI's language models to convert error logs into readable formats, detailing potential causes and solutions. By replacing the standard consol

Downloads

8

Readme

Console-ai

Console-ai is a Node.js module that enhances console functionality with a new method, console.ai(). It utilizes OpenAI's language models to translate error logs into a more readable format, providing potential causes and solutions. By replacing the standard console.log() with console.ai(), developers can gain insights into complex issues and expedite the debugging process. The original error message can be logged, if you want ensuring data integrity. As such, Console-ai is a potent tool that not only enhances debugging, but also offers insights into application behavior, thereby improving development efficiency.

console-ai

Installation

Use the package manager npm to install Console-ai.


npm  install  console-ai

Getting Your PolyFact Token

Console-ai uses the powerful package called PolyFact to generate AI responses. To use it, you need to get a PolyFact token.

Follow these steps to get your PolyFact token:

  1. Go to app.polyfact.com.

  2. Connect with GitHub.

  3. Copy the token.

Then, you need to export the PolyFact token in your environment:


export  POLYFACT_TOKEN=<your_polyfact_token>

Usage

First, import and initialize the module:

import { extendConsole } from "console-ai";

extendConsole();

Now, you can replace your usual console.log() or console.error() calls with console.ai():

try {
  // code that might throw an error
} catch (e) {
  console.ai(e);
}

Features

  • Converts error messages into a more understandable format.

  • Outlines potential causes of an error.

  • Suggests possible solutions.

  • Ensures original error messages are logged.

Options

The extendConsole() function can take an AILoggerOptions object:


extendConsole({

prompt?:  string;

sections?: ErrorSection[];

showOriginalError?: boolean;

showResultWithJsonFormat?: boolean;

});

Where:

  • prompt is a string that instructs the OpenAI model how to format the output.

  • sections is an array of ErrorSection enums. It determines the sections of the output (default is all sections).

  • showOriginalError is a boolean that indicates whether to log the original error (default is true).

  • showResultWithJsonFormat is a boolean that specifies whether to show the formatted error message in JSON format (default is false).

Section Display Configuration

You can customize the output of error information using the sections array, which accepts values of the ErrorSection enum. Each enum value corresponds to a different aspect of the error information:

  • ErrorSection.Error: This displays the actual error message or code.

  • ErrorSection.Location: This shows the file, function, or location where the error occurred.

  • ErrorSection.Summary: This provides a brief explanation or summary of the error.

  • ErrorSection.Causes: This lists the possible causes that may have led to the error.

  • ErrorSection.Solutions: This suggests potential solutions or fixes for the error.

By default, all sections will be displayed if the sections array is not specified. However, you can choose to display only certain sections by explicitly specifying them in the sections array.

Here is an example on how to do this:

typescriptCopy code

const sections: ErrorSection[] = [ErrorSection.Error, ErrorSection.Location];

In this case, the output will only display the error message/code and its location. Any section not included in the sections array will not be displayed in the output. Adjust this array to suit the error information needs of your application.

Contributing

Please make sure to update tests as appropriate.

License

CC0 1.0 Universal

Contact

If you want to contact me you can reach me at [email protected].

Author

kevin-btc