Update app.py
Browse files
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 |
-
|
|
|
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 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|