-
Notifications
You must be signed in to change notification settings - Fork 124
/
streamlit_app.py
37 lines (27 loc) · 1.1 KB
/
streamlit_app.py
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
import streamlit as st
from string import Template
from clumper import Clumper
st.markdown("# Intent Example Finder")
st.markdown("Use the selector in the sidebar to construct NLU data as a starting point.")
st.sidebar.markdown("Made with love over at [Rasa](https://rasa.com/).")
st.sidebar.image(
"https://rasahq.github.io/rasa-nlu-examples/square-logo.svg", width=100
)
clump = (Clumper.read_yaml("*/nlu.yml")
.unpack("nlu"))
intents = clump.select("intent").drop_duplicates().map(lambda d: d['intent']).collect()
intent_selection = st.sidebar.multiselect("What intents would you like to see?", intents, default=("bot_challenge", ))
st.sidebar.markdown("The original data is on [GitHub](https://github.com/RasaHQ/NLU-training-data).")
data = (clump
.keep(lambda d: d['intent'] in intent_selection)
.mutate(examples = lambda d: d['examples'].replace("- ", " - "))
.collect())
template = Template(" - intent: $intent\n examples : |\n$examples")
rendered = '\n'.join([template.substitute(d) for d in data])
text = f"""
```yaml
nlu:
{rendered}
```
"""
st.markdown(text)