Spaces:
Runtime error
Runtime error
app.py
CHANGED
|
@@ -64,23 +64,23 @@ def poem_generate(word):
|
|
| 64 |
"return_full_text": False
|
| 65 |
}}
|
| 66 |
response = requests.post(API_URL, headers=headers, json=json_)
|
| 67 |
-
output = response.json()
|
| 68 |
-
print(f"If there was an error? Reason is : {output}")
|
| 69 |
-
output_tmp = output[0]['generated_text']
|
| 70 |
-
print(f"GPTJ response without splits is: {output_tmp}")
|
| 71 |
-
|
| 72 |
-
if "\n\n" not in output_tmp:
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
else:
|
| 80 |
-
|
| 81 |
-
poem = poem.replace('?','')
|
| 82 |
#print(f"Poem being returned is: {poem}")
|
| 83 |
-
return output_tmp #poem
|
| 84 |
|
| 85 |
def poem_to_image(poem):
|
| 86 |
print("*****Inside Poem_to_image")
|
|
|
|
| 64 |
"return_full_text": False
|
| 65 |
}}
|
| 66 |
response = requests.post(API_URL, headers=headers, json=json_)
|
| 67 |
+
#output = response.json()
|
| 68 |
+
print(f"If there was an error? Reason is : {response}") #{output}")
|
| 69 |
+
#output_tmp = output[0]['generated_text']
|
| 70 |
+
#print(f"GPTJ response without splits is: {output_tmp}")
|
| 71 |
+
poem = output[0]['generated_text'].split("\n\n")[0] # +"."
|
| 72 |
+
#if "\n\n" not in output_tmp:
|
| 73 |
+
# if output_tmp.find('.') != -1:
|
| 74 |
+
# idx = output_tmp.find('.')
|
| 75 |
+
# poem = output_tmp[:idx+1]
|
| 76 |
+
# else:
|
| 77 |
+
# idx = output_tmp.rfind('\n')
|
| 78 |
+
# poem = output_tmp[:idx]
|
| 79 |
+
#else:
|
| 80 |
+
# poem = output_tmp.split("\n\n")[0] # +"."
|
| 81 |
+
#poem = poem.replace('?','')
|
| 82 |
#print(f"Poem being returned is: {poem}")
|
| 83 |
+
return response #output_tmp #poem
|
| 84 |
|
| 85 |
def poem_to_image(poem):
|
| 86 |
print("*****Inside Poem_to_image")
|