Spaces:
Sleeping
Sleeping
luisrosado100 commited on
Commit ·
71a4de1
1
Parent(s): 9f686be
Add ITSM RAG chatbot frontend
Browse files- .streamlit/secrets.toml +2 -0
- requirements.txt +2 -3
- streamlit_app.py +62 -0
.streamlit/secrets.toml
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[API_ENDPOINT]
|
| 2 |
+
value = "https://3nmcc1yzsj.execute-api.us-east-1.amazonaws.com/prod/chat"
|
requirements.txt
CHANGED
|
@@ -1,3 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
streamlit
|
|
|
|
| 1 |
+
streamlit==1.28.0
|
| 2 |
+
requests==2.31.0
|
|
|
streamlit_app.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
st.set_page_config(page_title="ITSM RAG Chatbot", layout="wide")
|
| 6 |
+
st.title("📚 ITSM Operational Assistant")
|
| 7 |
+
st.markdown("Ask questions about IT support procedures, policies, and troubleshooting steps.")
|
| 8 |
+
|
| 9 |
+
API_ENDPOINT = st.secrets.get("API_ENDPOINT", "https://3nmcc1yzsj.execute-api.us-east-1.amazonaws.com/prod/chat")
|
| 10 |
+
|
| 11 |
+
# Initialize session state
|
| 12 |
+
if "messages" not in st.session_state:
|
| 13 |
+
st.session_state.messages = []
|
| 14 |
+
|
| 15 |
+
# Sidebar with example queries
|
| 16 |
+
with st.sidebar:
|
| 17 |
+
st.header("Example Queries")
|
| 18 |
+
if st.button("Troubleshoot dashboard widget"):
|
| 19 |
+
st.session_state.query = "How do I troubleshoot dashboard widget issue?"
|
| 20 |
+
if st.button("Outbound email troubleshooting"):
|
| 21 |
+
st.session_state.query = " Help me troubleshoot outbound email delivery failures in the HelioMail service"
|
| 22 |
+
if st.button("Nimbus Flow connectivity issue"):
|
| 23 |
+
st.session_state.query = "How do I troubleshoot NimbusFlow desktop app connectivity"
|
| 24 |
+
|
| 25 |
+
# Main chat interface
|
| 26 |
+
with st.form("chat_form"):
|
| 27 |
+
user_input = st.text_input("Your question:", key="query")
|
| 28 |
+
submit = st.form_submit_button("Send")
|
| 29 |
+
|
| 30 |
+
if submit and user_input:
|
| 31 |
+
st.session_state.messages.append({"role": "user", "content": user_input})
|
| 32 |
+
|
| 33 |
+
with st.spinner("Retrieving answer..."):
|
| 34 |
+
try:
|
| 35 |
+
response = requests.post(
|
| 36 |
+
API_ENDPOINT,
|
| 37 |
+
json={"query": user_input},
|
| 38 |
+
timeout=30
|
| 39 |
+
)
|
| 40 |
+
if response.status_code == 200:
|
| 41 |
+
result = response.json()
|
| 42 |
+
answer = result['answer']
|
| 43 |
+
sources = result.get('sources', [])
|
| 44 |
+
|
| 45 |
+
st.session_state.messages.append({
|
| 46 |
+
"role": "assistant",
|
| 47 |
+
"content": answer,
|
| 48 |
+
"sources": sources
|
| 49 |
+
})
|
| 50 |
+
else:
|
| 51 |
+
st.error(f"API error: {response.status_code}")
|
| 52 |
+
except Exception as e:
|
| 53 |
+
st.error(f"Error: {str(e)}")
|
| 54 |
+
|
| 55 |
+
# Display conversation
|
| 56 |
+
for msg in st.session_state.messages:
|
| 57 |
+
with st.chat_message(msg["role"]):
|
| 58 |
+
st.write(msg["content"])
|
| 59 |
+
if msg["role"] == "assistant" and "sources" in msg:
|
| 60 |
+
with st.expander("📖 Sources"):
|
| 61 |
+
for source in msg["sources"]:
|
| 62 |
+
st.caption(f"• {source}")
|