import os import time import gradio as gr import openai from llama_index import GPTSimpleVectorIndex, Document, SimpleDirectoryReader #from Crypto.Cipher import AES os.environ['OPENAI_API_KEY'] = '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' filename = 'Penta_index_demo.json' index = GPTSimpleVectorIndex.load_from_disk('./{}'.format(filename)) def get_model_reply_no_prev_context(query): response = index.query(query) final_response = response.response return final_response # App title = "Knowledge Center at Penta Building Group" description = """ The program is trained to answer questions based on the documentation of 'Lessons Learned' from previous projects! """ article = "Your feedback matters!If you like it, contact me at mgupta70@asu.edu" gr.Interface( fn=get_model_reply_no_prev_context, inputs="textbox", outputs="text", title=title, description=description, article=article, examples=[["Which code is to be used while planning a pedestrian walkway?"], ["What is AHJ?"]], live=True ).launch(share=True)