app.py
CHANGED
@@ -4,11 +4,12 @@ import requests
|
|
4 |
# GPT-J-6B API
|
5 |
API_URL = "https://api-inference.huggingface.co/models/EleutherAI/gpt-j-6B"
|
6 |
|
7 |
-
examples = [["the roads are lovely dark and deep"], ["to be or not to be is the question, isn't it"], ["Elon Musk is not sure about "]]
|
8 |
|
9 |
|
10 |
def poem_generate(word):
|
11 |
-
prompt = """
|
|
|
12 |
poem using word: And then the day came,
|
13 |
when the risk
|
14 |
to remain tight
|
@@ -18,9 +19,9 @@ def poem_generate(word):
|
|
18 |
it took
|
19 |
to blossom.
|
20 |
|
21 |
-
word: """
|
22 |
-
|
23 |
prompt = prompt + word.lower() + "\n" + "poem using word: "
|
|
|
24 |
json_ = {"inputs": prompt,
|
25 |
"parameters":
|
26 |
{
|
@@ -31,6 +32,7 @@ def poem_generate(word):
|
|
31 |
}}
|
32 |
response = requests.post(API_URL, json=json_)
|
33 |
output = response.json()
|
|
|
34 |
poem = output[0]['generated_text'].split("\n\n")[0] # +"."
|
35 |
|
36 |
return poem
|
|
|
4 |
# GPT-J-6B API
|
5 |
API_URL = "https://api-inference.huggingface.co/models/EleutherAI/gpt-j-6B"
|
6 |
|
7 |
+
#examples = [["the roads are lovely dark and deep"], ["to be or not to be is the question, isn't it"], ["Elon Musk is not sure about "]]
|
8 |
|
9 |
|
10 |
def poem_generate(word):
|
11 |
+
prompt = """
|
12 |
+
word: risk
|
13 |
poem using word: And then the day came,
|
14 |
when the risk
|
15 |
to remain tight
|
|
|
19 |
it took
|
20 |
to blossom.
|
21 |
|
22 |
+
word: """
|
|
|
23 |
prompt = prompt + word.lower() + "\n" + "poem using word: "
|
24 |
+
print(f"Prompt is :{prompt}")
|
25 |
json_ = {"inputs": prompt,
|
26 |
"parameters":
|
27 |
{
|
|
|
32 |
}}
|
33 |
response = requests.post(API_URL, json=json_)
|
34 |
output = response.json()
|
35 |
+
print(f"Poem without splits is: {output[0]['generated_text']}")
|
36 |
poem = output[0]['generated_text'].split("\n\n")[0] # +"."
|
37 |
|
38 |
return poem
|