Spaces:
Runtime error
Runtime error
adding util file, email sign up and additional pages for actions
Browse files- __init__.py +0 -0
- pages/1_๐ท_Label_Clause_Demo.py +7 -4
- pages/2_๐ท_Label_Contract_Demo.py +7 -4
- pages/3_โ_Extract_Demo.py +8 -1
- pages/4_๐_Compare_Demo.py +6 -0
- pages/5_๐_Organise_Demo.py +8 -2
- pages/6_๐_Find_Demo.py +8 -2
- pages/__init__.py +0 -0
- utils.py +80 -0
- ๐ก_Home.py +21 -16
__init__.py
ADDED
File without changes
|
pages/1_๐ท_Label_Clause_Demo.py
CHANGED
@@ -8,10 +8,9 @@ from huggingface_hub import hf_hub_download
|
|
8 |
import streamlit as st
|
9 |
import streamlit.components.v1 as components
|
10 |
|
11 |
-
import numpy as np
|
12 |
-
|
13 |
from lime.lime_text import LimeTextExplainer
|
14 |
-
|
|
|
15 |
|
16 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
17 |
REPO_ID = "simplexico/cuad-sklearn-clause-classifier"
|
@@ -34,6 +33,8 @@ st.set_page_config(
|
|
34 |
}
|
35 |
)
|
36 |
|
|
|
|
|
37 |
st.title('๐ท Label Clause Demo')
|
38 |
st.write("""
|
39 |
This demo shows how AI can be used to label text.
|
@@ -94,4 +95,6 @@ if button:
|
|
94 |
st.header('๐ฎ Prediction Explainability')
|
95 |
st.write(
|
96 |
'We can perform an analysis to work out what terms in the clause were most important in deciding the predicted clause type:')
|
97 |
-
components.html(exp.as_html(predict_proba=False), height=
|
|
|
|
|
|
8 |
import streamlit as st
|
9 |
import streamlit.components.v1 as components
|
10 |
|
|
|
|
|
11 |
from lime.lime_text import LimeTextExplainer
|
12 |
+
|
13 |
+
from utils import add_logo_to_sidebar, add_footer
|
14 |
|
15 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
16 |
REPO_ID = "simplexico/cuad-sklearn-clause-classifier"
|
|
|
33 |
}
|
34 |
)
|
35 |
|
36 |
+
add_logo_to_sidebar()
|
37 |
+
|
38 |
st.title('๐ท Label Clause Demo')
|
39 |
st.write("""
|
40 |
This demo shows how AI can be used to label text.
|
|
|
95 |
st.header('๐ฎ Prediction Explainability')
|
96 |
st.write(
|
97 |
'We can perform an analysis to work out what terms in the clause were most important in deciding the predicted clause type:')
|
98 |
+
components.html(exp.as_html(predict_proba=False), height=600)
|
99 |
+
|
100 |
+
add_footer()
|
pages/2_๐ท_Label_Contract_Demo.py
CHANGED
@@ -8,10 +8,9 @@ import streamlit.components.v1 as components
|
|
8 |
|
9 |
from huggingface_hub import hf_hub_download
|
10 |
|
11 |
-
import numpy as np
|
12 |
-
|
13 |
from lime.lime_text import LimeTextExplainer
|
14 |
-
|
|
|
15 |
|
16 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
17 |
REPO_ID = "simplexico/cuad-sklearn-contract-classifier"
|
@@ -58,6 +57,8 @@ st.set_page_config(
|
|
58 |
}
|
59 |
)
|
60 |
|
|
|
|
|
61 |
st.title('๐ท Label Contract Demo')
|
62 |
st.write("""
|
63 |
This demo shows how AI can be used to label text.
|
@@ -120,4 +121,6 @@ if button:
|
|
120 |
st.write(
|
121 |
'We can perform an analysis to work out what terms in the contract were most important in deciding the predicted contract type:')
|
122 |
|
123 |
-
components.html(exp.as_html(predict_proba=False), height=
|
|
|
|
|
|
8 |
|
9 |
from huggingface_hub import hf_hub_download
|
10 |
|
|
|
|
|
11 |
from lime.lime_text import LimeTextExplainer
|
12 |
+
|
13 |
+
from utils import add_logo_to_sidebar, add_footer
|
14 |
|
15 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
16 |
REPO_ID = "simplexico/cuad-sklearn-contract-classifier"
|
|
|
57 |
}
|
58 |
)
|
59 |
|
60 |
+
add_logo_to_sidebar()
|
61 |
+
|
62 |
st.title('๐ท Label Contract Demo')
|
63 |
st.write("""
|
64 |
This demo shows how AI can be used to label text.
|
|
|
121 |
st.write(
|
122 |
'We can perform an analysis to work out what terms in the contract were most important in deciding the predicted contract type:')
|
123 |
|
124 |
+
components.html(exp.as_html(predict_proba=False), height=600)
|
125 |
+
|
126 |
+
add_footer()
|
pages/3_โ_Extract_Demo.py
CHANGED
@@ -13,6 +13,9 @@ from spacy.tokens import Span
|
|
13 |
import pandas as pd
|
14 |
import numpy as np
|
15 |
|
|
|
|
|
|
|
16 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
17 |
REPO_ID = "simplexico/cuad-spacy-custom-ner"
|
18 |
|
@@ -35,6 +38,8 @@ st.set_page_config(
|
|
35 |
}
|
36 |
)
|
37 |
|
|
|
|
|
38 |
st.title('โ Extract Demo')
|
39 |
st.write("""
|
40 |
This demo shows how AI can be used to extract information from text.
|
@@ -181,4 +186,6 @@ if button:
|
|
181 |
# Inject CSS with Markdown
|
182 |
st.markdown(hide_dataframe_row_index, unsafe_allow_html=True)
|
183 |
|
184 |
-
st.table(df)
|
|
|
|
|
|
13 |
import pandas as pd
|
14 |
import numpy as np
|
15 |
|
16 |
+
from utils import add_logo_to_sidebar, add_footer
|
17 |
+
|
18 |
+
|
19 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
20 |
REPO_ID = "simplexico/cuad-spacy-custom-ner"
|
21 |
|
|
|
38 |
}
|
39 |
)
|
40 |
|
41 |
+
add_logo_to_sidebar()
|
42 |
+
|
43 |
st.title('โ Extract Demo')
|
44 |
st.write("""
|
45 |
This demo shows how AI can be used to extract information from text.
|
|
|
186 |
# Inject CSS with Markdown
|
187 |
st.markdown(hide_dataframe_row_index, unsafe_allow_html=True)
|
188 |
|
189 |
+
st.table(df)
|
190 |
+
|
191 |
+
add_footer()
|
pages/4_๐_Compare_Demo.py
CHANGED
@@ -2,6 +2,8 @@ import streamlit as st
|
|
2 |
import difflib
|
3 |
import spacy
|
4 |
|
|
|
|
|
5 |
|
6 |
@st.cache(allow_output_mutation=True)
|
7 |
def load_model():
|
@@ -21,6 +23,8 @@ st.set_page_config(
|
|
21 |
}
|
22 |
)
|
23 |
|
|
|
|
|
24 |
st.title('๐ Compare Demo')
|
25 |
st.write("""
|
26 |
This demo shows how AI can be used to compare passages of text.
|
@@ -106,3 +110,5 @@ if button:
|
|
106 |
st.subheader('๐ญ Semantic Similarity')
|
107 |
st.markdown('We can measure the similarity based on the *meaning* of the two texts.')
|
108 |
st.metric(label='Semantic Similarity', value=f"{doc_1.similarity(doc_2) * 100:.1f}%")
|
|
|
|
|
|
2 |
import difflib
|
3 |
import spacy
|
4 |
|
5 |
+
from utils import add_logo_to_sidebar, add_footer
|
6 |
+
|
7 |
|
8 |
@st.cache(allow_output_mutation=True)
|
9 |
def load_model():
|
|
|
23 |
}
|
24 |
)
|
25 |
|
26 |
+
add_logo_to_sidebar()
|
27 |
+
|
28 |
st.title('๐ Compare Demo')
|
29 |
st.write("""
|
30 |
This demo shows how AI can be used to compare passages of text.
|
|
|
110 |
st.subheader('๐ญ Semantic Similarity')
|
111 |
st.markdown('We can measure the similarity based on the *meaning* of the two texts.')
|
112 |
st.metric(label='Semantic Similarity', value=f"{doc_1.similarity(doc_2) * 100:.1f}%")
|
113 |
+
|
114 |
+
add_footer()
|
pages/5_๐_Organise_Demo.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
st.set_page_config(
|
4 |
page_title="Organise Demo",
|
@@ -12,6 +13,11 @@ st.set_page_config(
|
|
12 |
}
|
13 |
)
|
14 |
|
|
|
|
|
15 |
st.title('๐ Organise Demo')
|
16 |
-
st.
|
17 |
-
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from utils import add_logo_to_sidebar, add_footer, add_email_signup_form
|
3 |
|
4 |
st.set_page_config(
|
5 |
page_title="Organise Demo",
|
|
|
13 |
}
|
14 |
)
|
15 |
|
16 |
+
add_logo_to_sidebar()
|
17 |
+
|
18 |
st.title('๐ Organise Demo')
|
19 |
+
st.markdown("๐ This demo is under construction. Please visit back soon.")
|
20 |
+
|
21 |
+
add_email_signup_form()
|
22 |
+
|
23 |
+
add_footer()
|
pages/6_๐_Find_Demo.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
st.set_page_config(
|
4 |
page_title="Find Demo",
|
@@ -12,6 +13,11 @@ st.set_page_config(
|
|
12 |
}
|
13 |
)
|
14 |
|
|
|
|
|
15 |
st.title('๐ Find Demo')
|
16 |
-
st.
|
17 |
-
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from utils import add_logo_to_sidebar, add_footer, add_email_signup_form
|
3 |
|
4 |
st.set_page_config(
|
5 |
page_title="Find Demo",
|
|
|
13 |
}
|
14 |
)
|
15 |
|
16 |
+
add_logo_to_sidebar()
|
17 |
+
|
18 |
st.title('๐ Find Demo')
|
19 |
+
st.markdown("๐ This demo is currently under construction. Please visit back soon.")
|
20 |
+
|
21 |
+
add_email_signup_form()
|
22 |
+
|
23 |
+
add_footer()
|
pages/__init__.py
ADDED
File without changes
|
utils.py
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import base64
|
2 |
+
import os
|
3 |
+
from datetime import datetime
|
4 |
+
from pathlib import Path
|
5 |
+
|
6 |
+
import mailerlite as MailerLite
|
7 |
+
import streamlit as st
|
8 |
+
|
9 |
+
client = MailerLite.Client({
|
10 |
+
'api_key': os.environ['mailerlitetoken']
|
11 |
+
})
|
12 |
+
NEWSLETTER_GROUP_ID = "74940965074240697"
|
13 |
+
|
14 |
+
|
15 |
+
def get_timestamp():
|
16 |
+
return datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
17 |
+
|
18 |
+
|
19 |
+
def add_logo_to_sidebar():
|
20 |
+
st.markdown(
|
21 |
+
f"""
|
22 |
+
<style>
|
23 |
+
[data-testid="stSidebarNav"] {{
|
24 |
+
background-image: url(data:image/png;base64,{base64.b64encode(Path('logo.png').read_bytes()).decode()});
|
25 |
+
background-repeat: no-repeat;
|
26 |
+
background-position: 20px 20px;
|
27 |
+
background-size: 300px;
|
28 |
+
padding-top: 100px
|
29 |
+
}}
|
30 |
+
</style>
|
31 |
+
""",
|
32 |
+
unsafe_allow_html=True,
|
33 |
+
)
|
34 |
+
|
35 |
+
|
36 |
+
def add_footer():
|
37 |
+
st.markdown("""
|
38 |
+
### ๐ค Interested in hiring us to build bespoke Legal AI solutions?
|
39 |
+
- ๐ Check out our [website](https://simplexico.ai)
|
40 |
+
- ๐ Book a call with [us](https://calendly.com/uwais-iqbal/discovery-call)
|
41 |
+
- โ๏ธ Send us an [email](mailto:[email protected])
|
42 |
+
""")
|
43 |
+
|
44 |
+
|
45 |
+
def add_email_signup_form():
|
46 |
+
st.markdown("### ๐ Join our mailing list to keep up to date with all things simplexico!")
|
47 |
+
col1, col2 = st.columns(2)
|
48 |
+
with st.form(key='email-form'):
|
49 |
+
name = col1.text_input(label='Enter your name', placeholder='John Doe')
|
50 |
+
email = col2.text_input(label='Enter your email', placeholder='[email protected]')
|
51 |
+
|
52 |
+
submit_button = st.form_submit_button(label='Submit', type='primary', use_container_width=True)
|
53 |
+
|
54 |
+
if submit_button:
|
55 |
+
valid_name = True
|
56 |
+
valid_email = True
|
57 |
+
|
58 |
+
if name == "":
|
59 |
+
st.error('โ Error! Please enter a name.')
|
60 |
+
valid_name = False
|
61 |
+
|
62 |
+
if email == "":
|
63 |
+
st.error('โ Error! Please enter an email.')
|
64 |
+
valid_email = False
|
65 |
+
elif not '@' in email:
|
66 |
+
st.error('โ Error! Please enter a valid email.')
|
67 |
+
valid_email = False
|
68 |
+
elif not '.' in email.split('@')[-1]:
|
69 |
+
st.error('โ Error! Please enter a valid email.')
|
70 |
+
valid_email = False
|
71 |
+
|
72 |
+
if valid_name and valid_email:
|
73 |
+
response = client.subscribers.create(email, fields={'name': name},
|
74 |
+
groups=[NEWSLETTER_GROUP_ID],
|
75 |
+
status='active', subscribed_at=get_timestamp())
|
76 |
+
try:
|
77 |
+
if response['data']['status'] == 'active':
|
78 |
+
st.success(f'โ
๐ Hey {name}! Welcome to our mailing list.')
|
79 |
+
except Exception as e:
|
80 |
+
st.error(f"๐ Sorry {name}. Something went wrong. We weren't able to add you to our mailing list.")
|
๐ก_Home.py
CHANGED
@@ -1,24 +1,30 @@
|
|
1 |
import streamlit as st
|
2 |
-
from
|
3 |
|
4 |
st.set_page_config(
|
5 |
page_title="Legal AI Demos",
|
6 |
page_icon="๐",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
)
|
8 |
|
9 |
-
|
10 |
-
|
11 |
|
12 |
-
st.
|
13 |
|
14 |
st.sidebar.success("๐ Select a demo above.")
|
15 |
|
16 |
-
|
17 |
st.markdown(
|
18 |
"""
|
19 |
Here at simplexico, we've put together a collection of demos showcasing what AI can do in legal.
|
20 |
AI tends go get spoken about in vague terms. We like to think about AI in terms of the specific
|
21 |
-
action it can perform. These demos are meant to cut through all the hype and noise so you can simplify see
|
22 |
for yourself what AI can and can't do.
|
23 |
|
24 |
Here you will find demos for the most common Legal AI Actions including:
|
@@ -30,29 +36,28 @@ st.markdown(
|
|
30 |
|
31 |
**๐ Select a demo from the sidebar** to see some examples of what Legal AI can do!
|
32 |
|
33 |
-
|
34 |
Building an AI model is a lot like cooking.
|
35 |
A ๐ฉโ๐ณ chef (data scientist) combines the ๐ฅ ingredients (data) according to a recipe ๐ (algorithm)
|
36 |
and ๐ณ cooks the meal (trains the model) in the ๐ช kitchen (computing environment).
|
37 |
Once the ๐ฅง meal (AI model) is ready, it can be ๐ served (deployed) to a ๐๐ปcustomer (user)
|
38 |
ready to be ๐ฝ eaten (used) and enjoyed ๐ (meeting the user's needs).
|
39 |
|
40 |
-
|
41 |
Our Legal AI Chefs ๐งโ๐ณ have prepared a selection of recipes ๐ and with publicly sourced
|
42 |
ingredients ๐ฅ they have created some fantastic meals ๐ฅง (AI demos) for you to try.
|
43 |
We've also peppered on some explainability so you can see what the AI model is thinking.
|
44 |
Try them out ๐ฝ!
|
45 |
|
46 |
-
|
47 |
simplexico offers white-glove Legal AI education, design and development services. We are on a mission to help
|
48 |
legal professionals step into a future of collaboration with AI.
|
49 |
|
50 |
We have the Legal AI Chefs ๐ฉโ๐ณ and recipes ๐.
|
51 |
You have the ingredients ๐ฅ (data).
|
52 |
-
We can tailor some yummy Legal AI meals
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
)
|
|
|
1 |
import streamlit as st
|
2 |
+
from utils import add_logo_to_sidebar, add_footer, add_email_signup_form
|
3 |
|
4 |
st.set_page_config(
|
5 |
page_title="Legal AI Demos",
|
6 |
page_icon="๐",
|
7 |
+
layout="wide",
|
8 |
+
initial_sidebar_state="expanded",
|
9 |
+
menu_items={
|
10 |
+
'Get Help': 'mailto:[email protected]',
|
11 |
+
'Report a bug': None,
|
12 |
+
'About': "## This a demo showcasing different Legal AI Actions"
|
13 |
+
}
|
14 |
)
|
15 |
|
16 |
+
## Add logo to sidebar
|
17 |
+
add_logo_to_sidebar()
|
18 |
|
19 |
+
st.title("๐ Welcome to the Legal AI Demos from simplexico!")
|
20 |
|
21 |
st.sidebar.success("๐ Select a demo above.")
|
22 |
|
|
|
23 |
st.markdown(
|
24 |
"""
|
25 |
Here at simplexico, we've put together a collection of demos showcasing what AI can do in legal.
|
26 |
AI tends go get spoken about in vague terms. We like to think about AI in terms of the specific
|
27 |
+
**action** it can perform. These demos are meant to cut through all the hype and noise so you can simplify see
|
28 |
for yourself what AI can and can't do.
|
29 |
|
30 |
Here you will find demos for the most common Legal AI Actions including:
|
|
|
36 |
|
37 |
**๐ Select a demo from the sidebar** to see some examples of what Legal AI can do!
|
38 |
|
39 |
+
### ๐ What goes into making an AI model?
|
40 |
Building an AI model is a lot like cooking.
|
41 |
A ๐ฉโ๐ณ chef (data scientist) combines the ๐ฅ ingredients (data) according to a recipe ๐ (algorithm)
|
42 |
and ๐ณ cooks the meal (trains the model) in the ๐ช kitchen (computing environment).
|
43 |
Once the ๐ฅง meal (AI model) is ready, it can be ๐ served (deployed) to a ๐๐ปcustomer (user)
|
44 |
ready to be ๐ฝ eaten (used) and enjoyed ๐ (meeting the user's needs).
|
45 |
|
46 |
+
### ๐ Showcasing our recipes
|
47 |
Our Legal AI Chefs ๐งโ๐ณ have prepared a selection of recipes ๐ and with publicly sourced
|
48 |
ingredients ๐ฅ they have created some fantastic meals ๐ฅง (AI demos) for you to try.
|
49 |
We've also peppered on some explainability so you can see what the AI model is thinking.
|
50 |
Try them out ๐ฝ!
|
51 |
|
52 |
+
### โน About Us
|
53 |
simplexico offers white-glove Legal AI education, design and development services. We are on a mission to help
|
54 |
legal professionals step into a future of collaboration with AI.
|
55 |
|
56 |
We have the Legal AI Chefs ๐ฉโ๐ณ and recipes ๐.
|
57 |
You have the ingredients ๐ฅ (data).
|
58 |
+
We can tailor some yummy Legal AI meals for your taste ๐ฅง!
|
59 |
+
""")
|
60 |
+
|
61 |
+
add_email_signup_form()
|
62 |
+
|
63 |
+
add_footer()
|
|