Spaces:
Running
Running
Update app.py
Browse files8 unmodified lines91011121314152 unmodified lines181920212223242526272829303185 unmodified lines117118119120121122123193 unmodified lines3173183193203213223238 unmodified linesfrom docx.oxml import parse_xml, OxmlElementfrom docx.oxml.ns import nsdecls, qn# Use the classic reliable legacy library version that matches your environment perfectlyimport google.generativeai as generative_ai# ---------------------------------------------------------------------------2 unmodified linesdef process_live_ai_request(word, api_key):"""Queries the stable Gemini 1.5 Flash model directly using the classicgenerativeai SDK configuration setup that generated your tables last week."""clean_key = api_key.strip() if api_key else ""if not clean_key:return "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>')# Perfect 0.069 inches padding applied precisely to word cellspadding_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)193 unmodified lineswith gr.Row():with gr.Column(scale=2):# FIX: Forced dark typography explicitly with an absolute tag-level inline CSS style blockgr.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;">8 unmodified lines91011121314152 unmodified lines181920212223242526272829303185 unmodified lines117118119120121122123193 unmodified lines3173183193203213223238 unmodified linesfrom docx.oxml import parse_xml, OxmlElementfrom docx.oxml.ns import nsdecls, qn# Classic reliable legacy library version that matches your environment perfectlyimport google.generativeai as generative_ai# ---------------------------------------------------------------------------2 unmodified linesdef process_live_ai_request(word, api_key):"""Queries the stable Gemini 1.5 Flash model directly using the classicgenerativeai SDK configuration setup that successfully generated your tables."""clean_key = api_key.strip() if api_key else ""if not clean_key:return "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>')# Word cell margins locked down precisely to your 0.069 inches padding 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)193 unmodified lineswith gr.Row():with gr.Column(scale=2):# FIX: Locked font contrast parameters inline directly onto the paragraph block 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; padding: 0 !important; line-height: 1.4 !important;">
app.py+5-5