File size: 635 Bytes
71d239c | 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 | """The front door: a Gradio chat box for asking questions about your documents."""
import gradio as gr
from generate import answer
from ingest import ingest
def setup():
"""Load and index the documents once when the app starts."""
count = ingest()
return f"Indexed {count} documents."
def on_ask(question):
return answer(question)
with gr.Blocks() as demo:
gr.Markdown("# Ask my documents")
status = gr.Markdown(setup())
question = gr.Textbox(label="Your question")
output = gr.Markdown()
question.submit(on_ask, inputs=question, outputs=output)
if __name__ == "__main__":
demo.launch()
|