gutai123 commited on
Commit
793190e
Β·
verified Β·
1 Parent(s): f59ac2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -24
app.py CHANGED
@@ -1,37 +1,43 @@
1
  from dotenv import load_dotenv
2
  import streamlit as st
3
  from user_utils import *
4
-
5
- #Creating session variables
6
-
7
-
8
 
9
  def main():
 
10
  load_dotenv()
11
 
12
  st.header("Automatic Ticket Classification Tool")
13
- #Capture user input
 
14
  st.write("We are here to help you, please ask your question:")
15
  user_input = st.text_input("πŸ”")
16
 
17
  if user_input:
18
-
19
- #creating embeddings instance...
20
- embeddings=create_embeddings()
21
-
22
- #Function to pull index data from Pinecone
23
-
24
- index=pull_from_pinecone("pcsk_4etRhj_Lc37c2KWzUgdTSPaShQKgxeZvC331qJcVWjK9LfpDARwkG23kXZoN5ZCHVLyYWZ","gcp-starter","ticket",embeddings)
25
-
26
- #This function will help us in fetching the top relevent documents from our vector store - Pinecone Index
27
- relavant_docs=get_similar_docs(index,user_input)
28
-
29
-
30
- st.write(relavant_docs)
31
-
32
-
33
-
34
- if __name__ == '__main__':
 
 
 
 
 
 
 
 
 
35
  main()
36
-
37
-
 
1
  from dotenv import load_dotenv
2
  import streamlit as st
3
  from user_utils import *
4
+ from pinecone import PineconeClient
 
 
 
5
 
6
  def main():
7
+ # Load environment variables
8
  load_dotenv()
9
 
10
  st.header("Automatic Ticket Classification Tool")
11
+
12
+ # Capture user input
13
  st.write("We are here to help you, please ask your question:")
14
  user_input = st.text_input("πŸ”")
15
 
16
  if user_input:
17
+ try:
18
+ # Create embeddings instance
19
+ embeddings = create_embeddings()
20
+
21
+ # Fetch the Pinecone index using the API key and environment info
22
+ index = pull_from_pinecone(
23
+ "pcsk_4etRhj_Lc37c2KWzUgdTSPaShQKgxeZvC331qJcVWjK9LfpDARwkG23kXZoN5ZCHVLyYWZ",
24
+ "gcp-starter",
25
+ "ticket",
26
+ embeddings
27
+ )
28
+
29
+ # Fetch the relevant documents based on the user input
30
+ relevant_docs = get_similar_docs(index, user_input)
31
+
32
+ # Display the relevant documents
33
+ if relevant_docs:
34
+ st.write("Relevant Documents:")
35
+ for doc in relevant_docs:
36
+ st.write(doc)
37
+ else:
38
+ st.write("No relevant documents found.")
39
+ except Exception as e:
40
+ st.write(f"An error occurred: {e}")
41
+
42
+ if __name__ == "__main__":
43
  main()