Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -84,8 +84,6 @@ class Website:
|
|
| 84 |
def get_contents(self):
|
| 85 |
return f"Webpage Title:\n{self.title}\nWebpage Contents:\n{self.text}\n\n"
|
| 86 |
|
| 87 |
-
# ted = Website("https://invoice.2go.com")
|
| 88 |
-
# ted.links
|
| 89 |
|
| 90 |
link_system_prompted = "You are to choose the links that are relevant in terms of marketing in this website and then \
|
| 91 |
and then you are to follow through with picking them out. Do not choose privacy link, and anyother irrelevant ones\n"
|
|
@@ -93,7 +91,7 @@ link_system_prompted += "Respond in Json"
|
|
| 93 |
link_system_prompted += """Follow this example \
|
| 94 |
"links ={type: about us : "https://something/somethinhg"}"""
|
| 95 |
|
| 96 |
-
|
| 97 |
|
| 98 |
def link_user_prompted(website):
|
| 99 |
User_prompter = f"I would like to know the relevant link in the {website.url} - "
|
|
@@ -101,7 +99,7 @@ def link_user_prompted(website):
|
|
| 101 |
User_prompter += "\n" .join(website.links)
|
| 102 |
return User_prompter
|
| 103 |
|
| 104 |
-
|
| 105 |
|
| 106 |
def get_stuff(Url):
|
| 107 |
website = Website.url
|
|
@@ -116,18 +114,12 @@ def get_stuff(Url):
|
|
| 116 |
result = response.choices[0].message.content
|
| 117 |
return json.loads(result)
|
| 118 |
|
| 119 |
-
|
| 120 |
-
# ed.links
|
| 121 |
|
| 122 |
"""## First step: Have GPT-4o-mini figure out which links are relevant
|
| 123 |
|
| 124 |
-
### Use a call to gpt-4o-mini to read the links on a webpage, and respond in structured JSON.
|
| 125 |
-
It should decide which links are relevant, and replace relative links such as "/about" with "https://company.com/about".
|
| 126 |
-
We will use "one shot prompting" in which we provide an example of how it should respond in the prompt.
|
| 127 |
|
| 128 |
-
This is an excellent use case for an LLM, because it requires nuanced understanding. Imagine trying to code this without LLMs by parsing and analyzing the webpage - it would be very hard!
|
| 129 |
|
| 130 |
-
Sidenote: there is a more advanced technique called "Structured Outputs" in which we require the model to respond according to a spec. We cover this technique in Week 8 during our autonomous Agentic AI project.
|
| 131 |
"""
|
| 132 |
|
| 133 |
link_system_prompt = "You are provided with a list of links found on a webpage. \
|
|
@@ -153,7 +145,7 @@ Do not include Terms of Service, Privacy, email links.\n"
|
|
| 153 |
user_prompt += "\n".join(website.links)
|
| 154 |
return user_prompt
|
| 155 |
|
| 156 |
-
|
| 157 |
|
| 158 |
def get_links(url):
|
| 159 |
website = Website(url)
|
|
@@ -170,11 +162,6 @@ def get_links(url):
|
|
| 170 |
|
| 171 |
# sample
|
| 172 |
|
| 173 |
-
Diamondadverts = Website("https://diamondadverts.com")
|
| 174 |
-
Diamondadverts.links
|
| 175 |
-
|
| 176 |
-
get_links("https://squeakycleaningservices.co.uk")
|
| 177 |
-
|
| 178 |
|
| 179 |
|
| 180 |
"""## Second step: make the pitch deck!
|
|
@@ -192,7 +179,8 @@ def get_all_details(url):
|
|
| 192 |
result += Website(link["url"]).get_contents()
|
| 193 |
return result
|
| 194 |
|
| 195 |
-
|
|
|
|
| 196 |
|
| 197 |
# system_prompt = "You are an assistant that analyzes the contents of several relevant pages from a company website \
|
| 198 |
# and creates a short pitch deck for the company, so the comapany can use it to apply for mor jobs and clients, investors and recruits. Respond in markdown.\
|
|
@@ -220,6 +208,8 @@ Focus on creating a narrative that highlights the company's strengths, unique po
|
|
| 220 |
# and creates a short humorous, entertaining, jokey brochure about the company for prospective customers, investors and recruits. Respond in markdown.\
|
| 221 |
# Include details of company culture, customers and careers/jobs if you have the information."
|
| 222 |
|
|
|
|
|
|
|
| 223 |
def get_pitch_user_prompt(company_name, url):
|
| 224 |
user_prompt = f"You are looking at a company called: {company_name}\n"
|
| 225 |
user_prompt += f"Here are the contents of its landing page and other relevant pages; use this information to build a short pitch deck for the company, of the company in markdown.\n"
|
|
@@ -240,7 +230,7 @@ def pitch_deck(company_name, url):
|
|
| 240 |
result = response.choices[0].message.content
|
| 241 |
display(Markdown(result))
|
| 242 |
|
| 243 |
-
|
| 244 |
|
| 245 |
"""## Finally - a minor improvement
|
| 246 |
|
|
|
|
| 84 |
def get_contents(self):
|
| 85 |
return f"Webpage Title:\n{self.title}\nWebpage Contents:\n{self.text}\n\n"
|
| 86 |
|
|
|
|
|
|
|
| 87 |
|
| 88 |
link_system_prompted = "You are to choose the links that are relevant in terms of marketing in this website and then \
|
| 89 |
and then you are to follow through with picking them out. Do not choose privacy link, and anyother irrelevant ones\n"
|
|
|
|
| 91 |
link_system_prompted += """Follow this example \
|
| 92 |
"links ={type: about us : "https://something/somethinhg"}"""
|
| 93 |
|
| 94 |
+
|
| 95 |
|
| 96 |
def link_user_prompted(website):
|
| 97 |
User_prompter = f"I would like to know the relevant link in the {website.url} - "
|
|
|
|
| 99 |
User_prompter += "\n" .join(website.links)
|
| 100 |
return User_prompter
|
| 101 |
|
| 102 |
+
|
| 103 |
|
| 104 |
def get_stuff(Url):
|
| 105 |
website = Website.url
|
|
|
|
| 114 |
result = response.choices[0].message.content
|
| 115 |
return json.loads(result)
|
| 116 |
|
| 117 |
+
|
|
|
|
| 118 |
|
| 119 |
"""## First step: Have GPT-4o-mini figure out which links are relevant
|
| 120 |
|
|
|
|
|
|
|
|
|
|
| 121 |
|
|
|
|
| 122 |
|
|
|
|
| 123 |
"""
|
| 124 |
|
| 125 |
link_system_prompt = "You are provided with a list of links found on a webpage. \
|
|
|
|
| 145 |
user_prompt += "\n".join(website.links)
|
| 146 |
return user_prompt
|
| 147 |
|
| 148 |
+
|
| 149 |
|
| 150 |
def get_links(url):
|
| 151 |
website = Website(url)
|
|
|
|
| 162 |
|
| 163 |
# sample
|
| 164 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
|
| 167 |
"""## Second step: make the pitch deck!
|
|
|
|
| 179 |
result += Website(link["url"]).get_contents()
|
| 180 |
return result
|
| 181 |
|
| 182 |
+
|
| 183 |
+
## system prompt updates
|
| 184 |
|
| 185 |
# system_prompt = "You are an assistant that analyzes the contents of several relevant pages from a company website \
|
| 186 |
# and creates a short pitch deck for the company, so the comapany can use it to apply for mor jobs and clients, investors and recruits. Respond in markdown.\
|
|
|
|
| 208 |
# and creates a short humorous, entertaining, jokey brochure about the company for prospective customers, investors and recruits. Respond in markdown.\
|
| 209 |
# Include details of company culture, customers and careers/jobs if you have the information."
|
| 210 |
|
| 211 |
+
#end
|
| 212 |
+
|
| 213 |
def get_pitch_user_prompt(company_name, url):
|
| 214 |
user_prompt = f"You are looking at a company called: {company_name}\n"
|
| 215 |
user_prompt += f"Here are the contents of its landing page and other relevant pages; use this information to build a short pitch deck for the company, of the company in markdown.\n"
|
|
|
|
| 230 |
result = response.choices[0].message.content
|
| 231 |
display(Markdown(result))
|
| 232 |
|
| 233 |
+
|
| 234 |
|
| 235 |
"""## Finally - a minor improvement
|
| 236 |
|