seminarLabAI / app.py
inoid's picture
Add several functionalities and associated more logic on UI presentations.
6eed986
raw
history blame
7.2 kB
import gradio as gr
from llm_call import GeminiLLM
from seminar_edition_ai import upload_file_ex, predictContemplando, predictProclamando, predictFromInit, \
downloadSermonFile, fileAddresToDownload, predictQuestionBuild, predictDevotionBuild, \
contemplandoQuestion, proclamandoQuestion, llm, embed_model
HISTORY_ANSWER = ''
with gr.Blocks() as demo:
gr.Markdown("SermonLab AI Demo.")
with gr.Tab("Preparando mi Serm贸n"):
text_input = gr.Textbox(label="T贸pico del serm贸n")
with gr.Accordion("Contemplando y Proclamando", open=False):
checkButton = gr.Checkbox(
value=False,
label="Mantener historial"
)
with gr.Row():
with gr.Tab("Contemplando"):
inbtwContemplando = gr.Button(f"Devocionalmente: {contemplandoQuestion['DEVOCIONALMENTE']}")
inbtwContemplandoOne = gr.Button(f"Ex茅gesis: {contemplandoQuestion['EX脡GESIS']}")
inbtwContemplandoTwo = gr.Button(f"Cristo: {contemplandoQuestion['CRISTO']}")
inbtwContemplandoTree = gr.Button(f"Arco Redentor: {contemplandoQuestion['ARCO REDENTOR']}")
inbtwContemplandoFour = gr.Button(f"Evangeli贸n: {contemplandoQuestion['EVANGELION']}")
inbtwContemplandoFourOne = gr.Button(f"Evangeli贸n: {contemplandoQuestion['EVANGELION_TWO']}")
with gr.Tab("Proclamando"):
inbtwProclamando = gr.Button(f"P煤blico: {proclamandoQuestion['P脷BLICO']}")
inbtwProclamandoOne = gr.Button(f"Historia: {proclamandoQuestion['HISTORIA']}")
inbtwProclamandoTwo = gr.Button(f"Expectativas: {proclamandoQuestion['EXPECTATIVAS']}")
inbtwProclamandoTwoTwo = gr.Button(f"Expectativas: {proclamandoQuestion['EXPECTATIVAS_TWO']}")
text_output = gr.Textbox(label="Respuesta", lines=10)
text_button = gr.Button("Crear")
text_download = gr.DownloadButton(
label="Descargar",
value=fileAddresToDownload,
every=10
)
inbtwContemplando.click(
fn=lambda x: predictContemplando(f"DEVOCIONALMENTE"),
inputs=text_input,
outputs=text_output
)
inbtwContemplandoOne.click(
fn=lambda x: predictContemplando(f"EX脡GESIS"),
inputs=text_input,
outputs=text_output
)
inbtwContemplandoTwo.click(
fn=lambda x: predictContemplando(f"CRISTO"),
inputs=text_input,
outputs=text_output
)
inbtwContemplandoTree.click(
fn=lambda x: predictContemplando(f"ARCO REDENTOR"),
inputs=text_input,
outputs=text_output
)
inbtwContemplandoFour.click(
fn=lambda x: predictContemplando(f"EVANGELION"),
inputs=text_input,
outputs=text_output
)
inbtwContemplandoFourOne.click(
fn=lambda x: predictContemplando(f"EVANGELION_TWO"),
inputs=text_input,
outputs=text_output
)
##---------------------------------------------------------------------
inbtwProclamando.click(
fn=lambda x: predictProclamando(f"P脷BLICO"),
inputs=text_input,
outputs=text_output
)
inbtwProclamandoOne.click(
fn=lambda x: predictProclamando(f"HISTORIA"),
inputs=text_input,
outputs=text_output
)
inbtwProclamandoTwo.click(
fn=lambda x: predictProclamando(f"EXPECTATIVAS"),
inputs=text_input,
outputs=text_output
)
inbtwProclamandoTwoTwo.click(
fn=lambda x: predictProclamando(f"EXPECTATIVAS_TWO"),
inputs=text_input,
outputs=text_output
)
text_button.click(
fn=predictFromInit,
inputs=text_input,
outputs=text_output
)
text_download.click(
fn=downloadSermonFile,
inputs=text_output
)
with gr.Tab("Obtener gu铆a de la comunidad (Preguntas)"):
with gr.Row():
#Bibliografy about components
# File (https://www.gradio.app/docs/gradio/file)
# Download Button (https://www.gradio.app/docs/gradio/downloadbutton)
with gr.Column():
file_input_question = gr.File()
upload_button_question = gr.UploadButton("Click to Upload a File", file_types=['.pdf'],
file_count="multiple")
with gr.Column():
temp_slider_question = gr.Slider(
minimum=1,
maximum=10,
value=1,
step=1,
interactive=True,
label="Preguntas",
)
text_output_question = gr.Textbox(label="Respuesta", lines=10)
text_button_question = gr.Button("Crear gu铆a de preguntas")
text_download_question = gr.DownloadButton(
label="Descargar",
value=fileAddresToDownload,
every=10
)
text_button_question.click(
fn=predictQuestionBuild,
outputs=text_output_question
)
upload_button_question.upload(upload_file_ex, inputs=upload_button_question,
outputs=[file_input_question, text_output_question])
with gr.Tab("Obtener gu铆a de la comunidad (Devocionario)"):
with gr.Row():
#Bibliografy about components
# File (https://www.gradio.app/docs/gradio/file)
# Download Button (https://www.gradio.app/docs/gradio/downloadbutton)
with gr.Column():
file_input_devotions = gr.File()
upload_button_devotion = gr.UploadButton("Click to Upload a File", file_types=['.pdf'],
file_count="multiple")
with gr.Column():
temp_slider_question = gr.Slider(
minimum=1,
maximum=10,
value=1,
step=1,
interactive=True,
label="Cantidad",
)
text_output_devotions = gr.Textbox(label="Respuesta", lines=10)
text_button_devotion = gr.Button("Crear")
text_download_question = gr.DownloadButton(
label="Descargar",
value=fileAddresToDownload,
every=10
)
text_button_devotion.click(
fn=predictDevotionBuild,
outputs=text_output_devotions
)
upload_button_devotion.upload(
upload_file_ex,
inputs=upload_button_devotion,
outputs=
[file_input_devotions, text_output_devotions]
)
if __name__ == "__main__":
llmBuilder = GeminiLLM()
embed_model = llmBuilder.getEmbeddingsModel()
llm = llmBuilder.getLLM()
demo.launch()