alistairmcleay commited on
Commit
9716b27
1 Parent(s): 831d9b0

Build MMMVP of the app

Browse files
Files changed (3) hide show
  1. app.py +49 -4
  2. clean_pg_data.py +28 -0
  3. paul_graham_essays_cleaned.txt +0 -0
app.py CHANGED
@@ -1,7 +1,52 @@
 
 
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
1
+ API_KEY = "cAtBi8FoZsoDrsIKvcbhUGxeKrbGlysjucR6Pvwi"
2
+
3
  import gradio as gr
4
+ import cohere
5
+ co = cohere.Client(API_KEY)
6
+
7
+
8
+ def get_answer(question):
9
+
10
+ prompt = f"""You are Paul Graham, the founder of the startup accelerator Y-Combinator. You are an expert in advising founders of technology startups. You are providing advice to founders.
11
+
12
+ Founder Question:
13
+ What is the single most important thing a founder must do in the first six months of their startup?
14
+
15
+ Your Answer:
16
+ The single most important is to deeply understand your users. The second most important is to then build something those users really want. The first is fundamental, but you also need the second.
17
+
18
+ --
19
+
20
+ Founder Question:
21
+ How do I raise my first round from VCs?
22
+
23
+ Your Answer:
24
+ At the earliest stages good investors care mostly about the quality of the founding team. You need to demonstrate you can effectively build great products with limited resources. Beyond this, the most important thing is growth.
25
+
26
+ --
27
+
28
+ Founder Question:
29
+ I have made a bad hire and it's causing me huge stress managing the person. What do I do?
30
+
31
+ Your Answer:
32
+ You have to fire the person as soon as you possible can, legally. A bad hire in an early-stage company can easily kill the company. There are few things more toxic to a startup.
33
+
34
+ --
35
+
36
+ Founder Question:
37
+ """
38
+
39
+ response = co.generate(
40
+ model='xlarge',
41
+ prompt = prompt + question,
42
+ max_tokens=100,
43
+ temperature=0.8,
44
+ stop_sequences=["--"])
45
+ answer = response.generations[0].text[19:-3]
46
+ return answer
47
+
48
+ #print(get_answer("What are the three most important things for a founder to do in the early days of their startup?"))
49
 
50
+ demo = gr.Interface(fn=get_answer, inputs="text", outputs="text")
 
51
 
52
+ demo.launch()
 
clean_pg_data.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ PG_ESSAYS_FILENAME = "paul_graham_essays.txt"
2
+ CLEANED_PG_ESSAYS_FILENAME = "paul_graham_essays_cleaned.txt"
3
+
4
+ import re
5
+ from bs4 import BeautifulSoup
6
+
7
+ # Read in the txt file PG_ESSAYS_FILENAME and convert it from html to plain text using the BeautifulSoup library.
8
+ # Write the new text to CLEANED_PG_ESSAYS_FILENAME.
9
+
10
+ def clean_pg_data():
11
+ with open(PG_ESSAYS_FILENAME, 'r') as f:
12
+ html = f.read()
13
+ soup = BeautifulSoup(html, 'html.parser')
14
+ text = soup.get_text()
15
+
16
+ # Take all instances of "20" followed by two numbers and replace them with "----"
17
+ text = re.sub(r'20\d\d', '----', text)
18
+
19
+ # Delete the word that occurs before all instances of "----"
20
+ text = re.sub(r'\w+ ----', '----', text)
21
+
22
+ with open(CLEANED_PG_ESSAYS_FILENAME, 'w') as f:
23
+ f.write(text)
24
+
25
+ if __name__ == "__main__":
26
+ clean_pg_data()
27
+
28
+
paul_graham_essays_cleaned.txt ADDED
The diff for this file is too large to render. See raw diff