|
from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader |
|
import os |
|
from llama_index.node_parser import SimpleNodeParser |
|
from llama_index import StorageContext, load_index_from_storage |
|
import gradio as gr |
|
import openai |
|
|
|
os.environ['OPENAI_API_KEY'] = os.environ["my_key"] |
|
|
|
|
|
storage_context = StorageContext.from_defaults(persist_dir="index_dir_full") |
|
|
|
|
|
index = load_index_from_storage(storage_context) |
|
|
|
|
|
query_engine = index.as_query_engine() |
|
|
|
|
|
|
|
|
|
|
|
def get_model_reply_no_prev_context(question): |
|
response = query_engine.query(question) |
|
final_response = response.response[1:] |
|
return final_response |
|
|
|
title = """ |
|
<center> |
|
Knowledge Center at Penta Building Group |
|
<img src= "https://pbs.twimg.com/profile_images/2463734643/1q8btct2spnez5nz158l_400x400.jpeg" width=200px> |
|
</center> |
|
""" |
|
|
|
description = """ |
|
<p><b>The idea of this project is to build an ‘AI’ program which by reading through documentation of a company’s projects of the last 10-30 years would consolidate its learning in one place. This ‘intelligent’ program can now assist a PE/PM/anyone in taking decisions which is reflective of the company’s previous experiences and its possible benefits and repercussions. </b></p> |
|
|
|
<p>This program is designed to answer questions based on the documentation of 'Lessons Learned' at <a href="https://www.pentabldggroup.com/">The Penta Building Group</a>, USA. Lessons Learned captures significant events that happened during a project or an initiative. It includes assessment of what worked well and what did not. This helps an organization to avoid repeating mistakes and improve their decision-making process using their own data. The current documentation of Lessons Learned used for this program includes some experiences of Penta in <b> walkway construction, demolition activities, ADA compliance, Fireproofing</b>, etc.</p> |
|
""" |
|
|
|
article = """Your feedback matters!If you like it, contact us at mgupta70@asu.edu. |
|
\n<b>Limitations:</b> \n 1. Current version of program is built upon a very limited size of data. So, it will not be able to respond to many queries related to construction industry. Also, if the subject of discussion is not present in detail in the training documents, one can expect a brief response.\n |
|
2. In case response includes numbers like building codes/year, it is generally recommended to double-check the validity of the response because sometimes the program can give an incorrect 'numerical' output. However, we think that the performance of the model in this regard can easily be improved by increasing the size of database. |
|
|
|
""" |
|
|
|
gr.Interface( |
|
fn=get_model_reply_no_prev_context, |
|
inputs="textbox", |
|
outputs="text", |
|
title=title, |
|
description=description, |
|
article=article, |
|
examples=[["What codal provisions should be used while planning a pedestrian walkway?"], ["How to determine the exact location of existing underground lines?"], ['What one should do to avoid struck-by hazard incidents?']] |
|
).launch() |
|
|
|
|
|
|
|
|