davidfearne commited on
Commit
0764ea9
·
verified ·
1 Parent(s): f94111e

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +64 -0
  2. questions.txt.txt +14 -0
  3. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from streamlit_chat import message
3
+ import requests
4
+ import pandas as pd
5
+ import plotly.express as px
6
+ st.set_page_config(layout="wide")
7
+
8
+ API_URL = "http://127.0.0.1:5000/api"
9
+ headers = {"Content-Type": "application/json"}
10
+
11
+ def query(payload):
12
+ response = requests.post(API_URL, headers=headers, json=payload)
13
+ return response.json()
14
+
15
+ def generate_response(user,prompt):
16
+ output = query({"namespace":"virtualEngineer","version":1,"messages":[{"role":user, "content": prompt}]})
17
+ return output
18
+
19
+
20
+ #Creating the chatbot interface
21
+ st.title("Engineering Expert")
22
+ st.caption("This is a proof of concept to demonstrate our Generative Enterprise Knowledge Navigator Cognitive Architecture. This demo contains 170 PDFs from a leading elevator manufacturer and maintenance company. This volume of information represents the maintenance manuals and product documentation for the doors for one generation of their lifts. The solution to this point provided search results, our challenge was to take this knowledge and provide actionable insights first accompanied by the file and page numbers that the information was sourced from.")
23
+ col1, col2 = st.columns(2)
24
+ # Storing the chat
25
+
26
+
27
+ if 'generated' not in st.session_state:
28
+ st.session_state['generated'] = []
29
+
30
+ if 'past' not in st.session_state:
31
+ st.session_state['past'] = []
32
+
33
+ with col1:
34
+ with st.form(key='my_form'):
35
+ User = st.text_input("Step 1 Set Engeineer Name","", key="user")
36
+ input_text = st.text_input("Step 2 How can I help today?","", key="input")
37
+ submit_button = st.form_submit_button(label='Submit')
38
+ if submit_button:
39
+ output = generate_response(User,input_text)
40
+ # store the output
41
+ st.session_state.past.append(input_text)
42
+ st.session_state.generated.append(output['choices'][0]['message']['content'])
43
+ df = pd.DataFrame(output["sources"])
44
+ fig = px.scatter(df, y="Score",color="Source", hover_data=['Insight'])
45
+ fig.update_layout(showlegend=False)
46
+ # Layout the columns
47
+
48
+ st.subheader("Response Data")
49
+ st.caption(f"Overall Answer Confidence: {output['accuracy']}%")
50
+ st.caption(f"Time Taken: {round(output['timeTaken'],1)} Seconds")
51
+ st.caption(f"Cognitive Cache Hit: {output['cacheHit']}")
52
+ st.caption('The below chart shows the distribution of knowledge in the knowledge store. This is used to supply expert information to answer your specific question. We request the top 100 results to speed up this demo, but analysing the knowledge store is an important part of maintaining high quality knowledge base which is key to high alignment, minimising hallucinations and ensuring safety.')
53
+ st.plotly_chart(fig, theme=None, use_container_width=True)
54
+ st.caption('Sources:')
55
+ st.caption('This table represents the books and their page numbers that were used to create the expert answer')
56
+ st.table(df.loc[:, ['Score', 'Source', 'startpage']].head(5))
57
+ if st.session_state['generated']:
58
+
59
+ for i in range(len(st.session_state['generated'])-1, -1, -1):
60
+ with col2:
61
+
62
+ message(st.session_state["generated"][i], key=str(i),avatar_style="identicon",seed="Socks")
63
+ message(st.session_state['past'][i], is_user=True, key=str(i) + '_user',avatar_style="identicon",seed="Mittens")
64
+
questions.txt.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 1. **how do I identify different variations of the Elevonic Modernization controllers?
2
+ 2. **how do I read the event logs of when performing maintenance
3
+ 3. what kind of boards are used in 9700 escalators and moving walks now?
4
+ 4. I have a G2S with a bad roller guide. What is the part number
5
+ 5. I have a Pulse unit and need troubleshooting info. I heard there might be a video?
6
+ 6. I’m installing a Glide A, how do I set it up?
7
+ 7. I have a Gen 2, how do I setup load cell?
8
+ 8. I’m installing a mod, I think I got the wrong encoder cable.
9
+ 9. I have a drive fault 402.
10
+ 10. How do I add card reader security.
11
+ 11. My ACP relay is toggling off and on.
12
+ 12. My Pulse unit has a bad wiring harness/connector, what is the part number?
13
+ 13. What is the part number for a Bat Ram chip on a 411M-MS?
14
+ **Good pair for demoing one after the other
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ requests
2
+ streamlit-chat
3
+ streamlit
4
+ pandas
5
+ plotly