OpenAI Extension
Enhance your Intrasheets application by integrating the ChatGPT API directly into your spreadsheet data grids. This extension enables automated content generation, intelligent response handling, and advanced data analysis, allowing front-end queries to connect to the API through the backend and deliver real-time, AI-powered insights to users.
Documentation
Section titled “Documentation”Methods
Section titled “Methods”| Method | Description |
|---|---|
=PROMPT() | Creates dynamic prompts by combining values or text fragments, enabling customized interactions with AI models for specific use cases. |
Example
Section titled “Example”Generate Marketing Copy
Section titled “Generate Marketing Copy”Suppose you have a list of products and their attributes and need to generate marketing copy for each item quickly.
A1: "Product Name"B1: "Product Description"C1: "Marketing Copy"A2: "Smartwatch"B2: "Fitness tracking, sleep monitoring, 48-hour battery life"
In C2, you would enter:
=PROMPT("Write an engaging marketing copy for a product named ", A2, " with these features: ", B2)Installation
Section titled “Installation”This extension requires Intrasheets Premium and OpenAI API account.
Using NPM
Section titled “Using NPM”$ npm install @jspreadsheet/openaiUsing a CDN
Section titled “Using a CDN”<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/openai/dist/index.min.js"></script>Configuration
Section titled “Configuration”Intrasheets Server enables secure requests to the ChatGPT API using each client’s API credentials. When a user executes a formula on the front end, the Intrasheets Server processes it and broadcasts the response to all connected users. With caching enabled, results are saved to the cell, minimizing unnecessary requests.
Installation
Section titled “Installation”Load the OpenAI extension and add it as an extension to the Intrasheets Server, as shown below.
const server = require('@jspreadsheet/server');const openai = require('@jspreadsheet/openai');
// Connect to the Open AI APIopenai({ apiKey: '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' });
// You can get this information on your Jspreadsheet Accountconst license = { clientId: 'your-client-id', licenseKey: 'your-license'}
// Private server that runs on your servers (100% private)server({ config: { cors: { origin: "*" }, }, port: 3000, error: function(e) { // Your implementation }, auth: async function(socket) { // Your implementation }, load: async function(guid) { // Your implementation }, create: async function(guid, config) { // Your implementation }, destroy: async function(guid) { // Your implementation }, change: async function(guid, changes) { // Your implementation }, license: license, extensions: { openai },});Examples
Section titled “Examples”Translating Column to French
Section titled “Translating Column to French”This example demonstrates the utilization of PROMPT to translate an entire column.
[ ['Hello', '=PROMPT("Translate ",A1," to French")'], ['Bye', '=PROMPT("Translate ",A2," to French")'], ['Thanks', '=PROMPT("Translate ",A3," to French")'], ['Sorry', '=PROMPT("Translate ",A4," to French")'],]Combining Words Semantics
Section titled “Combining Words Semantics”This example demonstrates the utilization of PROMPT to effectively combine word semantics.
['Flower', 'Bee', `=PROMPT(A1," and ",B1," combined result in this word:")`]