Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,44 +19,20 @@ HEADERS = {"Authorization": f"Bearer {api_token}"}
|
|
19 |
|
20 |
def generate_exegesis(passage):
|
21 |
if not passage.strip():
|
22 |
-
return "Please enter a
|
23 |
-
|
24 |
-
prompt =
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
Perform a **detailed exegesis** of the following biblical passage:
|
29 |
-
**"{passage}"**
|
30 |
-
|
31 |
-
Your response should include:
|
32 |
-
|
33 |
-
1. **Original Language Analysis** – Provide the **Greek (NT) or Hebrew (OT) text**, """
|
34 |
-
f"""including **transliteration** and word-by-word breakdown.
|
35 |
-
2. **Lexical Insights** – Explain key words using sources like **Strong’s Concordance, """
|
36 |
-
f"""Thayer’s Lexicon, and BDB**.
|
37 |
-
3. **Historical & Cultural Context** – Discuss the passage’s background, audience, and setting.
|
38 |
-
4. **Literary & Thematic Analysis** – Examine the passage’s **grammatical structure, literary form, """
|
39 |
-
f"""and theological themes**.
|
40 |
-
5. **Theological Significance** – Explain how the passage contributes to **Christian doctrine** """
|
41 |
-
f"""and biblical theology.
|
42 |
-
6. **Cross-References** – List related biblical passages that provide deeper understanding.
|
43 |
-
7. **Interpretative Views** – Present differing theological interpretations if applicable.
|
44 |
-
8. **Practical Application** – Explain how this passage applies to faith and Christian living.
|
45 |
-
|
46 |
-
Your response should be **deeply analytical, theologically sound, and easy to understand**, """
|
47 |
-
f"""drawing from **scholarly sources and traditional interpretations**. [/INST]
|
48 |
-
response = requests.post(API_URL, headers=HEADERS, json=payload, timeout=10)
|
49 |
-
### Exegesis:</s>"""
|
50 |
-
)
|
51 |
|
52 |
payload = {
|
53 |
"inputs": prompt,
|
54 |
}
|
55 |
try:
|
56 |
-
response = requests.post(API_URL, headers=HEADERS, json=payload
|
57 |
response.raise_for_status()
|
58 |
result = response.json()
|
59 |
-
logger.debug("API Response
|
60 |
|
61 |
if isinstance(result, list) and len(result) > 0:
|
62 |
generated_text = result[0].get("generated_text", "")
|
@@ -67,40 +43,22 @@ Your response should be **deeply analytical, theologically sound, and easy to un
|
|
67 |
else:
|
68 |
return "Error: Unexpected response format."
|
69 |
except requests.exceptions.RequestException as e:
|
70 |
-
|
71 |
-
return "An error occurred while processing your request. Please try again later."
|
72 |
|
73 |
def ask_any_questions(question):
|
74 |
-
prompt =
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
Provide a **detailed and well-researched answer** to the following question:
|
79 |
-
**"{question}"**
|
80 |
-
|
81 |
-
Your response should include:
|
82 |
-
|
83 |
-
1. **Relevant Bible Passages** – Cite key Scriptures that address the question.
|
84 |
-
2. **Exegesis & Context** – Analyze the historical, cultural, and linguistic background of these verses.
|
85 |
-
3. **Theological Insights** – Explain the doctrinal significance and its relevance to Christian faith.
|
86 |
-
4. **Different Interpretations (if applicable)** – Present various theological perspectives if there are differing views.
|
87 |
-
5. **Practical Application** – Relate the answer to real-life faith and Christian living.
|
88 |
-
|
89 |
-
Your response should be **scholarly yet easy to understand**, maintaining biblical accuracy while making it applicable for personal growth. [/INST]
|
90 |
-
|
91 |
-
### Answer:</s>"""
|
92 |
-
)
|
93 |
-
|
94 |
payload = {
|
95 |
"inputs": prompt,
|
96 |
}
|
97 |
|
98 |
try:
|
99 |
-
response = requests.post(API_URL, headers=HEADERS, json=payload
|
100 |
response.raise_for_status()
|
101 |
result = response.json()
|
102 |
-
|
103 |
-
logger.debug("Sanitized API Response: %s", json.dumps(sanitized_result, indent=4))
|
104 |
|
105 |
if isinstance(result, list) and len(result) > 0:
|
106 |
answer_text = result[0].get("generated_text", "")
|
@@ -111,39 +69,22 @@ Your response should be **scholarly yet easy to understand**, maintaining biblic
|
|
111 |
else:
|
112 |
return "Error: Unexpected response format."
|
113 |
except requests.exceptions.RequestException as e:
|
114 |
-
|
115 |
-
return "An error occurred while processing your request. Please try again later."
|
116 |
|
117 |
def generate_sermon(topic):
|
118 |
-
prompt =
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
**"{topic}"**
|
123 |
-
|
124 |
-
Your sermon should include:
|
125 |
-
|
126 |
-
1. **Title & Theme** – Provide a clear, impactful sermon title and theme.
|
127 |
-
2. **Key Bible Passages** – Cite relevant Scriptures (OT & NT) and explain their meaning.
|
128 |
-
3. **Exegesis & Context** – Analyze the historical, cultural, and linguistic background of key verses.
|
129 |
-
4. **Theological Insights** – Explain the doctrinal significance and how it aligns with biblical teaching.
|
130 |
-
5. **Illustrations & Real-Life Applications** – Include relatable examples, stories, or analogies to make the message practical.
|
131 |
-
6. **Call to Action** – End with a strong conclusion, a challenge for personal transformation, and a prayer if applicable.
|
132 |
-
|
133 |
-
Your sermon should be **well-structured, theologically rich, engaging, and applicable to daily Christian living.** Use a pastoral yet authoritative tone. [/INST]
|
134 |
-
|
135 |
-
### Sermon:</s>"""
|
136 |
-
)
|
137 |
payload = {
|
138 |
"inputs": prompt,
|
139 |
}
|
140 |
|
141 |
try:
|
142 |
-
response = requests.post(API_URL, headers=HEADERS, json=payload
|
143 |
response.raise_for_status()
|
144 |
result = response.json()
|
145 |
-
|
146 |
-
logger.debug("Sanitized API Response: %s", json.dumps(sanitized_result, indent=4))
|
147 |
|
148 |
if isinstance(result, list) and len(result) > 0:
|
149 |
sermon_text = result[0].get("generated_text", "")
|
@@ -154,26 +95,17 @@ Your sermon should be **well-structured, theologically rich, engaging, and appli
|
|
154 |
else:
|
155 |
return "Error: Unexpected response format."
|
156 |
except requests.exceptions.RequestException as e:
|
157 |
-
|
158 |
-
return "An error occurred while processing your request. Please try again later."
|
159 |
|
160 |
def keyword_search(keyword):
|
161 |
-
prompt =
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
4. **Contextual Analysis** – Explain how the word is used within different passages, including historical and cultural insights.
|
170 |
-
5. **Theological Implications** – Discuss the theological significance and how the term contributes to biblical doctrine.
|
171 |
-
6. **Cross-References** – List related biblical passages and concepts.
|
172 |
-
7. **Exegesis** – Provide a well-reasoned exegesis of key verses, considering grammatical structure, literary context, and interpretative traditions.
|
173 |
-
|
174 |
-
Be precise, scholarly, and include citations when necessary. [/INST]
|
175 |
-
Search Results:</s>"""
|
176 |
-
)
|
177 |
payload = {
|
178 |
"inputs": prompt,
|
179 |
}
|
@@ -235,4 +167,4 @@ bible_app = gr.TabbedInterface(
|
|
235 |
)
|
236 |
|
237 |
if __name__ == "__main__":
|
238 |
-
bible_app.launch()
|
|
|
19 |
|
20 |
def generate_exegesis(passage):
|
21 |
if not passage.strip():
|
22 |
+
return "Please enter a Bible passage."
|
23 |
+
|
24 |
+
prompt = f"""<s>[INST] You are a professional Bible Scholar. Provide a detailed exegesis of the following biblical verse, including:
|
25 |
+
The original Greek text and transliteration with word-by-word analysis and meanings, historical and cultural context, and theological significance for:
|
26 |
+
{passage} [/INST] Exegesis:</s>"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
payload = {
|
29 |
"inputs": prompt,
|
30 |
}
|
31 |
try:
|
32 |
+
response = requests.post(API_URL, headers=HEADERS, json=payload)
|
33 |
response.raise_for_status()
|
34 |
result = response.json()
|
35 |
+
logger.debug("Full API Response: %s", json.dumps(result, indent=4))
|
36 |
|
37 |
if isinstance(result, list) and len(result) > 0:
|
38 |
generated_text = result[0].get("generated_text", "")
|
|
|
43 |
else:
|
44 |
return "Error: Unexpected response format."
|
45 |
except requests.exceptions.RequestException as e:
|
46 |
+
return f"API Error: {e}"
|
|
|
47 |
|
48 |
def ask_any_questions(question):
|
49 |
+
prompt = f"""<s>[INST] You are a professional Bible Scholar. Provide a detailed answer to the following question, including:
|
50 |
+
Relevant Bible verses, their explanations, and theological significance for:
|
51 |
+
{question} [/INST] Answer:</s>"""
|
52 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
payload = {
|
54 |
"inputs": prompt,
|
55 |
}
|
56 |
|
57 |
try:
|
58 |
+
response = requests.post(API_URL, headers=HEADERS, json=payload)
|
59 |
response.raise_for_status()
|
60 |
result = response.json()
|
61 |
+
logger.debug("Full API Response: %s", json.dumps(result, indent=4))
|
|
|
62 |
|
63 |
if isinstance(result, list) and len(result) > 0:
|
64 |
answer_text = result[0].get("generated_text", "")
|
|
|
69 |
else:
|
70 |
return "Error: Unexpected response format."
|
71 |
except requests.exceptions.RequestException as e:
|
72 |
+
return f"API Error: {e}"
|
|
|
73 |
|
74 |
def generate_sermon(topic):
|
75 |
+
prompt = f"""<s>[INST] You are a professional Bible Scholar and Pastor. Provide a detailed sermon on the following topic, including:
|
76 |
+
Relevant Bible verses, their explanations, theological significance, and practical application for:
|
77 |
+
{topic} [/INST] Sermon:</s>"""
|
78 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
payload = {
|
80 |
"inputs": prompt,
|
81 |
}
|
82 |
|
83 |
try:
|
84 |
+
response = requests.post(API_URL, headers=HEADERS, json=payload)
|
85 |
response.raise_for_status()
|
86 |
result = response.json()
|
87 |
+
logger.debug("Full API Response: %s", json.dumps(result, indent=4))
|
|
|
88 |
|
89 |
if isinstance(result, list) and len(result) > 0:
|
90 |
sermon_text = result[0].get("generated_text", "")
|
|
|
95 |
else:
|
96 |
return "Error: Unexpected response format."
|
97 |
except requests.exceptions.RequestException as e:
|
98 |
+
return f"API Error: {e}"
|
|
|
99 |
|
100 |
def keyword_search(keyword):
|
101 |
+
prompt = f"""<s>[INST] You are a **Bible Scholar**. Find relevant Bible passages
|
102 |
+
include:
|
103 |
+
Original Greek/Hebrew text, transliteration, and translation.
|
104 |
+
Word meaning and lexical insights.
|
105 |
+
Context and theological significance.
|
106 |
+
Exegesis with historical and cultural background for
|
107 |
+
{keyword} [/INST] Search Results:</s>"""
|
108 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
payload = {
|
110 |
"inputs": prompt,
|
111 |
}
|
|
|
167 |
)
|
168 |
|
169 |
if __name__ == "__main__":
|
170 |
+
bible_app.launch()
|