Spaces:
Sleeping
Sleeping
File size: 9,473 Bytes
13c8e0f 6eed986 5a99733 6eed986 13c8e0f f757ba6 13c8e0f a6e1323 31b8b6f c6ff19b 9a95e09 4dc2082 c1c1b7e be9b691 c1c1b7e 5a99733 4dc2082 f757ba6 7da74a7 f757ba6 a6e1323 f757ba6 6eed986 f757ba6 a6e1323 f757ba6 6eed986 a6e1323 6eed986 f757ba6 5a99733 a6e1323 6eed986 f757ba6 6eed986 f757ba6 6eed986 f757ba6 6eed986 f757ba6 6eed986 f757ba6 6eed986 f757ba6 6eed986 f757ba6 6eed986 f757ba6 6eed986 f757ba6 6eed986 f757ba6 6eed986 f757ba6 6eed986 f757ba6 6eed986 2bc433a 7da74a7 179f2c8 85e8973 2bc433a 7da6d10 2bc433a dc884c4 85e8973 8bf2dd6 85e8973 dc884c4 578d2af 2bc433a 4dc2082 578d2af 7da6d10 8bf2dd6 4dc2082 f9d4718 4dc2082 f9d4718 4dc2082 7da74a7 4dc2082 6eed986 f9d4718 419cc7b 8bf2dd6 6eed986 f757ba6 6eed986 6b46211 2a563da f757ba6 8b249e4 |
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
import gradio as gr
from llm_call import GeminiLLM
from seminar_edition_ai import upload_file_ex, predictContemplando, predictProclamando, predictFromInit, \
downloadSermonFile, fileAddresToDownload, predictQuestionBuild, predictDevotionBuild, predictArgumentQuestionBuild, \
contemplandoQuestion, proclamandoQuestion, llm, embed_model
HISTORY_ANSWER = ''
llmModel = None
def activeSermonGuideZone(KEY):
#print("Button show " + buttonEvent.label)
return {text_button: gr.update (interactive = True), question_option: [KEY]}
def showMessage(questionAnswer, KEY):
if questionAnswer == None or questionAnswer == '' or len(questionAnswer) <= 7:
raise gr.Error(f"You must write some answer or more longer {KEY}")
else:
try:
return predictArgumentQuestionBuild(questionAnswer)
except Exception as e:
raise gr.Error(f" Error on call AI {e}!!!")
with gr.Blocks() as demo:
gr.Markdown("SermonLab AI Demo.")
llmModelState = gr.State([llmModel])
with gr.Tab("Preparando mi Serm贸n"):
text_input = gr.Textbox(label="T贸pico del serm贸n")
text_output = gr.Textbox(label="Respuesta", lines = 10)
text_button = gr.Button("Crear")
text_download = gr.DownloadButton(
label="Descargar",
value = fileAddresToDownload,
every=10
)
text_button.click(
fn = predictFromInit,
inputs =[ text_input, llmModelState],
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]
)
with gr.Tab("Contemplando y Proclamando (Gu铆a de preguntas)"):
question_option = gr.State([])
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']}")
with gr.Row():
with gr.Column(scale = 2):
#Answer for Contemplando y Proclamando questions
text_output_guia = gr.Textbox(label="Respuesta", lines = 10)
with gr.Column(scale = 1, min_width = 200):
text1 = gr.Textbox(visible = False)
#Button for calling AI Help
text_button = gr.Button("Buscar m谩s informaci贸n (IA)",
min_width = 200,
interactive = False
)
text2 = gr.Textbox(visible = False)
with gr.Column(scale = 2):
text_output_aiAnswer = gr.Textbox(label="Ayuda a mi respuesta", lines = 10)
inbtwContemplando.click(
fn = lambda x: activeSermonGuideZone(contemplandoQuestion['DEVOCIONALMENTE']),
inputs = inbtwContemplandoOne,
outputs = [text_button, question_option]
)
inbtwContemplandoOne.click(
fn = lambda x: activeSermonGuideZone(contemplandoQuestion['EX脡GESIS']),
inputs = inbtwContemplandoOne,
outputs = [text_button, question_option]
)
inbtwContemplandoTwo.click(
fn = lambda x: activeSermonGuideZone(contemplandoQuestion['CRISTO']),
inputs = inbtwContemplandoOne,
outputs = [text_button, question_option]
)
inbtwContemplandoTree.click(
fn = lambda x: activeSermonGuideZone(contemplandoQuestion['ARCO REDENTOR']),
inputs = inbtwContemplandoOne,
outputs = [text_button, question_option]
)
inbtwContemplandoFour.click(
fn = lambda x: activeSermonGuideZone(contemplandoQuestion['EVANGELION']),
inputs = inbtwContemplandoOne,
outputs = [text_button, question_option]
)
inbtwContemplandoFourOne.click(
fn = lambda x: activeSermonGuideZone(contemplandoQuestion['EVANGELION_TWO']),
inputs = inbtwContemplandoOne,
outputs = [text_button, question_option]
)
#####---------------------------------------------------------------------------------------------------------
inbtwProclamando.click(
fn = lambda x: activeSermonGuideZone(proclamandoQuestion['P脷BLICO']),
inputs = inbtwContemplandoOne,
outputs = [text_button, question_option]
)
inbtwProclamandoOne.click(
fn = lambda x: activeSermonGuideZone(proclamandoQuestion['HISTORIA']),
inputs = inbtwContemplandoOne,
outputs = [text_button, question_option]
)
inbtwProclamandoTwo.click(
fn = lambda x: activeSermonGuideZone(proclamandoQuestion['EXPECTATIVAS']),
inputs = inbtwContemplandoOne,
outputs = [text_button, question_option]
)
inbtwProclamandoTwoTwo.click(
fn = lambda x: activeSermonGuideZone(proclamandoQuestion['EXPECTATIVAS_TWO']),
inputs = inbtwContemplandoOne,
outputs = [text_button, question_option]
)
text_button.click(fn = showMessage, inputs = [text_output_guia, question_option], outputs = text_output_aiAnswer)
if __name__ == "__main__":
llmBuilder = GeminiLLM()
embed_model = llmBuilder.getEmbeddingsModel()
#global llmModel
demo.launch(share=True)
|