Skip to content

Latest commit

 

History

History
95 lines (69 loc) · 3.8 KB

Airtable + GPT-3 1f62ce98b82d4d3685214c55303bc08d.md

File metadata and controls

95 lines (69 loc) · 3.8 KB

Airtable + GPT-3

  1. GPT-3 Prompt
  2. GPT-3 Prompt to API Details
  3. Integrate GPT-3 API Into Airtable

https://youtu.be/LK2D3KbLPb4

https://youtu.be/LerLk1WLisU

https://youtu.be/Vtx-S8Gtfw8

Base: ReviewReplier

Table: Reviews

columns: review , reply

Automation:

  1. Trigger:
  2. Script:

GPT-3 Prompt

Write a reply to the given review. If the customer has any concerns, address them.

Review: One of the worst hyderabadi briyani i have ever tasted. Visited this place due to special occasion, but the briyani served here entirely spoiled our mood. Service was quick though, masala in the briyani was not good. Briyani is below average, hence we ordered kalmi chicken, which was okay and upto the mark. I don't suggest this place if you really wish to taste the original Hyderabad briyani
Replay: We understand you did not like the food, which prompted you to give us this feedback. We would like to apologise for the overall experience. Please give us another opportunity and we will do everything possible to give you a memorable experience

##

Review: My journey with paradise is along one. Our family is a hard core fan of Paradise biryanis. We tried fiery kababs and fiery boneless chicken biryani which were both yummy. Thank you Paradise for never disappointing us
Vegetarian options: The limited veg options are all good to try
Replay: Thank you for visiting us and giving us a great feedback overall. We would like to host you again at our Outlet.

##

Accessing Table or Input

console.log(`Hello, ${base.name}!`);
let inputConfig = input.config();
console.log(`The review is : ${inputConfig.review}`);

let table = base.getTable('Reviews');

console.log("Table: ",table)

Call GPT-3

let prompt = `Write a reply to the given review. If the customer has any concerns, address them.\n\nReview: One of the worst hyderabadi briyani i have ever tasted. Visited this place due to special occasion, but the briyani served here entirely spoiled our mood. Service was quick though, masala in the briyani was not good. Briyani is below average, hence we ordered kalmi chicken, which was okay and upto the mark. I don't suggest this place if you really wish to taste the original Hyderabad briyani\nReplay: We understand you did not like the food, which prompted you to give us this feedback. We would like to apologise for the overall experience. Please give us another opportunity and we will do everything possible to give you a memorable experience\n\n##\n\nReview: My journey with paradise is along one. Our family is a hard core fan of Paradise biryanis. We tried fiery kababs and fiery boneless chicken biryani which were both yummy. Thank you Paradise for never disappointing us\nVegetarian options: The limited veg options are all good to try\nReplay: Thank you for visiting us and giving us a great feedback overall. We would like to host you again at our Outlet.\n\n##\n\nReview:${inputConfig.review}\nReplay:`

console.log("Prompt: ",prompt)
let response = await fetch("https://api.openai.com/v1/completions", {
    body: JSON.stringify({
    "model": "text-davinci-002",
    "prompt": prompt,
    "max_tokens": 256,
    "top_p": 1,
    "frequency_penalty": 0,
    "presence_penalty": 0
  }),
    headers: {
      Authorization: "Bearer your-key",
      "Content-Type": "application/json"
    },
    method: "POST"
  })

let data = await response.json()
let output = data['choices'][0]['text'].trim()

if (output){
    console.log('GPT-3 Replay: '+output)
    await table.updateRecordAsync(inputConfig.id, {
        "reply" : output
    })
}

Update Record

if (output){
    console.log('GPT-3 Replay: '+output)
    await table.updateRecordAsync(inputConfig.id, {
        "reply" : output
    })
}