smart-error-explanator
Version:
A Node.js SDK that explains cryptic error messages using OpenAI's API.
1 lines • 2.44 kB
JavaScript
function a4_0x1ab9(_0x3c692c,_0x38ca26){const _0xe4bc09=a4_0xe4bc();return a4_0x1ab9=function(_0x1ab9ba,_0x27647c){_0x1ab9ba=_0x1ab9ba-0x1f0;let _0x124bcd=_0xe4bc09[_0x1ab9ba];return _0x124bcd;},a4_0x1ab9(_0x3c692c,_0x38ca26);}(function(_0xe994a7,_0x46d6a1){const _0x56050e=a4_0x1ab9,_0x228ab5=_0xe994a7();while(!![]){try{const _0x1b3054=-parseInt(_0x56050e(0x1f8))/0x1*(-parseInt(_0x56050e(0x1f0))/0x2)+-parseInt(_0x56050e(0x203))/0x3+-parseInt(_0x56050e(0x1fd))/0x4*(parseInt(_0x56050e(0x204))/0x5)+parseInt(_0x56050e(0x1ff))/0x6+-parseInt(_0x56050e(0x1f4))/0x7+parseInt(_0x56050e(0x207))/0x8+parseInt(_0x56050e(0x200))/0x9*(parseInt(_0x56050e(0x202))/0xa);if(_0x1b3054===_0x46d6a1)break;else _0x228ab5['push'](_0x228ab5['shift']());}catch(_0x2cf18b){_0x228ab5['push'](_0x228ab5['shift']());}}}(a4_0xe4bc,0x3fa83));import{OpenAI}from'openai';import{config}from'dotenv';config();function a4_0xe4bc(){const _0x2c20bb=['5625wfXFmz','message','11950DgMbit','1510263DNpNHo','10zrOzyx','trim','No\x20function\x20code\x20provided.','2029824szPbsa','542CvROxN','\x0a\x20\x20\x20\x20Function\x20Source\x20Code:\x20','create','No\x20response\x20available.','2336446KxkeRu','content','gpt-3.5-turbo','chat','859ZPJIRk','OPENAI_API_KEY','stringify','choices','\x0a\x0a\x20\x20\x20\x20Context:\x0a\x20\x20\x20\x20Error\x20Message:\x20','486308nCvUER','env','646200CsCUoB'];a4_0xe4bc=function(){return _0x2c20bb;};return a4_0xe4bc();}export async function chatWithAI(_0x4005a2,_0x128da5,_0x5a36ef,_0x13f030){const _0x6cf159=a4_0x1ab9,_0xe8e9a4=process[_0x6cf159(0x1fe)][_0x6cf159(0x1f9)];if(!_0xe8e9a4)throw new Error('OpenAI\x20API\x20key\x20not\x20set.\x20Please\x20configure\x20it\x20in\x20the\x20.env\x20file.');const _0x177aff=new OpenAI({'apiKey':_0xe8e9a4}),_0x2d80b5='\x0a\x20\x20\x20\x20User\x20Message:\x20'+_0x4005a2+_0x6cf159(0x1fc)+_0x128da5+_0x6cf159(0x1f1)+(_0x5a36ef||_0x6cf159(0x206))+'\x0a\x20\x20\x20\x20Arguments\x20Passed:\x20'+JSON[_0x6cf159(0x1fa)](_0x13f030,null,0x2)+'\x0a\x0a\x20\x20\x20\x20Respond\x20to\x20the\x20user\x27s\x20query\x20regarding\x20the\x20error.\x20Provide\x20helpful\x20guidance,\x20explanations,\x20and\x20suggestions.\x0a\x20\x20',_0x47e7f5=await _0x177aff[_0x6cf159(0x1f7)]['completions'][_0x6cf159(0x1f2)]({'model':_0x6cf159(0x1f6),'messages':[{'role':'user','content':_0x2d80b5}]});return _0x47e7f5[_0x6cf159(0x1fb)][0x0]?.[_0x6cf159(0x201)]?.[_0x6cf159(0x1f5)]?.[_0x6cf159(0x205)]()||_0x6cf159(0x1f3);}