Spaces:
Runtime error
Runtime error
Commit ·
3495719
1
Parent(s): 70cebce
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dotenv import load_dotenv
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from user_utils import *
|
| 4 |
+
|
| 5 |
+
#Creating session variables
|
| 6 |
+
if 'HR_tickets' not in st.session_state:
|
| 7 |
+
st.session_state['HR_tickets'] =[]
|
| 8 |
+
if 'IT_tickets' not in st.session_state:
|
| 9 |
+
st.session_state['IT_tickets'] =[]
|
| 10 |
+
if 'Transport_tickets' not in st.session_state:
|
| 11 |
+
st.session_state['Transport_tickets'] =[]
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def main():
|
| 15 |
+
load_dotenv()
|
| 16 |
+
|
| 17 |
+
st.header("Automatic Ticket Classification Tool")
|
| 18 |
+
#Capture user input
|
| 19 |
+
st.write("We are here to help you, please ask your question:")
|
| 20 |
+
user_input = st.text_input("🔍")
|
| 21 |
+
|
| 22 |
+
if user_input:
|
| 23 |
+
|
| 24 |
+
#creating embeddings instance
|
| 25 |
+
embeddings=create_embeddings()
|
| 26 |
+
|
| 27 |
+
#Function to pull index data from Pinecone
|
| 28 |
+
index=pull_from_pinecone("e697b71c-d5ed-4c66-8625-ac1c403a2df1","us-west1-gcp-free","tickets",embeddings)
|
| 29 |
+
|
| 30 |
+
#This function will help us in fetching the top relevent documents from our vector store - Pinecone Index
|
| 31 |
+
relavant_docs=get_similar_docs(index,user_input)
|
| 32 |
+
|
| 33 |
+
#This will return the fine tuned response by LLM
|
| 34 |
+
response=get_answer(relavant_docs,user_input)
|
| 35 |
+
st.write(response)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
#Button to create a ticket with respective department
|
| 39 |
+
button = st.button("Submit ticket?")
|
| 40 |
+
|
| 41 |
+
if button:
|
| 42 |
+
#Get Response
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
embeddings = create_embeddings()
|
| 46 |
+
query_result = embeddings.embed_query(user_input)
|
| 47 |
+
|
| 48 |
+
#loading the ML model, so that we can use it to predit the class to which this compliant belongs to...
|
| 49 |
+
department_value = predict(query_result)
|
| 50 |
+
st.write("your ticket has been sumbitted to : "+department_value)
|
| 51 |
+
|
| 52 |
+
#Appending the tickets to below list, so that we can view/use them later on...
|
| 53 |
+
if department_value=="HR":
|
| 54 |
+
st.session_state['HR_tickets'].append(user_input)
|
| 55 |
+
elif department_value=="IT":
|
| 56 |
+
st.session_state['IT_tickets'].append(user_input)
|
| 57 |
+
else:
|
| 58 |
+
st.session_state['Transport_tickets'].append(user_input)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
if __name__ == '__main__':
|
| 63 |
+
main()
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|