Spaces:
Running
Running
geekyrakshit
commited on
Commit
Β·
a645df8
1
Parent(s):
9269c10
add: made app multi-page
Browse files- README.md +1 -1
- app.py +16 -0
- chat_app.py β application_pages/chat_app.py +4 -6
- application_pages/evaluation_app.py +3 -0
- application_pages/intro_page.py +7 -0
README.md
CHANGED
@@ -16,5 +16,5 @@ source .venv/bin/activate
|
|
16 |
## Run Chat App
|
17 |
|
18 |
```bash
|
19 |
-
OPENAI_API_KEY="YOUR_OPENAI_API_KEY" streamlit run
|
20 |
```
|
|
|
16 |
## Run Chat App
|
17 |
|
18 |
```bash
|
19 |
+
OPENAI_API_KEY="YOUR_OPENAI_API_KEY" streamlit run app.py
|
20 |
```
|
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
intro_page = st.Page(
|
4 |
+
"application_pages/intro_page.py", title="Introduction", icon=":material/guardian:"
|
5 |
+
)
|
6 |
+
chat_page = st.Page(
|
7 |
+
"application_pages/chat_app.py", title="Chat", icon=":material/robot:"
|
8 |
+
)
|
9 |
+
evaluation_page = st.Page(
|
10 |
+
"application_pages/evaluation_app.py",
|
11 |
+
title="Evaluation",
|
12 |
+
icon=":material/monitoring:",
|
13 |
+
)
|
14 |
+
page_navigation = st.navigation([intro_page, chat_page, evaluation_page])
|
15 |
+
st.set_page_config(page_title="Guardrails Genie", page_icon=":material/guardian:")
|
16 |
+
page_navigation.run()
|
chat_app.py β application_pages/chat_app.py
RENAMED
@@ -10,12 +10,16 @@ from guardrails_genie.llm import OpenAIModel
|
|
10 |
load_dotenv()
|
11 |
weave.init(project_name="guardrails-genie")
|
12 |
|
|
|
|
|
13 |
if "guardrails" not in st.session_state:
|
14 |
st.session_state.guardrails = []
|
15 |
if "guardrail_names" not in st.session_state:
|
16 |
st.session_state.guardrail_names = []
|
17 |
if "guardrails_manager" not in st.session_state:
|
18 |
st.session_state.guardrails_manager = None
|
|
|
|
|
19 |
|
20 |
|
21 |
def initialize_guardrails():
|
@@ -63,15 +67,9 @@ guardrail_names = st.sidebar.multiselect(
|
|
63 |
)
|
64 |
st.session_state.guardrail_names = guardrail_names
|
65 |
|
66 |
-
# Use session state to track if the chat has started
|
67 |
-
if "chat_started" not in st.session_state:
|
68 |
-
st.session_state.chat_started = False
|
69 |
-
|
70 |
-
# Start chat when button is pressed
|
71 |
if st.sidebar.button("Start Chat") and chat_condition:
|
72 |
st.session_state.chat_started = True
|
73 |
|
74 |
-
# Display chat UI if chat has started
|
75 |
if st.session_state.chat_started:
|
76 |
with st.sidebar.status("Initializing Guardrails..."):
|
77 |
initialize_guardrails()
|
|
|
10 |
load_dotenv()
|
11 |
weave.init(project_name="guardrails-genie")
|
12 |
|
13 |
+
st.title(":material/robot: Guardrails Genie")
|
14 |
+
|
15 |
if "guardrails" not in st.session_state:
|
16 |
st.session_state.guardrails = []
|
17 |
if "guardrail_names" not in st.session_state:
|
18 |
st.session_state.guardrail_names = []
|
19 |
if "guardrails_manager" not in st.session_state:
|
20 |
st.session_state.guardrails_manager = None
|
21 |
+
if "chat_started" not in st.session_state:
|
22 |
+
st.session_state.chat_started = False
|
23 |
|
24 |
|
25 |
def initialize_guardrails():
|
|
|
67 |
)
|
68 |
st.session_state.guardrail_names = guardrail_names
|
69 |
|
|
|
|
|
|
|
|
|
|
|
70 |
if st.sidebar.button("Start Chat") and chat_condition:
|
71 |
st.session_state.chat_started = True
|
72 |
|
|
|
73 |
if st.session_state.chat_started:
|
74 |
with st.sidebar.status("Initializing Guardrails..."):
|
75 |
initialize_guardrails()
|
application_pages/evaluation_app.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
st.title(":material/monitoring: Evaluation")
|
application_pages/intro_page.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
st.title("π§ββοΈ Guardrails Genie")
|
4 |
+
|
5 |
+
st.write(
|
6 |
+
"Guardrails-Genie is a tool that helps you implement guardrails in your LLM applications."
|
7 |
+
)
|