anamansari062 / cozy-connect

Find your tribe, talk with people who share common grounds.
https://htf-hackathon.vercel.app
2 stars 0 forks source link

Emotion Detection from thoughts entered by user #1

Closed anamansari062 closed 1 year ago

anamansari062 commented 1 year ago

Description

  1. Detect user emotions from provided sentences.
  2. Using HTTP POST REST API call
  3. Sample API Body:
    {
    "text":"some text"
    }
WilfredAlmeida commented 1 year ago

OpenAI GPT-3 will be used for the task. Following is the JS code example. Please specify the file to add the code in.

const { Configuration, OpenAIApi } = require("openai");

const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

const response = await openai.createCompletion({
  model: "text-davinci-003",
  prompt: "Given list of emotions and a sentence, tell me the emotion of the sentence from the given list. Gererate 3 best possible classifications. Generate only the response keywords, don't generate any other text. Keep the output characters in lowercase.\n\nList of emotions: [admiration, adoration, appreciation of beauty, amusement, anger, anxiety, awe, awkwardness, boredom, calmness, confusion, craving, disgust, empathic pain, entrancement, excitement, fear, horror, interest, joy, nostalgia, relief, sadness, satisfaction, and surprise]\n\nSentence: she dumped me",
  temperature: 0.7,
  max_tokens: 256,
  top_p: 1,
  frequency_penalty: 0,
  presence_penalty: 0,
});
WilfredAlmeida commented 1 year ago

Resolved. Closing the issue.