Josebert commited on
Commit
2eb6cd8
·
verified ·
1 Parent(s): ef7aeaa

Upload 2 files

Browse files
Files changed (2) hide show
  1. README.md +13 -13
  2. app.py +51 -0
README.md CHANGED
@@ -1,13 +1,13 @@
1
- ---
2
- title: JR Study Bible V1
3
- emoji: 👁
4
- colorFrom: blue
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 5.16.0
8
- app_file: app.py
9
- pinned: false
10
- short_description: JR Study Bible is an AI-powered Bible study app that generat
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ ---
2
+ title: JR Study Bible V1
3
+ emoji: 👁
4
+ colorFrom: blue
5
+ colorTo: gray
6
+ sdk: gradio
7
+ sdk_version: 5.16.0
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: JR Study Bible is an AI-powered Bible study app that generat
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import requests
4
+
5
+ # Retrieve the API token from environment variables
6
+ API_TOKEN = os.getenv("API_TOKEN")
7
+ if not API_TOKEN:
8
+ raise ValueError("API token not found. Please set the API_TOKEN environment variable.")
9
+
10
+ API_URL = "https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-1B-Instruct"
11
+ HEADERS = {"Authorization": f"Bearer {API_TOKEN}"}
12
+
13
+
14
+ def generate_exegesis(passage):
15
+ if not passage.strip():
16
+ return "Please enter a Bible passage."
17
+
18
+ prompt = f"You are a professional Bible Scholar, Provide a detailed exegesis of the following biblical verse, including: The original Greek text and transliteration with Word-by-word analysis with meanings. Historical and cultural context. Theological significance. for:\n\n{passage}\n\nExegesis:"
19
+
20
+ payload = {
21
+ "inputs": prompt,
22
+ "parameters": {
23
+ "max_length": 250,
24
+ "temperature": 0.7,
25
+ "do_sample": True
26
+ }
27
+ }
28
+
29
+ try:
30
+ response = requests.post(API_URL, headers=HEADERS, json=payload)
31
+ response.raise_for_status() # Raise an error for bad responses (4xx, 5xx)
32
+ result = response.json()
33
+
34
+ if isinstance(result, list) and len(result) > 0:
35
+ return result[0].get("generated_text", "Error: No response from model.")
36
+ else:
37
+ return "Error: Unexpected response format."
38
+ except requests.exceptions.RequestException as e:
39
+ return f"API Error: {e}"
40
+
41
+ # Gradio interface
42
+ demo = gr.Interface(
43
+ fn=generate_exegesis,
44
+ inputs=gr.Textbox(label="Enter Bible Passage", placeholder="e.g., John 3:16"),
45
+ outputs=gr.Textbox(label="Exegesis Commentary"),
46
+ title="JR Study Bible",
47
+ description="Enter a Bible passage to receive insightful exegesis commentary using the Hugging Face API."
48
+ )
49
+
50
+ if __name__ == "__main__":
51
+ demo.launch()