Dec 20, 2022 12:01 PM - edited Dec 20, 2022 12:02 PM
Using chatGPT in an Airtable automation.
In my use case, the automation triggers on when an Airtable record matches conditions,
then follows with 2 actions, run script and update record. Adjust the first part of the prompt
with your own use case. Tip: Use chatGPT to help you write a prompt for chatGPT (!)
let inputConfig = input.config();
text = `${inputConfig.text}`;
var key = "openai-api-key";
var url = "https://api.openai.com/v1/completions";
prompt = "Reword this text to grade 9 reading level: " + text;
var gpt = {
model : "text-davinci-003",
prompt : prompt,
temperature : 0,
max_tokens : 1024
};
response = await fetch(url, {
method: 'POST',
body: JSON.stringify(gpt),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + key,
}
});
answer= await response.json();
data=answer.choices[0].text;
output.set('your-airtable-field',data);
Dec 20, 2022 12:56 PM
BOOM.
Feb 17, 2023 06:07 AM
this is awesome - though davinci isn't quiet the same or as good as chatgpt though right?
Feb 17, 2023 06:24 AM
chatGPT isn't a model though.
Feb 23, 2023 10:17 AM
Hi Guys,
where can I find the ChatGPT API?
It seems they can no longer be activated. I have a Pro account.
Thank you 🙂
Mar 01, 2023 06:00 AM - edited Mar 01, 2023 06:01 AM
Hi @chrisbyrne
and thank you for this show and tell!
I'm trying to do basically the same thing, but get only "undefined" responses. I might be doing some simple mistake, any idea what it is? Posting my edited script below
let inputConfig = input.config();
text = `${inputConfig.textToMakeShorter}`;
var key = "XXXXX";
var url = "https://api.openai.com/v1/completions";
prompt = "Summarize this text: " + text;
var gpt = {
model : "text-davinci-003",
prompt : prompt,
temperature : 0,
max_tokens : 1024
};
response = await fetch(url, {
method: 'POST',
body: JSON.stringify(gpt),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + key,
}
});
answer= await response.json();
data=answer.choices[0].text;
output.set('shortenedText',data);
Mar 01, 2023 06:21 AM
It's at capacity rn so could be that, it's something you will have to allow for.
In my app I have a retry number field that gets incremented if it fails.
What I would do now, is test the step before the prompt with
console.log(key) and console.log(url) to make sure these are correct.
The code I provided is bare bones without error checking, to make it clear what's happening.
You could add this before the answer= await response.json();
if (!response.ok) {
console.error(`Error: ${response.status}`);
}
This should cough up whatever is going on.
Mar 06, 2023 09:43 AM
Hello,
I wondering if it would be possible to perform ChatGPT summerisation when the WebClipper perform the capture of the page ?
Good or Bad idea ?
How do you handle to long article ? Did you try the GPT 3.5 with it's lower fees ?
Thanks
Mar 16, 2023 04:03 AM
To handle long articles you will need to strip the text so it's less than 1,500 words (GPT limit)
text = text.substring(0,2048);
Though with GPT4 it's expanded to 32k, a gamechanger!
Mar 26, 2023 02:11 AM
Yes playing with it 32k is interesting but I think expensive at scale.
Are you sure token = word ? What does it means for an html content ?