askrella / whatsapp-chatgpt

ChatGPT + DALL-E + WhatsApp = AI Assistant :rocket: :robot:
3.34k stars 806 forks source link

Custom Context (`!context <name>`) #69

Open navopw opened 1 year ago

navopw commented 1 year ago

Define a json configuration file that has a list of actors (e.g. doctor, humorist, etc).

context-config.json or something similar

[
    {
        name: "doctor",
        prompt: "Act as a doctor, give medical advise"
    },
    {
        name: "humorist",
        prompt: "Act as a humorist"
    }
]

Add the environment variable CONTEXT which defines the actor/context for all newly created conversations.

Make it possible to switch between different context/actors with !context <name>

Example code for promptPrefix:

const res = await api.sendMessage('what is the answer to the universe?', {
  promptPrefix: `Act as ...`
})

Credits go to: @andrewssobral

HarshalDewangan commented 1 year ago

Can you write the full code for this custom context feature and make it easy for people to use?