{"id":13410083,"url":"https://github.com/polyfact/console-ai","last_synced_at":"2026-01-28T10:16:32.405Z","repository":{"id":183668760,"uuid":"633291634","full_name":"polyfact/console-ai","owner":"polyfact","description":"ai-console is an NPM package that extends console with console.ai(), sending logs to OpenAI for translation into human-readable logs with possible solutions. It simplifies debugging by providing better context and guidance, saving time and frustration. Just install it, require it, and use console.ai() instead of console.log().","archived":false,"fork":false,"pushed_at":"2023-07-27T12:09:51.000Z","size":237,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T23:02:16.886Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/polyfact.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-04-27T07:29:01.000Z","updated_at":"2024-02-29T13:33:09.000Z","dependencies_parsed_at":"2023-07-26T14:16:21.683Z","dependency_job_id":"eaf62581-62a4-4a95-b7b3-549f49326008","html_url":"https://github.com/polyfact/console-ai","commit_stats":null,"previous_names":["kevin-btc/ai-logger","kevin-btc/ai-console","polyfire-ai/console-ai","polyfact/console-ai","kevin-btc/console-ai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfact%2Fconsole-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfact%2Fconsole-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfact%2Fconsole-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/polyfact%2Fconsole-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/polyfact","download_url":"https://codeload.github.com/polyfact/console-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243600652,"owners_count":20317311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:04.883Z","updated_at":"2026-01-28T10:16:32.360Z","avatar_url":"https://github.com/polyfact.png","language":"TypeScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"# Console-ai\n\nConsole-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.\n\n![console-ai](https://n42-nft.s3.eu-west-3.amazonaws.com/logger-ai.png)\n\n## Installation\n\nUse the package manager [npm](https://www.npmjs.com/) to install Console-ai.\n\n```bash\n\nnpm  install  console-ai\n\n```\n\n## Getting Your PolyFact Token\n\nConsole-ai uses the powerful package called PolyFact to generate AI responses. To use it, you need to get a PolyFact token.\n\nFollow these steps to get your PolyFact token:\n\n1. Go to [app.polyfact.com](https://app.polyfact.com).\n\n2. Connect with GitHub.\n\n3. Copy the token.\n\nThen, you need to export the PolyFact token in your environment:\n\n```bash\n\nexport  POLYFACT_TOKEN=\u003cyour_polyfact_token\u003e\n\n```\n\n## Usage\n\nFirst, import and initialize the module:\n\n```typescript\nimport { extendConsole } from \"console-ai\";\n\nextendConsole();\n```\n\nNow, you can replace your usual `console.log()` or `console.error()` calls with `console.ai()`:\n\n```typescript\ntry {\n  // code that might throw an error\n} catch (e) {\n  console.ai(e);\n}\n```\n\n## Features\n\n- Converts error messages into a more understandable format.\n\n- Outlines potential causes of an error.\n\n- Suggests possible solutions.\n\n- Ensures original error messages are logged.\n\n## Options\n\nThe `extendConsole()` function can take an `AILoggerOptions` object:\n\n```typescript\n\nextendConsole({\n\nprompt?:  string;\n\nsections?: ErrorSection[];\n\nshowOriginalError?: boolean;\n\nshowResultWithJsonFormat?: boolean;\n\n});\n\n```\n\nWhere:\n\n- `prompt` is a string that instructs the OpenAI model how to format the output.\n\n- `sections` is an array of `ErrorSection` enums. It determines the sections of the output (default is all sections).\n\n- `showOriginalError` is a boolean that indicates whether to log the original error (default is `true`).\n\n- `showResultWithJsonFormat` is a boolean that specifies whether to show the formatted error message in JSON format (default is `false`).\n\n## Section Display Configuration\n\nYou 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:\n\n- `ErrorSection.Error`: This displays the actual error message or code.\n\n- `ErrorSection.Location`: This shows the file, function, or location where the error occurred.\n\n- `ErrorSection.Summary`: This provides a brief explanation or summary of the error.\n\n- `ErrorSection.Causes`: This lists the possible causes that may have led to the error.\n\n- `ErrorSection.Solutions`: This suggests potential solutions or fixes for the error.\n\nBy 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.\n\nHere is an example on how to do this:\n\ntypescriptCopy code\n\n`const sections: ErrorSection[] = [ErrorSection.Error, ErrorSection.Location];`\n\nIn 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.\n\n## Contributing\n\nPlease make sure to update tests as appropriate.\n\n## License\n\n[CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/)\n\n## Contact\n\nIf you want to contact me you can reach me at \u003ckevin@polyfact.com\u003e.\n\n## Author\n\n[kevin-btc](https://github.com/kevin-btc)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolyfact%2Fconsole-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpolyfact%2Fconsole-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpolyfact%2Fconsole-ai/lists"}