File size: 3,868 Bytes
de72291
 
 
 
 
 
 
 
3b7c94e
de72291
 
 
3b7c94e
 
7eb60c4
3b7c94e
 
de72291
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed8fa7a
fc456e0
 
ed8fa7a
33a6b97
ed8fa7a
 
de72291
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a5d769d
de72291
 
 
 
8c88d14
fbe93da
 
9b80b15
fbe93da
de72291
 
fbe93da
de72291
 
 
 
 
 
 
 
 
 
 
 
a5d769d
de72291
734f3cc
de72291
 
 
 
 
 
 
 
fbe93da
de72291
 
960ceba
 
de72291
 
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
import gradio as gr
import os
import json
import time
import requests

# Nosey fucker arent you :)

def email(linkedin_url, description_of_what_you_are_selling , description_of_who_you_are , type_of_email = "", calendly_link = ""):

    human_url = os.environ["HUMAN_URL"]
    model_url = os.environ["MODEL_URL"]
    
    if description_of_what_you_are_selling == "":
        description_of_what_you_are_selling = "Generai, a YCombinator startup building a flowchart tool to build ML aplications"
    if description_of_who_you_are == "":
        description_of_who_you_are = "Jan Schnyder, Co-Founder of Generai"


    data = {
        "api_key": os.environ["HUMAN_API_KEY"],
        "linkedin_url" : linkedin_url
    }

    headers = {
        'Cache-Control': 'no-cache',
        'Content-Type': 'application/json'
    }

    response = requests.request("POST", human_url, headers=headers, json=data)
    resp= json.loads(response.text)

    print(resp)
    print("the email is: " + str(resp["person"]["email"]))


    email_address = str(resp["person"]["email"])

    # shorten the json if too long, otherwise 400 for openai
    if len(str(resp)) > 8000:
        resp = str(resp)[0:8000]


    # summarize

    headers = {
        "Content-Type": "application/json",
        "Authorization": "Bearer " + os.environ["MODEL_API_KEY"]
    }

    data = {
        "model": os.environ["MODEL_NAME"],
        "prompt": "summarize this json in a very detailed and readable paragraph describing the person. Dont include any ID or number combinations :" + str(resp),
        "temperature": 0,
        "max_tokens": 300
    }

    response = requests.post(model_url, headers=headers, json=data)

    if response.status_code == 200:
        response_json = response.json()
        summary = response_json["choices"][0]["text"]
    else:
        print("Request failed with status code:", response.status_code)
        return "Request failed with status code:", response.status_code

    
    # write the mail

    prompt = "now write me a " + type_of_email + " cold outreach email to this person that is highly personalized with the following information: " + summary + ". \n The email should be about selling " + description_of_what_you_are_selling + "The email is from " + description_of_who_you_are + " . Don't use placeholders. "

    if calendly_link != "":
        prompt = prompt + "The person can schedule a call here: " + str(calendly_link)

    data = {
        "model": os.environ["MODEL_NAME"],
        "prompt": prompt,
        "temperature": 0,
        "max_tokens": 300
    }

    response = requests.post(model_url, headers=headers, json=data)

    if response.status_code == 200:
        response_json = response.json()
        text = response_json["choices"][0]["text"]
        print(text)
    else:
        print("Request failed with status code:", response.status_code)
        return "Request failed with status code:", response.status_code
    
    return "email address: \n" + email_address +  " \n\n" + text + " \n\n- " + "P.S: This email was generated using our tool ;) , built with " + "https://flow.generai.art/"

demo = gr.Interface(
    email,
    [
        gr.Textbox(lines=1, label="LinkedIn URL"),
        gr.Textbox(lines=1, label="Description of what you are selling (Name, Product, Service))"),
        gr.Textbox(lines=1, label="Description of who you are (Name, Company, Position))"),
        gr.Textbox(lines=1, label="(Optional) Describe the style of the email (funny, formal, short, long))"),
        gr.Textbox(lines=1, label="(Optional) Add your Calendly link here")
    ],
    gr.Textbox(lines=15, placeholder="Name Here...", label="Output"),
    title="LinkedIn Email Generai-tor",
    description="From Linked in profile to personalized email in 1 click! API might be down sometimes. For questions team@generai.art",
)
demo.launch()