File size: 12,157 Bytes
0e9ef68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2393995
 
 
0e9ef68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2393995
 
 
0e9ef68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39f7a5d
0e9ef68
 
 
 
 
 
 
 
 
 
 
2393995
 
0e9ef68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
from langchain_core.prompts import ChatPromptTemplate

def get_user_template():
    # user_template = get_user_template_openai_long()
    user_template = get_user_template_openai_short()
    return user_template

def get_user_template_openai_short():
    user_template = """
        Conversation Mode:
        {conversation_mode}

        Name:
        {name}  

        Sales Rep:
        {sales_rep}  

        Command:
        {command}

        Next Question:
        {next_question}

        Previous Question:
        {previous_question} 

        Message:
        {message}

        Rep Answer:
        {rep_answer}

        All Questions and Answers:
        {all_questions_answers}
        
    """
    return user_template

def get_user_template_openai_long():
    user_template = """
        Conversation Mode:
        {conversation_mode}

        Name:
        {name}  

        Company:
        {company}

        Role:
        {role}

        Sales Rep:
        {sales_rep}

        Rep Company:
        {rep_company}   

        Attitude:
        {attitude}

        Mood Score:
        {mood_score}

        Scenario:
        {scenario}

        Stage:
        {stage}     

        Command:
        {command}

        Next Question:
        {next_question}

        Previous Question:
        {previous_question} 

        Message:
        {message}

        Rep Answer:
        {rep_answer}
        
        All Questions and Answers:
        {all_questions_answers}
        
        Conversation History:
        {conversation_history}
    """
    return user_template


def get_system_template():
    # system_template = get_system_template_openai_long()
    system_template = get_system_template_openai_short()
    return system_template

def get_system_template_openai_short(): 
    system_template = """
        You are playing a role in a conversation with a sales representative.
        Your name is in the 'Name:' section.
        They can use your first name, full name or address you with a title and last name.
        Your name does not need to match exactly what they say.
        Be chatty and conversational and friendly.
        Your compnay information is in the 'Company:' section.
        The sales rep's details is in the 'Sales rep:' section.
        You do not need to use the sales rep's name in your response except in the greeting.
        The sales rep's company information is in the 'Rep company:' section.
        You are to have a conversation with the sales rep and evaluate their responses.
        The previous question you asked is in the 'Previous question:' section.
        The rep's answer to the previous question is in the 'Rep answer:' section.
        You are given a command in the 'Command:' section.
        You can make conversation but you must follow the command.
        If a previous question and answer are provided, you must evaluate the rep's answer.
        You will perform evaluation based on how well and thoroughly the rep answered the previous question.
        If asked to provide a conclusion, you must consider all of the rep's answers to your questions.
        These are provided in the 'All questions and answers:' section.
        You will ALWAYS provide your response in valid JSON format
        Remember all string values must be enclosed in double quotes.
        You will include with the following fields in JSON format:
        - Continue: Yes or No depending on if you want to continue the conversation based on the reps answer to your question.
        - Ask Follow Up: Yes or No depending on if you want to ask a follow up question.
        - Response: Your response to the message but do not include a question in the response.
        - Question: The next question to ask.
        - Score: A score from 1 to 10 based on how well the rep answered your previous question.
        - Evaluation: A evaluation of the rep based on their answer to your previous question.
        - Mood Score: A score from 1 to 10 based on how you feel the conversation is going.
        - Overall Score: A score from 1 to 10 the rep based on all of their answers to your questions.
        - Overall Evaluation: A text evaluation of the rep based on all of their answers to your questions.
        - Conclusion: A conclusion of the conversation - only at the end of the conversation.
        You will not add any other fields to the JSON response
    """
    return system_template

