llamazookeeper commited on
Commit
db9c5ff
1 Parent(s): 016719e
Files changed (3) hide show
  1. app.py +0 -4
  2. pages/Tesla_Cases.py +11 -12
  3. prompts/main.prompt +1 -1
app.py CHANGED
@@ -1,8 +1,4 @@
1
  import streamlit as st
2
- from llama_index import download_loader, SimpleDirectoryReader, StorageContext, load_index_from_storage
3
- from llama_index import SimpleDirectoryReader, ServiceContext, StorageContext, VectorStoreIndex, download_loader
4
- from llama_index.llms import HuggingFaceLLM
5
- from llama_index.embeddings import HuggingFaceEmbedding
6
 
7
  import torch
8
  torch.set_default_device('cuda')
 
1
  import streamlit as st
 
 
 
 
2
 
3
  import torch
4
  torch.set_default_device('cuda')
pages/Tesla_Cases.py CHANGED
@@ -66,7 +66,7 @@ def get_vector_index(nodes, vector_store):
66
 
67
  def generate_insight(engine, search_string):
68
 
69
- with open("prompts/report.prompt", "r") as f:
70
  template = f.read()
71
 
72
  prompt_template = PromptTemplate(
@@ -88,7 +88,7 @@ def get_query_engine(engine):
88
  QueryEngineTool(
89
  query_engine=engine,
90
  metadata=ToolMetadata(
91
- name="Case Report",
92
  description=f"Provides information about the cases from its case report.",
93
  ),
94
  ),
@@ -111,20 +111,20 @@ os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
111
 
112
 
113
  if OPENAI_API_KEY:
114
- pdfs = st.sidebar.file_uploader("Upload the case report in PDF format", type="pdf")
115
  st.sidebar.info("""
116
  Example pdf reports you can upload here:
117
  """)
118
 
119
  if st.sidebar.button("Process Document"):
120
  with st.spinner("Processing Document..."):
121
- nodes = process_pdf(pdfs)
122
- #st.session_state.index = get_vector_index(nodes, vector_store="faiss")
123
- st.session_state.index = get_vector_index(nodes, vector_store="simple")
124
  st.session_state.process_doc = True
125
  st.toast("Document Processsed!")
126
 
127
- #st.session_state.process_doc = True
128
 
129
  if st.session_state.process_doc:
130
  search_text = st.text_input("Enter your question")
@@ -132,12 +132,11 @@ if OPENAI_API_KEY:
132
  engine = get_query_engine(st.session_state.index.as_query_engine(similarity_top_k=3))
133
  start_time = time.time()
134
 
135
- with st.status("**Analyzing Report...**"):
136
- st.write("Case search result...")
137
- response = generate_insight(engine, search_text)
138
- st.session_state["end_time"] = "{:.2f}".format((time.time() - start_time))
139
 
140
- st.toast("Report Analysis Complete!")
141
 
142
  if st.session_state.end_time:
143
  st.write("Report Analysis Time: ", st.session_state.end_time, "s")
 
66
 
67
  def generate_insight(engine, search_string):
68
 
69
+ with open("prompts/main.prompt", "r") as f:
70
  template = f.read()
71
 
72
  prompt_template = PromptTemplate(
 
88
  QueryEngineTool(
89
  query_engine=engine,
90
  metadata=ToolMetadata(
91
+ name="Alert Report",
92
  description=f"Provides information about the cases from its case report.",
93
  ),
94
  ),
 
111
 
112
 
113
  if OPENAI_API_KEY:
114
+ pptx_files = st.sidebar.file_uploader("Upload the case report in PDF format", type="pptx")
115
  st.sidebar.info("""
116
  Example pdf reports you can upload here:
117
  """)
118
 
119
  if st.sidebar.button("Process Document"):
120
  with st.spinner("Processing Document..."):
121
+ nodes = process_pptx(pptx_files)
122
+ st.session_state.index = get_vector_index(nodes, vector_store="faiss")
123
+ #st.session_state.index = get_vector_index(nodes, vector_store="simple")
124
  st.session_state.process_doc = True
125
  st.toast("Document Processsed!")
126
 
127
+ st.session_state.process_doc = True
128
 
129
  if st.session_state.process_doc:
130
  search_text = st.text_input("Enter your question")
 
132
  engine = get_query_engine(st.session_state.index.as_query_engine(similarity_top_k=3))
133
  start_time = time.time()
134
 
135
+ st.write("Alert search result...")
136
+ response = generate_insight(engine, search_text)
137
+ st.session_state["end_time"] = "{:.2f}".format((time.time() - start_time))
 
138
 
139
+ st.toast("Report Analysis Complete!")
140
 
141
  if st.session_state.end_time:
142
  st.write("Report Analysis Time: ", st.session_state.end_time, "s")
prompts/main.prompt CHANGED
@@ -1,3 +1,3 @@
1
  You are a tesla alert analyzer.
2
- Your job is the is to provide a detailed analysis of the following:
3
 
 
1
  You are a tesla alert analyzer.
2
+ Your job is the is to provide a detailed analysis of the alert and follow-up
3