Uwais commited on
Commit
4a3a4a3
โ€ข
1 Parent(s): 95ba32b

adding util file, email sign up and additional pages for actions

Browse files
__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
- from lime import lime_text
 
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=800)
 
 
 
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
- from lime import lime_text
 
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=800)
 
 
 
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.write("""This demo shows how AI can be used to organise a collection of texts.""")
17
- st.header("๐Ÿ— This demo is under construction. Please visit back soon.")
 
 
 
 
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.write("""This demo shows how AI can be used to find relevant information from a collection of texts.""")
17
- st.header("๐Ÿ— This demo is under construction. Please visit back soon.")
 
 
 
 
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:hello@simplexico.ai)
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='john.doe@outlook.com')
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 PIL import Image
3
 
4
  st.set_page_config(
5
  page_title="Legal AI Demos",
6
  page_icon="๐Ÿ‘‹",
 
 
 
 
 
 
 
7
  )
8
 
9
- image = Image.open('logo.png')
10
- st.image(image, width=250)
11
 
12
- st.write("# Welcome to the Legal AI Action Demos from simplexico! ๐Ÿ‘‹")
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
- ## What goes into making an AI model?
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
- ## Showcasing our Recipes
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
- ## About Us
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 just for your taste ๐Ÿฅง!
53
-
54
- ### Want to learn more?
55
- - ๐ŸŒ Check out our website [simplexico.ai](https://simplexico.ai)
56
- - ๐Ÿ“ž Book a Call With Us [Book a call](https://calendly.com/uwais-iqbal/discovery-call)
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:hello@simplexico.ai',
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()