import gradio as gr import random import time import os from llama_index import GPTSimpleVectorIndex with gr.Blocks() as demo: chatbot = gr.Chatbot() msg = gr.Textbox() clear = gr.Button("Clear") def respond(message, chat_history): bot_message = str(index.query(message)).strip() chat_history.append((message, bot_message)) return "", chat_history msg.submit(respond, [msg, chatbot], [msg, chatbot]) clear.click(lambda: None, None, chatbot, queue=False) if __name__ == "__main__": global index index = GPTSimpleVectorIndex.load_from_disk('email.json') demo.launch()