geekyrakshit commited on
Commit
98a3259
·
1 Parent(s): 15915d9

add: eval page to app

Browse files
Files changed (4) hide show
  1. .gitignore +2 -1
  2. README.md +1 -1
  3. app.py +1 -1
  4. application_pages/evaluation_app.py +38 -0
.gitignore CHANGED
@@ -164,4 +164,5 @@ cython_debug/
164
  cursor_prompts/
165
  uv.lock
166
  test.py
167
- temp.txt
 
 
164
  cursor_prompts/
165
  uv.lock
166
  test.py
167
+ temp.txt
168
+ **.csv
README.md CHANGED
@@ -10,7 +10,7 @@ cd guardrails-genie
10
  pip install -u pip uv
11
  uv venv
12
  # If you want to install for torch CPU, uncomment the following line
13
- # export PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cpu
14
  uv pip install -e .
15
  source .venv/bin/activate
16
  ```
 
10
  pip install -u pip uv
11
  uv venv
12
  # If you want to install for torch CPU, uncomment the following line
13
+ # export PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cpu"
14
  uv pip install -e .
15
  source .venv/bin/activate
16
  ```
app.py CHANGED
@@ -13,4 +13,4 @@ evaluation_page = st.Page(
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()
 
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()
application_pages/evaluation_app.py CHANGED
@@ -1,3 +1,41 @@
 
1
  import streamlit as st
 
 
 
 
 
2
 
3
  st.title(":material/monitoring: Evaluation")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
  import streamlit as st
3
+ import weave
4
+ from dotenv import load_dotenv
5
+
6
+ load_dotenv()
7
+ weave.init(project_name="guardrails-genie")
8
 
9
  st.title(":material/monitoring: Evaluation")
10
+
11
+ if "start_evaluation" not in st.session_state:
12
+ st.session_state.start_evaluation = False
13
+ if "ref" not in st.session_state:
14
+ st.session_state.ref = None
15
+
16
+ uploaded_file = st.sidebar.file_uploader("Choose a CSV file", type="csv")
17
+ dataset_name = st.sidebar.text_input("Dataset name", value="")
18
+ visualize_in_app = st.sidebar.toggle("Visualize in app", value=False)
19
+
20
+ if uploaded_file is not None:
21
+ with st.expander("Dataset Preview"):
22
+ dataframe = pd.read_csv(uploaded_file)
23
+ data_list = dataframe.to_dict(orient="records")
24
+
25
+ if dataset_name != "":
26
+ dataset = weave.Dataset(name=dataset_name, rows=data_list)
27
+ st.session_state.ref = weave.publish(dataset)
28
+ st.write(
29
+ f"Dataset published at https://wandb.ai/{st.session_state.ref.entity}/{st.session_state.ref.project}/weave/objects/{st.session_state.ref.name}/versions/{st.session_state.ref._digest}"
30
+ )
31
+
32
+ if visualize_in_app:
33
+ st.dataframe(data_list)
34
+ # dataset = weave.ref("weave:///geekyrakshit/guardrails-genie/object/sample-dataset:RvdLm7KZ5KXFGcXUHWMGoJBWRVmdxiH6VgWu4cpsDHM").get()
35
+
36
+ run_evaluation_button = st.sidebar.button("Run Evaluation")
37
+ st.session_state.start_evaluation = run_evaluation_button
38
+
39
+ if st.session_state.start_evaluation:
40
+ with st.expander("Evaluation Results"):
41
+ st.write("Evaluation results will be displayed here.")