import llama_index from llama_index import SimpleDirectoryReader, GPTVectorStoreIndex ,StorageContext,load_index_from_storage import os import gradio as gr os.environ["OPENAI_API_KEY"] = "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" storage_context = StorageContext.from_defaults(persist_dir="mustafaKemalAtatürk.txt") index = load_index_from_storage(storage_context) #prompt = "What is this text about" #result = index.as_query_engine().query(prompt) def query(prompt): result = index.as_query_engine().query(prompt) return result with gr.Blocks() as demo: prompt = gr.Textbox(label="Questions or query", placeholder="what is your query") output = gr.Textbox() query_btn = gr.Button("query") query_btn.click(query, prompt, output) demo.launch()