File size: 2,470 Bytes
d2f12bd
 
 
94b4765
d2f12bd
 
 
b9a1d0e
d2f12bd
 
 
b9a1d0e
 
d2f12bd
 
 
b9a1d0e
 
 
 
 
d2f12bd
b9a1d0e
d2f12bd
b9a1d0e
d2f12bd
b9a1d0e
d2f12bd
b9a1d0e
d2f12bd
b9a1d0e
d2f12bd
b9a1d0e
d2f12bd
b9a1d0e
d2f12bd
b9a1d0e
 
 
 
 
 
d2f12bd
b9a1d0e
d2f12bd
 
b9a1d0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d2f12bd
 
b9a1d0e
 
 
 
 
d2f12bd
 
94b4765
 
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
import openai
import os
from dotenv import load_dotenv
import streamlit as st

load_dotenv()
openai.api_key = os.getenv("OPENAI_API_KEY")


function_descriptions = [
    {
        "name": "extract_info_from_email",
        "description": "categorise & extract key info from an email, such as use case, company name, contact details, etc.",
        "parameters": {
            "type": "object",
            "properties": {
                "companyName": {
                    "type": "string",
                    "description": "the name of the company that sent the email"
                },                                        
                "product": {
                    "type": "string",
                    "description": "Try to identify which product the client is interested in, if any"
                },
                "amount":{
                    "type": "string",
                    "description": "Try to identify the amount of products the client wants to purchase, if any"
                },
                "category": {
                    "type": "string",
                    "description": "Try to categorise this email into categories like those: 1. Sales 2. customer support; 3. consulting; 4. partnership; etc."
                },
                "nextStep":{
                    "type": "string",
                    "description": "What is the suggested next step to move this forward?"
                },
                "priority": {
                    "type": "string",
                    "description": "Try to give a priority score to this email based on how likely this email will leads to a good business opportunity, from 0 to 10; 10 most important"
                },
            },
            "required": ["companyName", "amount", "product", "priority", "category", "nextStep"]
        }
    }
]

email = """
Dear Jason 
I hope this message finds you well. I'm Shirley from Gucci;

I'm looking to purchase some company T-shirt for my team, we are a team of 100k people, and we want to get 2 t-shirt per personl

Please let me know the price and timeline you can work with;

Looking forward

Shirley Lou
"""

prompt = f"Please extract key information from this email: {email} "
message = [{"role": "user", "content": prompt}]

response = openai.ChatCompletion.create(
    model="gpt-3.5-turbo",
    messages=message,
    functions = function_descriptions,
    function_call="auto"
)

print(response)

st.header(response)