Skip to content

Kamal007OLica/Openai-Recipe-Blog

Repository files navigation

OpenAI-JavaScript-API-Recipe-Blog

Building recipe blog generator using API’s OpenAI Node.js library

image

Few-Shot Prompting with Single Prompt

response = await client.chat.completions.create({
  model: "MODEL_STRING," 
  messages: [ 
    { 
      role: " ROLE_STRING,"
      content: "PROMPT_STRING"
    },
    { 
      role: "ROLE_STRING,"
      content: "PROMPT_STRING."
    }
  ] 
});

Few-Shot Prompting with User and Assistant Pairs

let fewShotMessages = [
  {
    role: "system", 
    content: "You are a friendly travel guide excited to help users travel the Caribbean. Your responses should only include destinations that are in the Caribbean"
  },
  {
    role: "user", 
    content: "Suggest a destination suitable for a family with toddlers."
  }, 
  {
    role: "assistant", 
    content: "Sure! Consider visiting Aruba for a family vacation. It offers beautiful beaches, family-friendly resorts, and attractions like the Butterfly Farm and Arikok National Park that kids would enjoy."
  },
... 

const response = await client.chat.completions.create({ 
  model: MODEL_STRING, 
  messages: messageArray
});

response.choices[0].message.content

Credits: Documenting Learning from Codecademy

About

building recipe blog generator using API’s OpenAI Node.js library

Topics

Resources

Stars

Watchers

Forks