Thibault Goehringer commited on
Commit
36ad45e
·
1 Parent(s): ad45b04

Fix filename

Browse files
Files changed (2) hide show
  1. main.py +22 -4
  2. requirements.txrt → requirements.txt +0 -0
main.py CHANGED
@@ -1,7 +1,25 @@
1
- from fastapi import FastAPI
2
 
3
- app = FastAPI()
4
 
5
 
6
- def read_root():
7
- return {"Hello": "World!"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
 
3
+ openai.api_key = os.environ.get("openai_api_key")
4
 
5
 
6
+ _tweet = "I'm a pretty average middle aged guy, got a solid job and had a good family but things got messy and took " \
7
+ "a turn for the worst. Everyone says you need to hit rock bottom to go back up so here I am!"
8
+
9
+
10
+ def prompt(tweet, roast=True):
11
+ roast_or_toast = "snarky joke" if roast else "encouragement"
12
+ return f"A user tweeted this tweet:\n\n{tweet}\\n\nThe following {roast_or_toast} was given as an answer:"
13
+
14
+
15
+ response = openai.Completion.create(
16
+ engine="text-davinci-002",
17
+ prompt=prompt(_tweet, roast=False),
18
+ temperature=0.7,
19
+ max_tokens=60,
20
+ top_p=1,
21
+ frequency_penalty=0,
22
+ presence_penalty=0
23
+ )
24
+
25
+ print(response.choices[0].text.strip())
requirements.txrt → requirements.txt RENAMED
File without changes