import gradio as gr
from module.bible_index import BibleIndex
def query_index(query, testament, top_n):
_index = BibleIndex(testament)
items = _index.query(query, top_n=top_n)
item_list = f"
{query}
"
item_list += ""
for item in items:
item_list += f"{item.get('src')}
"
item_list += f"- {item.get('text')}
"
item_list += "
"
return item_list
demo = gr.Interface(
query_index,
[
gr.Textbox(label="Query text"),
gr.Radio(["all", "old", "new"], label="Section of the Bible"),
gr.Slider(0, 10, step=1, label="Top N results"),
],
outputs="html",
examples=[
["What is love", "new", 5],
["How old was Adam?", "old", 3],
["Who is God?", "all", 7],
],
title="Bible Search Index",
description="""
A search index for The Bible using *sentence_transformer*.
""",
)
demo.launch()