HarshaBattula commited on
Commit ·
c9433ef
1
Parent(s): 1f5af8e
update interface
Browse files4 unmodified lines5678910111213141528 unmodified lines44454647484950514 unmodified linesfrom chain import *import gradio as grdef chatbot(query):llm_response = qa_chain.run({"query": query})return llm_responsedef load_embeddings_database_from_disk(persistence_directory, embeddings_generator):"""Load a Chroma vector database from disk.28 unmodified linesqa_chain = create_question_answering_chain(retriever)inputs = gr.inputs.Textbox(lines=7, label="Coversational Interface with Chat history")outputs = gr.outputs.Textbox(label="Reply")gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Retrieval Augmented Question Answering",show_progress = True, theme="compact").launch(debug=True)4 unmodified lines567891028 unmodified lines394041424344454647484950515253545556575859606162636465666768694 unmodified linesfrom chain import *import gradio as grdef load_embeddings_database_from_disk(persistence_directory, embeddings_generator):"""Load a Chroma vector database from disk.28 unmodified linesqa_chain = create_question_answering_chain(retriever)def add_text(history, text):history = history + [(text, None)]return history, gr.update(value="", interactive=False)def bot(query):llm_response = qa_chain.run({"query": query[-1][0]})query[-1][1] = llm_responsereturn querywith gr.Blocks() as demo:chatbot = gr.Chatbot([], elem_id="Retrieval Augmented Question Answering").style(height=750)with gr.Row():with gr.Column(scale=0.95):txt = gr.Textbox(show_label=False,placeholder="Enter text and press enter",).style(container=False)txt_msg = txt.submit(add_text, [chatbot, txt], [chatbot, txt], queue=False).then(bot, chatbot, chatbot)txt_msg.then(lambda: gr.update(interactive=True), None, txt, queue=False)demo.launch()
app.py+27-9