Spaces:
Running
Running
Update app.py
Browse filesI'm ready for a nap
8 unmodified lines910111212131415161617181920202122231 unmodified line252627282829303126 unmodified lines585960616162636452 unmodified lines11711811912012012112212396 unmodified lines22022122222322322422522610 unmodified lines23723823924024024124218 unmodified lines2612622632652642652662671 unmodified line26927027127327227327427541 unmodified lines3173183193213203213223238 unmodified linesfrom docx.oxml import parse_xml, OxmlElementfrom docx.oxml.ns import nsdecls, qn
# Classic reliable legacy library that natively connects your interface to Gemini 1.5 Flash# Classic secure SDK version that maps your target model beautifullyimport google.generativeai as generative_ai
# ---------------------------------------------------------------------------# 1. CORE LINGUISTIC PIPELINE (GEMINI TRANSLITERATION & TRANSLATION ENGINE)# 1. CORE AI LINGUISTIC PIPELINE (USER API KEY PASS)# ---------------------------------------------------------------------------def process_live_ai_request(word, api_key): """ Queries the stable Gemini 1.5 Flash model using the user's custom API key. Queries the stable Gemini 1.5 Flash model utilizing the user-provided API key. Enforces the full BEI Transliteration Schema Matrix and Morphology constraints. """ clean_key = api_key.strip() if api_key else ""1 unmodified line return "Missing Key", "Missing Key", "Enter valid key above" try: # Configure the legacy library with the user-provided key # Configure the legacy library dynamically with the key from the UI text box generative_ai.configure(api_key=clean_key) model = generative_ai.GenerativeModel('gemini-1.5-flash') 26 unmodified lines BET: v / BET_DAGESH: b | GIMEL: g / GIMEL_DAGESH: g | DALET: d / DALET_DAGESH: d | KAF/FINAL_KAF: kh / KAF_DAGESH: k | PE/FINAL_PE: f / PE_DAGESH: p | TAV: t / TAV_DAGESH: t HARDCODED CLUSTERS & EXPLICIT WORDS: שּׁ -> sh | צּ -> ts | יְרוּשָׁלִַם -> yᵉ·roo·sha·la̱·yeem | מממ -> ha·ma·shee̱·akh | קקק or יֵשׁוּעַ -> Yey·shoo̱·a | אֲדֹנָי -> a·do·nai̱ | שִׁיחַ -> ·shee̱·akh | DIVINE_NAME (YHVH) -> Yᵉ·ho·va̱h | DIVINE_NAME_ELOHIM -> Ye·ho·vee̱h שּׁ -> sh | צּ -> ts | יְרווּשָׁלִַם -> yᵉ·roo·sha·la̱·yeem | מממ -> ha·ma·shee̱·akh | קקק or יֵשׁוּעַ -> Yey·shoo̱·a | אֲדֹנָי -> a·do·nai̱ | שִׁיחַ -> ·shee̱·akh | DIVINE_NAME (YHVH) -> Yᵉ·ho·va̱h | DIVINE_NAME_ELOHIM -> Ye·ho·vee̱h --- CRITICAL BEI MORPHOLOGY RULES:52 unmodified lines cell_top.width = Inches(col_widths[col_idx]) tcPr_top = cell_top._tc.get_or_add_tcPr() borders_top = parse_xml(f'<w:tcBorders {nsdecls("w")}><w:top w:val="single" w:sz="4" w:color="B7B7B7"/><w:left w:val="single" w:sz="4" w:color="B7B7B7"/><w:bottom w:val="single" w:sz="4" w:color="B7B7B7"/><w:right w:val="single" w:sz="4" w:color="B7B7B7"/></w:tcBorders>') # Cell margin padding locked precisely to your true 0.069 inches benchmark spacing # Precise cell margin constraints set down to your 0.069 inches padding benchmark layout padding_top = parse_xml(f'<w:tcMar {nsdecls("w")}><w:top w:w="99" w:type="dxa"/><w:left w:w="99" w:type="dxa"/><w:bottom w:w="99" w:type="dxa"/><w:right w:w="99" w:type="dxa"/></w:tcMar>') tcPr_top.append(borders_top) tcPr_top.append(padding_top)96 unmodified lines return "".join(html_elements)
# ---------------------------------------------------------------------------# 4. RUNTIME WORKFLOW CONTROLLER (PACED INDIVIDUAL TOKEN ENGINE)# 4. RUNTIME WORKFLOW CONTROLLER (PACED SEQUENCE ENGINE)# ---------------------------------------------------------------------------def process_pipeline(api_key, ms_name, book, ch, ver, raw_input): if not raw_input.strip():10 unmodified lines word_packages = [] for tok in tokens: # Pacing constraint (0.4s) naturally prevents network rate blocks time.sleep(0.4) tl, ts, mo = process_live_ai_request(tok, api_key) word_packages.append((tok, tl, ts, mo))18 unmodified lines doc.save(file_path) elapsed = time.time() - start_time status = f"Success! Processed {len(tokens)} words in {elapsed:.2f} seconds across Gemini 1.5 Flash." status = f"Success! Processed {len(tokens)} words in {elapsed:.2f} seconds." return status, html_canvas, gr.update(value=file_path, visible=True)
1 unmodified line return "", "Success: Canvas workspace cleared cleanly.", "", gr.update(visible=False)
# ---------------------------------------------------------------------------# 5. GRADIO INTERFACE LAYOUT (WITH CORRECT CONTRAST PALETTES)# 5. GRADIO DESIGN THEME LAYOUT PARAMETERS# ---------------------------------------------------------------------------bei_css = """body, .gradio-container { background-color: #F4F3EF !important; }41 unmodified lines with gr.Row(): with gr.Column(scale=2): # FIXED VISIBILITY: Removed the bold text tags to ensure the title inherits clear dark charcoal text natively # RESTORED INTERFACE: Removed boldface text markers completely so the label displays cleanly in its native dark theme color gr.HTML(''' <div class="api-guide-box"> <p style="color: #2D3748 !important; font-family: Arial, sans-serif !important; font-size: 11pt !important; margin: 0 !important; padding: 0 !important; line-height: 1.4 !important;">app.py+10-11