Spaces:
Running
Running
Update app.py
Browse files8 unmodified lines91011121314151617181997 unmodified lines11711811912012112212396 unmodified lines22022122222322422522690 unmodified lines3173183193203213223233243253263278 unmodified linesfrom docx.oxml import parse_xml, OxmlElementfrom docx.oxml.ns import nsdecls, qn# Import the official legacy package to ensure perfect model version mappingimport google.generativeai as generative_ai# ---------------------------------------------------------------------------# 1. CORE API LINGUISTIC PIPELINE (STABLE SDK ENVIRONMENT CONFIGURATION)# ---------------------------------------------------------------------------def process_live_ai_request(word, api_key):"""97 unmodified linescell_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 constraints set safely to your exact 0.069 inches metric layoutpadding_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 linesreturn "".join(html_elements)# ---------------------------------------------------------------------------# 4. RUNTIME WORKFLOW CONTROLLER (PACED LOGS ENGINE)# ---------------------------------------------------------------------------def process_pipeline(api_key, ms_name, book, ch, ver, raw_input):if not raw_input.strip():90 unmodified lineswith gr.Row():with gr.Column(scale=2):# FIX: Injected inline style color mapping directly onto paragraphs and strong text nodesgr.HTML('''<div class="api-guide-box"><p style="color: #2D3748 !important; font-family: Arial, sans-serif !important; font-size: 11pt !important; margin: 0 !important;">๐ <strong style="color: #2D3748 !important;">Gemini API Key Guide:</strong> To generate your credentials key, log into<a href="https://aistudio.google.com/" target="_blank" style="color: #1B4D3E !important; font-weight: bold !important; text-decoration: underline !important;">Google AI Studio</a>,click the "Get API Key" button, copy the token code block, and paste it below.</p>8 unmodified lines91011121314151617181997 unmodified lines11711811912012112212396 unmodified lines22022122222322422522690 unmodified lines3173183193203213223233243253263278 unmodified linesfrom docx.oxml import parse_xml, OxmlElementfrom docx.oxml.ns import nsdecls, qn# Classic secure SDK module to map your target model smoothlyimport google.generativeai as generative_ai# ---------------------------------------------------------------------------# 1. CORE AI LINGUISTIC PIPELINE (STABLE LEGACY ROUTING)# ---------------------------------------------------------------------------def process_live_ai_request(word, api_key):"""97 unmodified linescell_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 text padding cushion locked cleanly to 0.069 inchespadding_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 linesreturn "".join(html_elements)# ---------------------------------------------------------------------------# 4. RUNTIME WORKFLOW CONTROLLER (PACED SEQUENCE ENGINE)# ---------------------------------------------------------------------------def process_pipeline(api_key, ms_name, book, ch, ver, raw_input):if not raw_input.strip():90 unmodified lineswith gr.Row():with gr.Column(scale=2):# FIX: Forced direct inline style properties onto the h4/p/strong structures to enforce high contrast charcoal color textgr.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;">๐ <strong style="color: #2D3748 !important; font-weight: bold !important;">Gemini API Key Guide:</strong> To generate your credentials key, log into<a href="https://aistudio.google.com/" target="_blank" style="color: #1B4D3E !important; font-weight: bold !important; text-decoration: underline !important;">Google AI Studio</a>,click the "Get API Key" button, copy the token code block, and paste it below.</p>
app.py+7-7