Spaces:
Running
Running
Update app.py
Browse files286 unmodified lines287288289290286 unmodified lines- VOCAL_SHEVA: "ᵉ", HATAF_SEGOL: "e", HATAF_PATAH: "a", HATAF_QAMATS: "o", HIRIQ: "i", TSERE: "ey", SEGOL: "e", PATAH: "a", QAMATS: "a", HOLAM: "o", QUBUTS: "oo", MAQAF: "-", PASEQ: "׀", SOF_PASUQ: "."- SYLLABLE_SEPARATOR: "·", STRESS_MARKER: location: "after-vowel", mark: "̱"- DIVINE_NAME: "Yᵉ·ho·va̱h", DIVINE_NAME_ELOHIM: "Ye·ho·vee̱h"- Specific translations: Always map 'יֵשׁוּעַ' to transliteration 'yey286 unmodified lines287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378286 unmodified lines- VOCAL_SHEVA: "ᵉ", HATAF_SEGOL: "e", HATAF_PATAH: "a", HATAF_QAMATS: "o", HIRIQ: "i", TSERE: "ey", SEGOL: "e", PATAH: "a", QAMATS: "a", HOLAM: "o", QUBUTS: "oo", MAQAF: "-", PASEQ: "׀", SOF_PASUQ: "."- SYLLABLE_SEPARATOR: "·", STRESS_MARKER: location: "after-vowel", mark: "̱"- DIVINE_NAME: "Yᵉ·ho·va̱h", DIVINE_NAME_ELOHIM: "Ye·ho·vee̱h"- Specific translations: Always map 'יֵשׁוּעַ' to transliteration 'yey·shoo̱·a' and translation 'Yeshua'."""response = client.models.generate_content(model=MODEL_NAME, contents=prompt,config=types.GenerateContentConfig(system_instruction=system_instruction_text,response_mime_type="application/json", candidate_count=1))raw_json_data = json.loads(response.text.strip())except Exception as e:yield gr.update(visible=True, value=f"<p style='color:red; text-align:center;'>❌ API Error: {str(e)}</p>"), "", gr.update(visible=False)returnyield gr.update(visible=True, value=status_html("Executing 3-Step Column Balance Layout Matrix")), "", gr.update(visible=False)try:final_table_html = build_html_tables(manuscript_name, reference_header, raw_json_data)except Exception as e:yield gr.update(visible=True, value=f"<p style='color:red; text-align:center;'>❌ Layout Error: {str(e)}</p>"), "", gr.update(visible=False)returnyield gr.update(visible=False, value=""), final_table_html, gr.update(visible=True)copy_js = """function() {const payload = document.getElementById('table-payload').innerHTML;const blob = new Blob([payload], { type: 'text/html' });const data = [new ClipboardItem({ 'text/html': blob })];navigator.clipboard.write(data).then(() => {alert('📋 Tables successfully copied to clipboard with exact formatting!');}).catch(err => { alert('❌ Clipboard Copy Failed: ' + err); });}"""with gr.Blocks(css=custom_css, title="Hebrew Interlinear Table Generator") as demo:gr.HTML("<div style='background: linear-gradient(135deg, #111827 0%, #1f2937 100%); padding: 24px; border-radius: 12px; margin-bottom: 24px; color: white; text-align: center; border: 1px solid #374151; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.5);'>""<h1 style='margin: 0 0 8px 0; font-size: 28px; font-weight: 700; color: white;'>📖 Hebrew Interlinear Table Generator</h1>""<p style='margin: 0; font-size: 15px; opacity: 0.8; color: #9ca3af;'>Convert raw Hebrew text into structured, balanced 7-inch columns.</p>""</div>")with gr.Accordion("🔑 How to find and paste your Gemini API key", open=True):gr.Markdown("1. Go to [Google AI Studio](https://aistudio.google.com/).\n""2. Click **Get API Key** in the menu.\n""3. Copy the **Default API Key** shown on the screen.\n""4. Paste it into the **Gemini API Key** box below.\n\n""📺 **Need visual help?** Watch this [simple video tutorial](https://youtu.be/Uyn-P2nRvDA?si=_1NqPoJK-sHOVX-W).")with gr.Row():with gr.Column(scale=4):gr.Markdown("### 🛠️ Step 1: Configure Reference Settings")api_key_input = gr.Textbox(label="🔑 Gemini API Key", type="password", placeholder="Paste your default API key token here...")manuscript_input = gr.Textbox(label="📜 Manuscript Name", value="Marseilles MS-24")book_input = gr.Textbox(label="📚 Book Title", value="Luke")with gr.Row():chapter_input = gr.Dropdown(choices=[str(x) for x in range(1, 151)], label="Ch.", value="11", allow_custom_value=True)verse_input = gr.Dropdown(choices=[str(x) for x in range(1, 177)], label="Ver.", value="49", allow_custom_value=True)gr.Markdown("### 📝 Step 2: Paste Hebrew Text")text_string_input = gr.Textbox(label="Hebrew Verses Input String", placeholder="Paste your raw Hebrew string text right here...", lines=3)with gr.Row():submit_btn = gr.Button("🚀 Generate Table", variant="primary")clear_btn = gr.Button("🧹 Clear Text", variant="secondary")status_panel = gr.HTML(visible=False)gr.Markdown("### 📊 Step 3: Output View & Copy Options")copy_btn = gr.Button("📋 Copy for Google Docs", variant="secondary", visible=False)output_html = gr.HTML(label="Generated Output Table Grid Layout Canvas")demo.load(fn=None, inputs=None, outputs=None, js=force_clean_layout_js)submit_btn.click(fn=generate_table_code,inputs=[api_key_input, manuscript_input, book_input, chapter_input, verse_input, text_string_input],outputs=[status_panel, output_html, copy_btn],show_progress="hidden")clear_btn.click(fn=None, inputs=[], outputs=[text_string_input], js="() => ''")copy_btn.click(fn=None, js=copy_js)if __name__ == "__main__":demo.queue().launch(server_name="0.0.0.0", server_port=7860)
app.py+89-1