From cc9b0ac68ca3c05f1df1706d314648f64b51356e Mon Sep 17 00:00:00 2001 From: LUIS NOVO Date: Fri, 1 Nov 2024 13:09:44 -0300 Subject: [PATCH] new playground page --- pages/8_🛝_Playground.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pages/8_🛝_Playground.py diff --git a/pages/8_🛝_Playground.py b/pages/8_🛝_Playground.py new file mode 100644 index 0000000..a041847 --- /dev/null +++ b/pages/8_🛝_Playground.py @@ -0,0 +1,36 @@ +import streamlit as st +import yaml + +from open_notebook.graphs.multipattern import graph as pattern_graph +from stream_app.utils import version_sidebar + +st.set_page_config( + layout="wide", page_title="🛝 Playground", initial_sidebar_state="expanded" +) +version_sidebar() + +st.title("🛝 Playground") +with open("transformations.yaml", "r") as file: + transformations = yaml.safe_load(file) + +insight_transformations = transformations["source_insights"] + +transformation = st.selectbox( + "Pick a transformation", + insight_transformations, + format_func=lambda x: x.get("name", "No Name"), +) + +with st.expander("Details"): + st.json(transformation) + +input_text = st.text_area("Enter some text", height=200) + +if st.button("Run"): + output = pattern_graph.invoke( + dict( + content_stack=[input_text], + patterns=transformation["patterns"], + ) + ) + st.markdown(output["output"])