shnippi commited on
Commit
de72291
·
0 Parent(s):
Files changed (3) hide show
  1. README.md +13 -0
  2. app.py +90 -0
  3. requirements.txt +2 -0
README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Email Generai-tor
3
+ emoji: 🐨
4
+ colorFrom: green
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 3.17.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: other
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import json
4
+ import time
5
+ import requests
6
+
7
+ # Nosey fucker arent you :)
8
+
9
+ def email(linkedin_url, description_of_what_you_are_selling, description_of_who_you_are, type_of_email):
10
+
11
+ human_url = os.environ["HUMAN_URL"]
12
+ model_url = os.environ["MODEL_URL"]
13
+
14
+
15
+ data = {
16
+ "api_key": os.environ["HUMAN_API_KEY"],
17
+ "linkedin_url" : linkedin_url
18
+ }
19
+
20
+ headers = {
21
+ 'Cache-Control': 'no-cache',
22
+ 'Content-Type': 'application/json'
23
+ }
24
+
25
+ response = requests.request("POST", human_url, headers=headers, json=data)
26
+
27
+
28
+ resp= json.loads(response.text)
29
+
30
+ print(resp)
31
+ print("the email is: " + str(resp["person"]["email"]))
32
+
33
+
34
+ # summarize
35
+
36
+ headers = {
37
+ "Content-Type": "application/json",
38
+ "Authorization": "Bearer " + os.environ["MODEL_API_KEY"]
39
+ }
40
+
41
+ data = {
42
+ "model": os.environ["MODEL_NAME"],
43
+ "prompt": "summarize this json in a very detailed and readable paragraph describing the person. Dont include any ID or number combinations :" + str(resp),
44
+ "temperature": 0,
45
+ "max_tokens": 300
46
+ }
47
+
48
+ response = requests.post(model_url, headers=headers, json=data)
49
+
50
+ if response.status_code == 200:
51
+ response_json = response.json()
52
+ summary = response_json["choices"][0]["text"]
53
+ else:
54
+ print("Request failed with status code:", response.status_code)
55
+
56
+
57
+ # write the mail
58
+
59
+ data = {
60
+ "model": os.environ["MODEL_NAME"],
61
+ "prompt": "now write me a" + type_of_email + "cold outreach email to this person that is highly personalized with the following information: " + summary + " 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.",
62
+ "temperature": 0,
63
+ "max_tokens": 300
64
+ }
65
+
66
+ response = requests.post(model_url, headers=headers, json=data)
67
+
68
+ if response.status_code == 200:
69
+ response_json = response.json()
70
+ text = response_json["choices"][0]["text"]
71
+ print(text)
72
+ else:
73
+ print("Request failed with status code:", response.status_code)
74
+
75
+ return text
76
+
77
+ demo = gr.Interface(
78
+ email,
79
+ [
80
+ gr.Textbox(lines=1, label="LinkedIn URL"),
81
+ gr.Textbox(lines=1, label="Description of what you are selling (Name, Product, Service))"),
82
+ gr.Textbox(lines=1, label="Description of who you are (Name, Company, Position))"),
83
+ gr.Textbox(lines=1, label="(Optional) Describe the style of the email (funny, formal, short, long))"),
84
+ gr.Radio(["funny", "formal", "short", "long"], label="Type of Email")
85
+ ],
86
+ gr.Textbox(lines=15, placeholder="Name Here...", label="Output"),
87
+ title="Email Generai-tor",
88
+ description="From Linked in profile to personalized email in 1 click! If it doesnt work that means most likely that some API is bugging. For questions team@generai.art",
89
+ )
90
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio==3.18.0
2
+ requests==2.27.1