Spaces:
Runtime error
Runtime error
Download app.py from germanp/lc-sql-front-02: direct link, hf CLI and curl.
- Browser
- Download file 2.33 kB
-
https://huggingface.co/spaces/germanp/lc-sql-front-02/resolve/main/app.py
- Command line
-
hf download hf://spaces/germanp/lc-sql-front-02/app.py
-
curl -L -o app.py https://huggingface.co/spaces/germanp/lc-sql-front-02/resolve/main/app.py
2.33 kB
| import gradio as gr | |
| import logging | |
| import os | |
| logging.getLogger().setLevel(logging.INFO) | |
| theme = gr.themes.Base(primary_hue="rose", | |
| secondary_hue="zinc", | |
| font=[gr.themes.GoogleFont('Encode Sans Condensed')]).set(prose_header_text_weight='800') | |
| hf_token = os.getenv('HF_TOKEN') | |
| assistant = gr.load(name="spaces/germanp/lc_sql_back_02", | |
| hf_token=hf_token | |
| ) | |
| def generate_answer(question): | |
| query, answer, cost = assistant(question) | |
| return query, answer, cost | |
| def clean_text(question_textbox, query_textbox, answer_textbox, cost_box): | |
| return [None, None, None, None] | |
| examples = ['¿Cuáles son las columnas de 202208 BASE CANCELACIONES HIST?', | |
| '¿Cuál fue el motivo más frecuente?', | |
| '¿Qué mas franquicias hay?' | |
| ] | |
| with gr.Blocks(theme=theme) as demo: | |
| with gr.Row(): | |
| with gr.Column(scale=1): | |
| gr.Image("davilogo_01.png", | |
| height=40, | |
| width=40, | |
| min_width=5, | |
| show_label=False, | |
| interactive=False, | |
| show_download_button=False, | |
| show_share_button=False) | |
| with gr.Column(scale=30): | |
| gr.Markdown(" ")#sqlGPT Q&A") | |
| with gr.Row(): | |
| with gr.Column(scale=7): | |
| question_text = gr.Textbox(label="Pregunta", placeholder="Escribe aquí tu consulta") | |
| answer_btn = gr.Button(value="Responder") | |
| with gr.Column(scale=7): | |
| query_text = gr.Textbox(label="Query") | |
| answer_text = gr.Textbox(label="Respuesta") | |
| clean_btn = gr.Button(value="¡Otra pregunta!") | |
| #with gr.Column(scale=1, min_width=120): | |
| # cost_text = gr.TextArea(label='Costo de la consulta', lines=1) | |
| answer_btn.click(generate_answer, inputs=question_text, outputs=[query_text, answer_text])#, cost_text | |
| clean_btn.click(clean_text, outputs=[question_text, query_text, answer_text])#, cost_text | |
| examples = gr.Examples(examples=examples, | |
| inputs=[question_text] | |
| ) | |
| demo.launch(debug=True, | |
| show_api=False, | |
| favicon_path="davilogo_01.png", | |
| inline=False | |
| ) |