Spaces:
Sleeping
Sleeping
File size: 2,392 Bytes
bd37926 b092604 bd37926 b092604 bd37926 b092604 bd37926 b092604 bd37926 b092604 bd37926 b092604 bd37926 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
from dotenv import load_dotenv
import streamlit as st
import os
from utils._graph_util import run_customer_support
# Initialize categories in session state
if "categories" not in st.session_state:
st.session_state.categories = {
"HR": [],
"IT": [],
"Transportation": [],
"Other": []
}
def main():
load_dotenv()
# Add detailed API key verification
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
st.error("β OpenAI API key not found! Please ensure it's set in the environment variables.")
st.info("To set up your API key:")
st.code("1. Go to Hugging Face Space settings\n2. Add OPENAI_API_KEY in Repository Secrets")
st.stop()
# Page configuration
st.set_page_config(
page_title="Intelligent Customer Support Agent",
page_icon="π€",
layout="wide"
)
# Sidebar for API key
with st.sidebar:
#openai_api_key = st.text_input("OpenAI API Key", type="password")
st.markdown("---")
st.markdown("""
### About
This is an AI-powered customer support agent that can answer questions or raise support ticket about the company policies and procedures:
- HR policies
- IT policies
- Transportation policies
- Other policies
""")
# Main chat interface
st.title("π€ Intelligent Customer Support Agent")
st.caption("Your 24/7 AI Customer Service Representative")
st.header("Automatic Ticket Classification Tool")
#Capture user input
st.write("We are here to help you, please ask your question:")
prompt = st.text_input("π")
if prompt:
if "vector_store" not in st.session_state:
st.error("Please load the document data first!")
st.stop()
response = run_customer_support(prompt)
st.write(response.get("response"))
#Button to create a ticket with respective department
button = st.button("Submit ticket?")
if button:
category = response.get("category")
st.session_state.categories[category].append(prompt)
st.success("Ticket submitted successfully!")
# Display category (optional)
st.write(f"Category: {category}")
if __name__ == '__main__':
main()
|