File size: 2,692 Bytes
a00ff7d
 
1e300a8
a00ff7d
 
1e300a8
a00ff7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1e300a8
a00ff7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from openai import AzureOpenAI
client = AzureOpenAI()

class SentimentAnalyzer:
    def __init__(self):
        pass

    def analyze_sentiment(self, text):
        conversation = [
          {"role": "system", "content": """You are a Sentiment Analyser.Your task is to analyze and predict the sentiment using scores. Sentiments are categorized into the following list: Positive,Negative,Neutral. You need to provide the sentiment with the highest score. The scores should be in the range of 0.0 to 1.0, where 1.0 represents the highest intensity of the emotion.
            Please analyze the text and provide the output in the following format: Sentiment: score [with one result having the highest score]."""},
          {"role": "user", "content": f"""
            input text{text}
            """}
            ]
        response = client.chat.completions.create(
            model="GPT-3",
            messages=conversation,
            temperature=1,
            max_tokens=60
        )

        message = response.choices[0].message.content

        return message
    def emotion_analysis(self,text):


        conversation = [
          {"role": "system", "content": """You are a Emotion Analyser.Your task is to analyze and predict the emotion using scores. Emotions are categorized into the following list: Sadness, Happiness, Joy, Fear, Disgust, and Anger. You need to provide the emotion with the highest score. The scores should be in the range of 0.0 to 1.0, where 1.0 represents the highest intensity of the emotion.
            Please analyze the text and provide the output in the following format: emotion: score [with one result having the highest score]."""},
          {"role": "user", "content": f"""
            input text{text}
            """}
            ]
        response = client.chat.completions.create(
            model="GPT-3",
            messages=conversation,
            temperature=1,
            max_tokens=60
        )

        message = response.choices[0].message.content

        return message




class Summarizer:

    def __init__(self):
        # self.client = OpenAI()
        pass

    def generate_summary(self, text):

        conversation = [
          {"role": "system", "content": "You are a Summarizer"},
          {"role": "user", "content": f"""summarize the following conversation delimited by triple backticks.

                     ```{text}```
            """}
            ]
        response = client.chat.completions.create(
            model="GPT-3",
            messages=conversation,
            temperature=1,
            max_tokens=500
        )

        message = response.choices[0].message.content
        return message