Spaces:
Running
Running
Update app.py
Browse files8 unmodified lines9101112131415161718195 unmodified lines2526272829303185 unmodified lines11711811912012112212396 unmodified lines22022122222322422522642 unmodified lines26927027127227327427527627740 unmodified lines3183193203213223233248 unmodified linesfrom docx.oxml import parse_xml, OxmlElementfrom docx.oxml.ns import nsdecls, qn# Use the classic legacy package to guarantee perfect model connectivityimport google.generativeai as generative_ai# ---------------------------------------------------------------------------# 1. CORE API LINGUISTIC PIPELINE (VERIFIED LEGACY WORKSPACE ROUTING)# ---------------------------------------------------------------------------def process_live_ai_request(word, api_key):"""5 unmodified linesreturn "Missing Key", "Missing Key", "Enter valid key above"try:# Bind your personal API key directly to the classic workspace configurationgenerative_ai.configure(api_key=clean_key)model = generative_ai.GenerativeModel('gemini-1.5-flash')85 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 cushion margin padding assigned exactly to your 0.069 inches benchmarkpadding_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():42 unmodified linesreturn "", "Success: Canvas workspace cleared cleanly.", "", gr.update(visible=False)# ---------------------------------------------------------------------------# 5. GRADIO UI DESIGN PALETTE CONFIGURATIONS# ---------------------------------------------------------------------------# Re-bound background to your exact #F4F3EF ivory hue parametersbei_css = """body, .gradio-container { background-color: #F4F3EF !important; }.bei-banner { background-color: #1B4D3E; padding: 22px; text-align: center; border-radius: 8px; border-bottom: 4px solid #D4AF37; }40 unmodified lineswith gr.Row():with gr.Column(scale=2):# FIX: Injected inline styling directly into standard text tags to force high contrast gray over Gradio's standard layoutsgr.HTML('''<div class="api-guide-box"><p style="color: #2D3748 !important; font-family: Arial, sans-serif !important; font-size: 11pt !important; margin: 0 !important;">8 unmodified lines9101112131415161718195 unmodified lines2526272829303185 unmodified lines11711811912012112212396 unmodified lines22022122222322422522642 unmodified lines26927027127227327427527640 unmodified lines3173183193203213223238 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):"""5 unmodified linesreturn "Missing Key", "Missing Key", "Enter valid key above"try:# Bind your personal API key directly to the classic legacy workspace configurationgenerative_ai.configure(api_key=clean_key)model = generative_ai.GenerativeModel('gemini-1.5-flash')85 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():42 unmodified linesreturn "", "Success: Canvas workspace cleared cleanly.", "", gr.update(visible=False)# ---------------------------------------------------------------------------# 5. GRADIO DESIGN THEME LAYOUT PARAMETERS# ---------------------------------------------------------------------------bei_css = """body, .gradio-container { background-color: #F4F3EF !important; }.bei-banner { background-color: #1B4D3E; padding: 22px; text-align: center; border-radius: 8px; border-bottom: 4px solid #D4AF37; }40 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;">
app.py+7-8