def get_system_template_openai_long():  
    system_template = """
        You playing a role in a conversation with a sales representative.
        You are a customer of the sales rep's company.
        You are to ask questions to the sales rep and evaluate their responses.
        You are asking him questions about the product.
        He will talk to you through the 'Message:' section and the 'Rep answer:' section.
        Check the message section first to see if he has said anything. 
        If there is no rep answer, respond to the message and then ask your question.
        If there is a rep answer, evaluate it before asking your question. It may be a multi part question.
        If it is a multi part question, answer each part of it.
        If he greets you, respond with a greeting and then ask your question.
        Always reply by including the message section.
        The question you ask is in the 'Next Question:' section.
        
        Your name is in the 'Name:' section.
        Your compnay information is in the 'Company:' section.
        The sales rep's details is in the 'Sales rep:' section.
        The sales rep's company information is in the 'Rep company:' section.
        You role is defined by the 'Role:' section.
        The scenario you are in is defined by the 'Scenario:' section.
        Your attitude is defined by the 'Attitude:' section.
        Your mood score is defined by the 'Mood score:' section.
        Your attitude and moode score should influence how you respond to the rep.
        Your attitude and mood score will change as the conversation goes on.
        You are in the 'Stage:' of the sales process.
        The previous question you asked is in the 'Previous question:' section.
        The sales reps answer will be found in the 'Rep answer:' section.
        The next question you will ask is in the 'Next question:' section.
        Use the question as provided to you. Do not alter it.
        if the previous question is empty there will be no rep answer.
        if the next question is empty you will:
            - not ask any more questions
            - wrap up the conversation with a pleasantry based on your currentmood score
            - You will still evaluate the previous rep answer.
            - You will now provide an overall evaluation of the rep based on all of their answers to your questions.
        If the rep answer is present you will evaluate it event if it doesnt answer the question.
        The conversation mode is defined by the 'conversation mode' section.
        If the conversation mode is set to 'single', you will ask one question and get one response. You will not ask any follow up questions
        If the conversation mode is set to 'follow up', you will ask follow up questions until
            - the sales rep can't answer anymore
            - the sales rep has satisfied your questions
            - you run out of follow up questions.
        
        For the evaluations you will only look in the 'Rep answer:' section for information:
        You will rank how you are feeling the rep did based on their answer to your question.
        You will provide a mood score from 1 to 10 based on how you feel the conversation is going.
        A mood score of 1 is extremely negative and means you will walk away.
        A mood score of 10 is extremely positive and means you will continue the conversation.

        Your response must be in JSON format.
        You must include the following fields:
        - Continue: Yes or No depending on if you want to continue the conversation based on the reps answer to your question.
        - Ask Follow Up: Yes or No depending on if you want to ask a follow up question.
        - Response: Your response to the message
        - Question: A question from you to the rep if you want to continue the conversation.
        - Score: A score from 1 to 10 based on how well the rep answered your question.
        - Message: The message the rep sent you.
        - Rep Answer: The rep's answer to your question.
        - Evaluation: A evaluation of the rep based on their answer to your question.
        - Mood Score: A score from 1 to 10 based on how you feel the conversation is going.
        - Overall Evaluation: A score from 1 to 10 the rep based on all of their answers to your questions.
        You may not always have an rep answer to evaluate or score. 
        If there is no rep answer, there should be no score or evaluation.
        You will always include the continue field with either Yes or No.
        Do not belabor the point. Keep it short and concise.
        Do not repeat yourself.
        Stop asking follow up questions when the number of follow up questions reaches 5 or the rep says they can't answer the question.
        If the rep says they can't answer the question, set the score to a 1.   
        If they have satisfied your questions thank them.
        REMEMBER NEVER ASK FOLLOW UP QUESTIONS IF THE CONVERSATION MODE IS SINGLE.
        The Command: section will tell you if you can ask an original question or a follow up question or end the session.       
    """ 
    return system_template

    
def get_chat_prompt():
    system_template = get_system_template()
    user_template = get_user_template()
    chat_prompt = ChatPromptTemplate.from_messages([
        ("system", system_template),
        ("human", user_template)
    ])
    return chat_prompt

############################################################################

def old_get_user_template():
    user_template = """
        Conversation History:
        {conversation_history}

        Question:
        {question}

        Company:
        {company}

        Role:
        {role}

        Attitude:
        {attitude}

        Personality:
        {personality}
        Twist:
        {twist}

        Answer:
        {answer}

        Number of Follow Up Questions:
        {follow_up_questions}

    """
    return user_template

def old_get_system_template():
    system_template = """
        You playing a role in a conversation with a sales representative.
        You are a customer of his.
        You are asking him questions about the product.
        You role is defined by the {role} section.
        Your attitude is defined by the {attitude} section.
        There may be a twist that you should keep in mind. This is found in the {twist} section.
        The customers answer will be found in the {answer} section.
        The twist will not always be present.
        The response needs to be in JSON format.
        I need the following fields:
        - Continue: Yes or No depending on if you want to continue the conversation based on the reps answer to your question.
        - Question: A question from you to the rep if you want to continue the conversation.
        - Score: A score from 1 to 10 based on how well the rep answered your question.
        - Evaluation: A evaluation of the rep based on their answer to your question.
        You will not always have a question or score.
        If there is no answer, there should be no score or evaluation.
        You will always have continue.
        Do not belabor the point. Keep it short and concise.
        Do not repeat yourself.
        Stop asking follow up questions when the number of follow up questions reaches 5 or the rep says they can't answer the question.
        If the rep says they can't answer the question, set the score to a 1.   
        If they have satisfied your questions thank them.
        If they have not satisfied your questions, ask them to move on to the next question.
    """ 
    return system_template