-
В Google Sheet → Extensions → App Script
-
Вставте цей код:
/** * Генерує текст за допомогою моделі GPT3 від OpenAI * @param {string} prompt Запит до моделі GPT-3 * @param {string} cell Клітинка, з якої додати текст до запиту * @param {number} [maxWords=10] Максимальна кількість слів для формування відповіді * @return {string} Згенерований текст * @customfunction */function runOpenAI(prompt, cell, maxWords) {const API_KEY = "YOUR API KEY";maxTokens = 150if (maxWords){maxTokens = maxWords * 0.75}model = "text-davinci-003"prompt = prompt+cell+":",temperature= 0 // Set up the request body with the given parameters const requestBody = { "model": model, "prompt": prompt, "temperature": temperature, "max_tokens": maxTokens }; console.log(requestBody) // Set up the request options with the required headers const requestOptions = { "method": "POST", "headers": { "Content-Type": "application/json", "Authorization": "Bearer "+API_KEY }, "payload": JSON.stringify(requestBody) }; // Send the request to the GPT-3 API endpoint for completions const response = UrlFetchApp.fetch("https://api.openai.com/v1/completions", requestOptions); console.log(response.getContentText()) // Get the response body as a JSON object const responseBody = JSON.parse(response.getContentText()); let answer= responseBody.choices[0].text // Return the generated text from the response return answer}3. ЗамінітьYOUR API KEYв коді на ваш ключ. Знайти його можна в своїй адмінці OpenAI. І збережіть код, поверніться до своєї таблиці. -
За допомогою команди
“=runOpenAI()”створюйте потрібні вам запити. Наприклад,“=runOpenAI("write a 100 word product description that is light hearted and funny",F2)”.
Схожі новини
Roger Montti знайшов стародавнє дослідження Google — за 2020 рік. Схоже, що саме технологію, яка…
·2 хв
Google дещо змінив формат відповідей на питання. Новий випуск тут. Транскрибація англійською. Дуже…
·2 хв
Barry Adams рекомендує додавати теги до новинних статей, його власні думки не обов'язково…
·2 хв
Більше за січень 2023
Інші новини того ж місяця