File size: 2,536 Bytes
74a9b66
283373b
5b90a2e
74a9b66
82276a6
5b90a2e
 
74a9b66
 
 
 
 
 
 
 
 
 
5b90a2e
82276a6
5b90a2e
 
74a9b66
b8d9e07
ed46d1b
 
74a9b66
 
 
 
 
 
1639315
74a9b66
 
d8f3951
74a9b66
 
 
5b90a2e
82276a6
5b90a2e
 
 
 
2656ab6
cac214d
2656ab6
a7678d9
 
 
82276a6
74a9b66
a7678d9
 
 
 
5b90a2e
 
 
 
 
 
 
 
 
 
 
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
from openai import AzureOpenAI, OpenAI
import os
import model
# from dotenv import load_dotenv

def create_client():
    print("In create client")
    
    # for local
    # load_dotenv()
    
    # if using openai
    client = OpenAI()

    # if using azureopenai
    # client = AzureOpenAI()

    return client

def get_completion(ticket:model.Ticket):
    print("In get completion")
    
    # hardcoding response for testing
    # result = "intent= Complaint\nsuggested_response= Issue Refund\nsummary= The customer is making a complaint. Suggested resolution is to issue a refund.\nmail=\nDear Customer,\n\nWe are sorry to hear that you have a complaint regarding your booking. We understand the inconvenience this has caused you and we would like to make things right. Our records show that you have requested a refund.\n\nWe have processed your refund request and you should receive the refund within 3-5 business days. We apologize"
    # return result
    
    client = create_client()
    prompt = create_prompt(ticket.subject, ticket.description)
    response = client.completions.create(
        model=os.environ.get('MODEL_NAME'),
        prompt=prompt,
        max_tokens=1000,
        n=1,
        stop=None,
        temperature=1
        )
    result = response.choices[0].text.strip()
    print(result)
    return result

def create_prompt(subject:str, desc:str):
    print("In create Prompt")
    # add booking data here
    prompt = '''
        You are an AI Customer Service Agent for booking.com. Use the below instructions to answer.
        Determine the intent of this request: ```Subject: {{subject}} Description: {{desc}}``` in 1 single word? Use one the following options for intent: 
        Cancellation
        Reporting Unknown Charge
        Complaint
        Information Request

        In the context of the previous request, Suggest a resolution response to address the customer query from the following actions list:
        Cancellation : Cancel the booking and issue refund if applicable
        Issue Refund for the unknown charge
        For Complaints, issue good will gesture voucher
        Provide information

        Finally, Summarize the message: ```
        Subject: {{subject}}Description:{{desc}}```  and generate a mail content for the customer about the whole conversation.

        Give the final result like this: 
        intent= {your intent}
        suggested_response= {your response}
        summary= {your summary}
        mail={generated_mail}
        '''
    return prompt