Debugging Simplified with console.ai()

victorforissier

victor forissier

Posted on July 27, 2023

Debugging Simplified with console.ai()

Debugging often feels to me like finding a needle in a haystack, which is why we did this new tool, console-ai, and it makes a notable difference. You can explore more about it on the GitHub repository.

console-ai, a Node.js module, redefines console functionality. It leverages OpenAI's language models to transform error logs into an easily comprehensible format, outlining potential causes and solutions. It introduces a new method, console.ai(), as an upgrade to the standard console.log().

console-ai

How Does console-ai Work?

The essence of console-ai is to expedite and enhance the debugging process, but how does it do that?

By simply replacing your regular console.log() or console.error() calls with console.ai(), this tool offers valuable insights into complex issues, which can dramatically speed up debugging. Moreover, it maintains the integrity of your data by logging the original error message, if you choose. If that sounds intriguing, do check out the project on GitHub.

Getting Started with console-ai

First, import and initialize the module:

import { extendConsole } from "console-ai";


extendConsole();
Enter fullscreen mode Exit fullscreen mode

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);
}
Enter fullscreen mode Exit fullscreen mode

Beyond Debugging

In addition to enhancing debugging, console-ai offers insights into application behavior, thereby improving overall development efficiency. It translates error messages into a more understandable format, outlines potential causes of an error, suggests possible solutions, and ensures original error messages are logged.

Customize Your Experience

You can customize console.ai by picking which sections of the output to display or decide whether or not to keep the original error.

extendConsole({
    prompt?:  string;
    sections?: ErrorSection[];
    showOriginalError?: boolean;
    showResultWithJsonFormat?: boolean;
});
Enter fullscreen mode Exit fullscreen mode

You can find more details about these customization options in the GitHub repository.

A Peek Behind the Scenes

console-ai was built using the PolyFact SDK, a Node SDK that calls an API to help build AI tools and apps. The PolyFact SDK forms the backbone of Console-ai, enabling it to provide enhanced console functionality.

Wrapping Up

console-ai presents a modest yet powerful solution to improve debugging and development efficiency. It offers an innovative way to translate error logs into a more readable format, providing potential causes and solutions. By leveraging the power of the PolyFact SDK and OpenAI's language models, it delivers a more insightful, customizable debugging experience.

Visit the GitHub repository to check it out and see how console-ai can enhance your development workflow. Happy coding!

For any queries or suggestions, feel free to reach out on Discord.

πŸ’– πŸ’ͺ πŸ™… 🚩
victorforissier
victor forissier

Posted on July 27, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related