Spaces:
Running
Running
Update app.py
Browse filesdaniels' fix
12345678128 unmodified lines13713813914014114249 unmodified lines1921931941951961971981 unmodified line20020120220320420517 unmodified lines2232242252262272282292302312322332342352362372382392402412422432445 unmodified lines25025125225325425525622 unmodified lines2792802812822832842852862872881 unmodified line2902912922932942959 unmodified lines3053063073083093103113123133143 unmodified lines3183193203213223233243253263273283293303313323333341 unmodified line33633733833934034134236 unmodified lines379380381382383384385386import gradio as grfrom google import genaifrom google.genai import typesimport timeimport json# --- BEI Premium Theme & Horizontal Interface Custom Engine ---custom_css = """128 unmodified linesalign-items: flex-end !important;min-height: 42px !important;}"""sticky_session_and_layout_js = """49 unmodified lines}, 1200);}"""MODEL_NAME = "gemini-3.1-flash-lite"def clean_hyphens_for_docs(text_string):1 unmodified linereturn ""return str(text_string).replace("-", "‑")def calculate_clean_chunks(words_data):chunks = []current_chunk = []17 unmodified linestable_style = (f"width: {total_table_width_in}in !important; min-width: {total_table_width_in}in !important; "f"max-width: {total_table_width_in}in !important; table-layout: fixed !important; border-collapse: collapse; ""direction: rtl; border: 1pt solid #b7b7b7; background-color: #ffffff; ""line-height: 1.0 !important; height: auto; margin-left: auto !important; margin-right: auto !important;")base_cell = "border: 1pt solid #b7b7b7; padding: 0.069in !important; height: auto; overflow: hidden; white-space: normal !important; word-wrap: break-word !important; box-sizing: border-box !important;"hebrew_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 24px !important; color: #000000 !important; text-align: right !important; vertical-align: middle; {base_cell}"english_cell_style = f"font-family: Arial, sans-serif !important; font-size: 14.6667px !important; color: #000000 !important; text-align: center !important; vertical-align: top; line-height: 1.0 !important; {base_cell}"heading_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18.6667px !important; color: #000000 !important; text-align: center !important; vertical-align: middle; line-height: 1.0 !important; {base_cell}"html_output = ['<div id="table-payload" class="white-canvas" style="background-color: #ffffff; padding: 15px; border-radius: 8px; display: inline-block; width: 100%; box-sizing: border-box; text-align: center;">']table_chunks = calculate_clean_chunks(words_data)for idx, current_chunk in enumerate(table_chunks):# Open a new table for each chunkhtml_output.append(f'<table style="{table_style}" align="center" cellpadding="5" cellspacing="0">')html_output.append(' <colgroup>')for _ in range(total_slots):html_output.append(f' <col style="width: {column_width_in}in !important; min-width: {column_width_in}in !important; max-width: {column_width_in}in !important;">')5 unmodified linesif is_last_table:while allocated_slots < total_slots:current_chunk.append({"hebrew": " ", "transliteration": " ", "translation": " ", "morphology": " "})allocated_slots += 1# --- ROW 1: Right-Justified Hebrew Word Units ---22 unmodified lineselse:html_output.append(f' <td style="{english_cell_style}"> </td>')html_output.append(' </tr>')# Close the table for this chunk and inject a double line break spacer!html_output.append('</table><br><br>')html_output.append('</div>')return "".join(html_output)1 unmodified lineif not api_key:return "<p style='color:red; text-align:center;'>❌ Error: Please enter your Gemini API key.</p>", gr.update(visible=False)reference_header = f"{book} {chapter}:{verse}"try:9 unmodified linesPopulate a flat JSON array containing objects matching this schema format exactly:{{"hebrew": "The exact raw Hebrew word token","transliteration": "The syllabic transliteration strictly following the provided rules","translation": "The direct lowercase contextual translation","morphology": "The clean root-only structural morphology format string"}}STRICT BEI TRANSLITERATION MAPPING TABLES:3 unmodified lines- SPECIAL CLUSTERS: שּׁ = "sh", צּ = "ts", יְרוּשָׁלִַם = "yᵉ·roo·sha·la̱·yeem", יֵשׁוּעַ = "Yey·shoo̱·a"- DIVINE_NAME: "Yᵉ·ho·va̱h", DIVINE_NAME_ELOHIM: "Ye·ho·vee̱h"CRITICAL SYLLABLE SEPARATOR RULE:- You MUST use the middle dot symbol (·, ALT+0183) exclusively to separate syllables in the transliteration field (e.g., "ga·dol", "mi·bey̱t", "ha·me·le̱kh"). Never vary from this separator mark.CRITICAL ROOT-ONLY MORPHOLOGY LOGIC:- Report ONLY on the core 'root' properties of a word unit. Strip out all prefix or suffix clutter from the morphology description (e.g. for 'mi'beyt', evaluate only 'house' -> 'nms constr').- Abbreviations: verb=v, noun=n, adverb=adv, adjective=adj, conjunction=conj, particle=part, preposition=prep, pronoun=pron, proper name=name, definite direct object=ddo, number=#, interjection=intj, construct=constr. Do not include periods.- Binyan forms: Pa'al, Nif'al, Pi'el, Pu'al, Hif'il, Huf'al, Hitpa'el. Never use "Qal".- Tense forms: perfect=perf, imperfect=imp, participle=ptcpl.- Structure formatting: part_of_speech + space + binyan (if app) + space + tense (if app) + person/gender/number combo (no inner spacing, e.g., '3ms', '2mp'). Example: "v Pa'al perf 3ms" or "n mp constr"."""response = client.models.generate_content(model=MODEL_NAME, contents=prompt,config=types.GenerateContentConfig(1 unmodified lineresponse_mime_type="application/json", candidate_count=1))raw_json_data = json.loads(response.text.strip())final_table_html = build_html_tables(manuscript_name, reference_header, raw_json_data)return final_table_html, gr.update(visible=True)except Exception as e:36 unmodified linesbook_input = gr.Textbox(label="📚 Bible Book", value="Luke", scale=2)# Chapter and Verse as Number inputs for spinner functionalitychapter_input = gr.Number(label="Chapter", value=11, precision=0, scale=1)verse_input = gr.Number(label="Verse", value=49, precision=0, scale=1)text_string_input = gr.Textbox(label="📝 Hebrew Verses Input String", placeholder="Paste line segments...", scale=4)12345678910128 unmodified lines13914014114214314414514614714814915015149 unmodified lines2012022032042052061 unmodified line20820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145217 unmodified lines4704714724734744754764774784794804814824834844854864874884894904914924934944955 unmodified lines50150250350450550650750850951051151251351451551651722 unmodified lines5405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975981 unmodified line6006016026036046056066079 unmodified lines6176186196206216226236246256266276286296306316326336346353 unmodified lines6396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077081 unmodified line71071171271371471571671771871972072172236 unmodified lines759760761762763764765766import gradio as grfrom google import genaifrom google.genai import typesimport jsonimport refrom html import escapefrom urllib.parse import quote# --- BEI Premium Theme & Horizontal Interface Custom Engine ---custom_css = """128 unmodified linesalign-items: flex-end !important;min-height: 42px !important;}/* Forces all plain <span> text inside the generated table payload to black */#table-payload span {color: #000000 !important;-webkit-text-fill-color: #000000 !important;opacity: 1 !important;}"""sticky_session_and_layout_js = """49 unmodified lines}, 1200);}"""MODEL_NAME = "gemini-3.1-flash-lite"def clean_hyphens_for_docs(text_string):1 unmodified linereturn ""return str(text_string).replace("-", "‑")def parse_gemini_json_response(response_text):response_text = response_text.strip()# Remove markdown fences if Gemini accidentally returns them.response_text = response_text.replace("```json", "").replace("```", "").strip()# Keep only the JSON array if Gemini adds extra text before or after it.first_bracket = response_text.find("[")last_bracket = response_text.rfind("]")if first_bracket != -1 and last_bracket != -1 and last_bracket > first_bracket:response_text = response_text[first_bracket:last_bracket + 1]# Remove illegal trailing commas before } or ].response_text = re.sub(r",\s*([}\]])", r"\1", response_text)return json.loads(response_text)def space_hebrew_letters(root_word):if not root_word:return ""root_word = str(root_word).strip()if root_word.upper() == "NONE" or root_word == " ":return root_wordreturn " - ".join(list(root_word))def make_pealim_strongs_root_cell(strongs_number,hebrew_word,word_first_ot_ref,root_word,root_strongs_number,root_first_ot_ref):if not strongs_number:return " "strongs_number = str(strongs_number).strip()hebrew_word = str(hebrew_word).strip()word_first_ot_ref = str(word_first_ot_ref).strip() if word_first_ot_ref else ""root_word = str(root_word).strip() if root_word else ""root_strongs_number = str(root_strongs_number).strip() if root_strongs_number else ""root_first_ot_ref = str(root_first_ot_ref).strip() if root_first_ot_ref else ""if not root_word or root_word.upper() == "NONE" or root_word == " ":root_word = ""if not root_strongs_number or root_strongs_number.upper() == "NONE" or root_strongs_number == " ":root_strongs_number = ""# Top Strong's number searches Pealim for the actual Hebrew word in this column.word_pealim_url = f"https://www.pealim.com/search/?q={quote(hebrew_word)}"# Bottom root Strong's number searches Pealim for the Hebrew root word.root_pealim_url = ""if root_word:root_pealim_url = f"https://www.pealim.com/search/?q={quote(root_word)}"if (strongs_number.upper() == "NONE"or strongs_number == " "or not hebrew_wordor hebrew_word == " "):word_strongs_display = escape(strongs_number)else:word_strongs_display = (f'<a href="{word_pealim_url}" 'f'target="_blank" 'f'rel="noopener noreferrer" 'f'style="color: #0000EE !important; 'f'font-family: \'Times New Roman\', serif !important; 'f'font-size: 18px !important; 'f'text-decoration: underline !important;">'f'{escape(strongs_number)}'f'</a>')word_first_ref_display = make_biblegateway_kjv_link(word_first_ot_ref)if word_first_ref_display:word_first_ref_display = f"<br>{word_first_ref_display}"# separator_display = (# f'<div style="'# f'border-top: 1px solid #b7b7b7 !important; '# f'height: 1px !important; '# f'line-height: 1px !important; '# f'margin: 3px 8px 2px 8px !important; '# f'padding: 0 !important;">'# f'</div>'# )if root_word:spaced_root = space_hebrew_letters(root_word)# Plain display only. The Hebrew root itself is NOT clickable.root_display = (f'<br>'f'<div dir="rtl" 'f'style="font-family: \'Times New Roman\', serif !important; 'f'font-size: 18px !important; 'f'font-weight: normal !important; 'f'color: #000000 !important; 'f'-webkit-text-fill-color: #000000 !important; 'f'opacity: 1 !important; 'f'text-decoration: none !important; 'f'line-height: 1.0 !important; 'f'padding: 0 !important;">'f'{escape(spaced_root)}'f'</div>')else:root_display = ""if root_strongs_number and root_pealim_url:root_strongs_display = (f'<br>'f'<a href="{root_pealim_url}" 'f'target="_blank" 'f'rel="noopener noreferrer" 'f'style="color: #0000EE !important; 'f'font-family: \'Times New Roman\', serif !important; 'f'font-size: 18px !important; 'f'text-decoration: underline !important;">'f'{escape(root_strongs_number)}'f'</a>')elif root_strongs_number:root_strongs_display = f'<br>{escape(root_strongs_number)}'else:root_strongs_display = ""root_first_ref_display = make_biblegateway_kjv_link(root_first_ot_ref)if root_first_ref_display:root_first_ref_display = f"<br>{root_first_ref_display}"return (word_strongs_display+ word_first_ref_display# + separator_display+ root_display+ root_strongs_display+ root_first_ref_display)def abbreviate_bible_reference(reference_text):if not reference_text:return ""reference_text = str(reference_text).strip()book_abbreviations = {"Genesis": "Gen","Exodus": "Exod","Leviticus": "Lev","Numbers": "Num","Deuteronomy": "Deut","Joshua": "Josh","Judges": "Judg","Ruth": "Ruth","1 Samuel": "1 Sam","2 Samuel": "2 Sam","1 Kings": "1 Kgs","2 Kings": "2 Kgs","1 Chronicles": "1 Chr","2 Chronicles": "2 Chr","Ezra": "Ezra","Nehemiah": "Neh","Esther": "Esth","Job": "Job","Psalms": "Ps","Psalm": "Ps","Proverbs": "Prov","Ecclesiastes": "Eccl","Song of Solomon": "Song","Song of Songs": "Song","Isaiah": "Isa","Jeremiah": "Jer","Lamentations": "Lam","Ezekiel": "Ezek","Daniel": "Dan","Hosea": "Hos","Joel": "Joel","Amos": "Amos","Obadiah": "Obad","Jonah": "Jonah","Micah": "Mic","Nahum": "Nah","Habakkuk": "Hab","Zephaniah": "Zeph","Haggai": "Hag","Zechariah": "Zech","Malachi": "Mal"}for full_book_name, abbreviated_book_name in book_abbreviations.items():if reference_text.startswith(full_book_name + " "):return reference_text.replace(full_book_name, abbreviated_book_name, 1)return reference_textdef make_biblegateway_kjv_link(reference_text):if not reference_text:return ""reference_text = str(reference_text).strip()if (not reference_textor reference_text.upper() == "NONE"or reference_text == " "):return ""display_reference = abbreviate_bible_reference(reference_text)biblegateway_url = (f"https://www.biblegateway.com/passage/"f"?search={quote(reference_text)}&version=KJV")return (f'<a href="{biblegateway_url}" 'f'target="_blank" 'f'rel="noopener noreferrer" 'f'style="color: #0000EE !important; 'f'font-family: \'Times New Roman\', serif !important; 'f'font-size: 12px !important; 'f'line-height: 1.0 !important; 'f'text-decoration: underline !important;">'f'{escape(display_reference)}'f'</a>')def calculate_clean_chunks(words_data):chunks = []current_chunk = []17 unmodified linestable_style = (f"width: {total_table_width_in}in !important; min-width: {total_table_width_in}in !important; "f"max-width: {total_table_width_in}in !important; table-layout: fixed !important; ""border-collapse: collapse !important; border-spacing: 0 !important; ""direction: rtl; border: 1pt solid #b7b7b7; background-color: #ffffff; ""line-height: 1.0 !important; height: auto; ""margin-top: 0 !important; margin-bottom: 0 !important; ""margin-left: auto !important; margin-right: auto !important;")base_cell = "border: 1pt solid #b7b7b7; padding: 0.069in !important; height: auto; overflow: hidden; white-space: normal !important; word-wrap: break-word !important; box-sizing: border-box !important;"hebrew_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18px !important; color: #000000 !important; text-align: right !important; vertical-align: middle; {base_cell}"english_cell_style = f"font-family: Arial, sans-serif !important; font-size: 11px !important; color: #000000 !important; text-align: center !important; vertical-align: top; line-height: 1.0 !important; {base_cell}"strongs_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18px !important; color: #000000 !important; text-align: center !important; vertical-align: middle; line-height: 1.15 !important; {base_cell}"heading_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18px !important; color: #000000 !important; text-align: center !important; vertical-align: middle; line-height: 1.0 !important; {base_cell}"html_output = ['<div id="table-payload" class="white-canvas" style="background-color: #ffffff; padding: 15px; border-radius: 8px; display: inline-block; width: 100%; box-sizing: border-box; text-align: center;">']table_chunks = calculate_clean_chunks(words_data)for idx, current_chunk in enumerate(table_chunks):# Open a new table for each chunkhtml_output.append(f'<table style="{table_style}" align="center" cellpadding="0" cellspacing="0">')html_output.append(' <colgroup>')for _ in range(total_slots):html_output.append(f' <col style="width: {column_width_in}in !important; min-width: {column_width_in}in !important; max-width: {column_width_in}in !important;">')5 unmodified linesif is_last_table:while allocated_slots < total_slots:current_chunk.append({"hebrew": " ","transliteration": " ","translation": " ","morphology": " ","strongs": " ","word_first_ot_ref": " ","root": " ","root_strongs": " ","root_first_ot_ref": " "})allocated_slots += 1# --- ROW 1: Right-Justified Hebrew Word Units ---22 unmodified lineselse:html_output.append(f' <td style="{english_cell_style}"> </td>')html_output.append(' </tr>')# --- ROW 3: Strong's Concordance Number Links ---html_output.append(' <tr style="height: auto; line-height: 1.0 !important;">')if idx == 0:html_output.append(f' <td style="{strongs_cell_style}"></td>')# html_output.append(# f' <td style="{strongs_cell_style}">'# f'# Strong’s<br>'# f'1st Use<br>'# f'<div style="border-top: 1px solid #b7b7b7; margin: 3px 8px 2px 8px;"></div>'# f'Root Word<br>'# f'# Root Strong’s<br>'# f'Root 1st Use'# f'</td>'# )for word in current_chunk:hebrew_word = word.get("hebrew", " ")if hebrew_word != " " and hebrew_word != " ":strongs_number = word.get("strongs", "NONE")word_first_ot_ref = word.get("word_first_ot_ref", "NONE")root_word = word.get("root", "NONE")root_strongs_number = word.get("root_strongs", "NONE")root_first_ot_ref = word.get("root_first_ot_ref", "NONE")strongs_root_cell = make_pealim_strongs_root_cell(strongs_number,hebrew_word,word_first_ot_ref,root_word,root_strongs_number,root_first_ot_ref)html_output.append(f' <td style="{strongs_cell_style}">{strongs_root_cell}</td>')else:html_output.append(f' <td style="{strongs_cell_style}"> </td>')html_output.append(' </tr>')# Close the table for this chunk and inject only a small one line 4px spacer...DJMhtml_output.append("</table>""<div style=\"font-family: 'Times New Roman', serif !important; ""font-size: 4pt !important; ""line-height: 4pt !important; ""height: 4pt !important; ""margin: 0 !important; ""padding: 0 !important; ""background-color: #ffffff !important;\"> </div>")html_output.append('</div>')return "".join(html_output)1 unmodified lineif not api_key:return "<p style='color:red; text-align:center;'>❌ Error: Please enter your Gemini API key.</p>", gr.update(visible=False)chapter = max(1, int(chapter))verse = max(1, int(verse))reference_header = f"{book} {chapter}:{verse}"try:9 unmodified linesPopulate a flat JSON array containing objects matching this schema format exactly:{{{{{{"hebrew": "The exact raw Hebrew word token from the input text","transliteration": "The syllabic transliteration strictly following the provided rules","translation": "The direct lowercase contextual translation","morphology": "The clean root-only structural morphology format string","strongs": "The best matching Hebrew Strong's Concordance number for the actual Hebrew word or lexical term used in this column, formatted like H7225, or NONE if no reliable Strong's number applies","word_first_ot_ref": "The first Old Testament reference where this actual Hebrew word or lexical term appears, formatted like Genesis 1:1, or NONE if uncertain","root": "The Hebrew root word behind the actual Hebrew word, written in Hebrew consonants only with no vowel points, no spaces, no hyphens, and no explanations","root_strongs": "The best matching Hebrew Strong's Concordance number for the Hebrew root word, formatted like H7218, or NONE if no reliable root Strong's number applies","root_first_ot_ref": "The first Old Testament reference where this Hebrew root word appears, formatted like Genesis 2:10, or NONE if uncertain"}}}}}}STRICT BEI TRANSLITERATION MAPPING TABLES:3 unmodified lines- SPECIAL CLUSTERS: שּׁ = "sh", צּ = "ts", יְרוּשָׁלִַם = "yᵉ·roo·sha·la̱·yeem", יֵשׁוּעַ = "Yey·shoo̱·a"- DIVINE_NAME: "Yᵉ·ho·va̱h", DIVINE_NAME_ELOHIM: "Ye·ho·vee̱h"CRITICAL JSON OUTPUT RULES:- Return ONLY one valid JSON array.- Do not return markdown.- Do not return explanations.- Do not wrap the JSON in ```json fences.- Do not put trailing commas after the final field in any object.- Do not put trailing commas after the final object in the array.- Every object must contain exactly these fields: hebrew, transliteration, translation, morphology, strongs, word_first_ot_ref, root, root_strongs, root_first_ot_ref.CRITICAL SYLLABLE SEPARATOR RULE:- You MUST use the middle dot symbol (·, ALT+0183) exclusively to separate syllables in the transliteration field (e.g., "ga·dol", "mi·bey̱t", "ha·me·le̱kh"). Never vary from this separator mark.CRITICAL ROOT-ONLY MORPHOLOGY LOGIC:- Report ONLY on the core 'root' properties of a word unit. Strip out all prefix or suffix clutter from the morphology description (e.g. for 'mi'beyt', evaluate only 'house' -> 'nms constr').- Abbreviations: verb=v, noun=n, adverb=adv, adjective=adj, conjunction=conj, particle=part, preposition=prep, pronoun=pron, proper name=name, definite direct object=ddom, number=#, interjection=intj, construct=constr. Do not include periods.- Binyan forms: Pa'al, Nif'al, Pi'el, Pu'al, Hif'il, Huf'al, Hitpa'el. Never use "Qal".- Tense forms: perfect=perf, imperfect=imp, participle=ptcpl.- Structure formatting: part_of_speech + space + binyan (if app) + space + tense (if app) + person/gender/number combo (no inner spacing, e.g., '3ms', '2mp'). Example: "v Pa'al perf 3ms" or "n mp constr".CRITICAL STRONG'S CONCORDANCE LOGIC:- Add a "strongs" field to every JSON object.- The "strongs" field must identify the best matching Hebrew Strong's Concordance number for the actual Hebrew word/term in the column.- Do NOT automatically use the root Strong's number for the "strongs" field.- The "strongs" field should represent the lexical term being translated in that column, including derived nouns, names, particles, verbs, adjectives, or other Hebrew dictionary terms.- Example: רֵאשִׁית should use strongs H7225 because the word/term means beginning.- Example: the root behind רֵאשִׁית is ראש, and that root should use root_strongs H7218.- Example: for a simple verb like אמר, the word Strong's number and root Strong's number may both be H559. That is acceptable only when they truly match.- Format Hebrew Strong's numbers as H followed by digits, such as H7225.- If no reliable Strong's number applies, return "NONE".- Do not guess wildly. Prefer "NONE" when uncertain.CRITICAL HEBREW ROOT WORD LOGIC:- Add a "root" field to every JSON object.- The "root" field must contain the Hebrew root behind the actual Hebrew word in that column.- Return the root in Hebrew consonants only.- Do not include vowel points, cantillation marks, spaces, hyphens, transliteration, English, labels, or explanatory notes.- For verbs, prefer the shoresh/root, usually three Hebrew consonants when applicable.- For derived nouns, identify the underlying Hebrew root, not merely the same noun repeated.- Example: for רֵאשִׁית, return root ראש.- Example: for ברא, return root ברא.- If no reliable Hebrew root applies, return "NONE".CRITICAL ROOT STRONG'S CONCORDANCE LOGIC:- Add a "root_strongs" field to every JSON object.- The "root_strongs" field must identify the best matching Hebrew Strong's Concordance number for the Hebrew root word in the "root" field.- Do NOT simply copy the "strongs" field unless the word Strong's number and root Strong's number are truly the same.- Example: רֵאשִׁית should use strongs H7225, root ראש, and root_strongs H7218.- Example: ברא may use strongs H1254, root ברא, and root_strongs H1254 because the word and root are the same lexical item.- Format Hebrew Strong's numbers as H followed by digits, such as H7218.- If no reliable root Strong's number applies, return "NONE".- Do not guess wildly. Prefer "NONE" when uncertain.CRITICAL FIRST OLD TESTAMENT OCCURRENCE LOGIC:- Add a "word_first_ot_ref" field to every JSON object.- Add a "root_first_ot_ref" field to every JSON object.- "word_first_ot_ref" must identify the first Old Testament / Hebrew Bible location where the actual Hebrew word or lexical term appears.- "root_first_ot_ref" must identify the first Old Testament / Hebrew Bible location where the Hebrew root word appears.- Use KJV book names and reference formatting, such as Genesis 1:1, Exodus 3:14, Deuteronomy 6:4.- Do not include the verse text.- Do not include Hebrew text in these reference fields.- If you are uncertain, return "NONE".- Do not simply copy "word_first_ot_ref" into "root_first_ot_ref" unless they are truly the same first occurrence."""response = client.models.generate_content(model=MODEL_NAME, contents=prompt,config=types.GenerateContentConfig(1 unmodified lineresponse_mime_type="application/json", candidate_count=1))# response_text = response.text.strip()# print("RAW GEMINI RESPONSE:")# print(response_text)# raw_json_data = json.loads(response_text)raw_json_data = parse_gemini_json_response(response.text)final_table_html = build_html_tables(manuscript_name, reference_header, raw_json_data)return final_table_html, gr.update(visible=True)except Exception as e:36 unmodified linesbook_input = gr.Textbox(label="📚 Bible Book", value="Luke", scale=2)# Chapter and Verse as Number inputs for spinner functionalitychapter_input = gr.Number(label="Chapter", value=11, minimum=1, step=1, precision=0, scale=1)verse_input = gr.Number(label="Verse", value=49, minimum=1, step=1, precision=0, scale=1)text_string_input = gr.Textbox(label="📝 Hebrew Verses Input String", placeholder="Paste line segments...", scale=4)
app.py+401-21