Spaces:
Runtime error
Runtime error
File size: 2,330 Bytes
d259589 9b02885 d259589 3c2cbc6 b5a05a8 3c2cbc6 74a60e9 05f3aff 3c2cbc6 d259589 ea2f9cf d259589 8960cdf d259589 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 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
) |