mgupta70 commited on
Commit
74b36f6
1 Parent(s): 2288687

new_Version

Browse files
Files changed (1) hide show
  1. app.py +45 -0
app.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader
2
+ import os
3
+ import time
4
+ from llama_index.node_parser import SimpleNodeParser
5
+ from llama_index import StorageContext, load_index_from_storage
6
+ import gradio as gr
7
+ import openai
8
+
9
+ os.environ['OPENAI_API_KEY'] = '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'
10
+
11
+ # rebuild storage context
12
+ storage_context = StorageContext.from_defaults(persist_dir="index_dir")
13
+
14
+ # load index
15
+ index = load_index_from_storage(storage_context)
16
+
17
+ # strat a search engine
18
+ query_engine = index.as_query_engine()
19
+
20
+
21
+
22
+ # APP
23
+
24
+ def get_model_reply_no_prev_context(question):
25
+ response = query_engine.query(question)
26
+ final_response = response.response[1:]
27
+ return final_response
28
+
29
+ title = "Knowledge Center at Penta Building Group"
30
+ description = """
31
+ The program is trained to answer questions based on the documentation of 'Lessons Learned' from previous projects!
32
+
33
+ """
34
+
35
+ article = "Your feedback matters!If you like it, contact me at mgupta70@asu.edu"
36
+
37
+ gr.Interface(
38
+ fn=get_model_reply_no_prev_context,
39
+ inputs="textbox",
40
+ outputs="text",
41
+ title=title,
42
+ description=description,
43
+ article=article,
44
+ examples=[["Which code is to be used while planning a pedestrian walkway?"], ["What is AHJ?"]], live=True
45
+ ).launch(share=True)