Skip to content

Instantly share code, notes, and snippets.

@mustafabutt-dev
mustafabutt-dev / ChatGPT-in-JavaScript.js
Last active March 14, 2023 14:28
Integrate ChatGPT in JavaScript app
// import the ChatGPTAPI
import { ChatGPTAPI } from 'chatgpt'
async function myFunction() {
// Initialize the constructor with your OpenAI API key
const api = new ChatGPTAPI({
apiKey: YOUR_OPENAI_API_KEY
})
// Invoke the sendMessage method to send a message to the GPT-3 model
const res = await api.sendMessage('Hello World!');
@mustafabutt-dev
mustafabutt-dev / chatgpt-and-google-docs.gs
Created February 3, 2023 22:04
Google Docs Integration with ChatGPT
// DROP DOWN MENU
function onOpen() {
DocumentApp.getUi().createMenu("ChatGPT")
.addItem("Generate Image", "generateImage")
.addItem("Generate synonym ", "generateSynonym")
.addItem("Write a tagline", "tagLine")
.addToUi();
}
// ****END MENU****
@mustafabutt-dev
mustafabutt-dev / index.js
Created April 26, 2022 03:09
code snippet to import XML data into Excel
// create sheet from stream(e.g. xml to xlsx)
var aspose = aspose || {};
//get the aspose.cells module in to your project.
aspose.cells = require("aspose.cells");
// load the fs module for reading/writing files
var fs = require("fs");
// creates the read stream of the source file