Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,10 +27,6 @@ def analyze_figure_of_speech(verse):
|
|
| 27 |
Bible Verse: "{verse}"
|
| 28 |
[/INST] Figures: </s>"""
|
| 29 |
|
| 30 |
-
# Print only the values
|
| 31 |
-
print("\n".join(str(value) for value in data.values() if value))
|
| 32 |
-
|
| 33 |
-
|
| 34 |
payload = {"inputs": prompt, "parameters": {"max_new_tokens": 250, "temperature": 0.5, "top_p": 0.9}}
|
| 35 |
|
| 36 |
try:
|
|
@@ -45,7 +41,11 @@ print("\n".join(str(value) for value in data.values() if value))
|
|
| 45 |
generated_text = generated_text.split(marker, 1)[1].strip()
|
| 46 |
try:
|
| 47 |
output_json = json.loads(generated_text)
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
except json.JSONDecodeError:
|
| 50 |
return generated_text
|
| 51 |
else:
|
|
@@ -60,7 +60,7 @@ demo = gr.Interface(
|
|
| 60 |
placeholder="e.g., 'I am the vine, you are the branches' - John 15:5",
|
| 61 |
lines=3
|
| 62 |
),
|
| 63 |
-
outputs=gr.Textbox(label="Figures of Speech Analysis
|
| 64 |
title="JR-Sacred Syntax: Bible Figures of Speech Detector",
|
| 65 |
description="Enter a Bible verse to detect and analyze figures of speech with detailed biblical explanations."
|
| 66 |
)
|
|
|
|
| 27 |
Bible Verse: "{verse}"
|
| 28 |
[/INST] Figures: </s>"""
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
payload = {"inputs": prompt, "parameters": {"max_new_tokens": 250, "temperature": 0.5, "top_p": 0.9}}
|
| 31 |
|
| 32 |
try:
|
|
|
|
| 41 |
generated_text = generated_text.split(marker, 1)[1].strip()
|
| 42 |
try:
|
| 43 |
output_json = json.loads(generated_text)
|
| 44 |
+
if isinstance(output_json, list): # Ensure it's a list
|
| 45 |
+
# Print only values, not keys
|
| 46 |
+
return "\n\n".join("\n".join(str(value) for value in item.values() if value) for item in output_json)
|
| 47 |
+
else:
|
| 48 |
+
return json.dumps(output_json, indent=2)
|
| 49 |
except json.JSONDecodeError:
|
| 50 |
return generated_text
|
| 51 |
else:
|
|
|
|
| 60 |
placeholder="e.g., 'I am the vine, you are the branches' - John 15:5",
|
| 61 |
lines=3
|
| 62 |
),
|
| 63 |
+
outputs=gr.Textbox(label="Figures of Speech Analysis"),
|
| 64 |
title="JR-Sacred Syntax: Bible Figures of Speech Detector",
|
| 65 |
description="Enter a Bible verse to detect and analyze figures of speech with detailed biblical explanations."
|
| 66 |
)
|