Spaces:
Runtime error
Runtime error
| import os | |
| os.environ["OPENAI_API_KEY"] | |
| from llama_index import VectorStoreIndex, SimpleDirectoryReader | |
| import os.path | |
| from llama_index import ( | |
| VectorStoreIndex, | |
| SimpleDirectoryReader, | |
| StorageContext, | |
| load_index_from_storage, | |
| ) | |
| # load the existing index | |
| PERSIST_DIR = "./storage" | |
| storage_context = StorageContext.from_defaults(persist_dir=PERSIST_DIR) | |
| index = load_index_from_storage(storage_context) | |
| import gradio as gr | |
| def nishauri(question): | |
| query_engine = index.as_query_engine() | |
| response = query_engine.query(question) | |
| return response | |
| demo = gr.Interface( | |
| title = "Nishauri Chatbot Demo", | |
| fn=nishauri, | |
| inputs=["text"], | |
| outputs=["text"], | |
| ) | |
| demo.launch() | |