ChatGPT integration
Generate, refactor, and explain the code of a function inside the Azion Console editor, with credentials from your own OpenAI account.
The code editor of a function calls the ChatGPT APIs. The integration explains, generates, and refactors JavaScript inside the editor, so you do not open a separate tab. It runs on the credentials of your own OpenAI account, which you declare in the source code of the function.
Credentials
The ChatGPT integration authenticates with an OpenAI API key and an OpenAI organization ID. Generate both on the OpenAI platform:
Declare the two values as a comment in the source code of the function:
Code explanation
Code explanation returns a description of the code in the editor. Use it when you debug a function, when you review one before a change, or when you read code you did not write.
Code generation
Code generation turns a comment into JavaScript. The ChatGPT: Generate command, in the context menu of the editor, reads the selected comment as the prompt and returns the generated code.
This prompt asks for an HTML table with three columns:
The integration returns the markup:
Code refactor
Code refactor rewrites a block of JavaScript. The ChatGPT: Refactor command, in the context menu of the editor, refactors the code you select.
Debugging
The integration also covers debugging. For the symptoms of a function that fails at run time, and the remedy for each, refer to Troubleshooting.