Skip to content

Commit fb7c1ca

Browse files
committed
full code documentation
1 parent de7158d commit fb7c1ca

9 files changed

+235
-61
lines changed

requirements.txt

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# This file may be used to create an environment using:
2+
# $ conda create --name <env> --file <this file>
3+
# platform: win-64
4+
altair=4.1.0=py_1
5+
argon2-cffi=21.3.0=pyhd3eb1b0_0
6+
argon2-cffi-bindings=21.2.0=py39h2bbff1b_0
7+
arrow-cpp=8.0.0=py39hbd6f097_0
8+
asttokens=2.0.5=pyhd3eb1b0_0
9+
attrs=22.1.0=py39haa95532_0
10+
aws-c-common=0.4.57=ha925a31_1
11+
aws-c-event-stream=0.1.6=hd77b12b_5
12+
aws-checksums=0.1.9=ha925a31_0
13+
aws-sdk-cpp=1.8.185=hd77b12b_0
14+
backcall=0.2.0=pyhd3eb1b0_0
15+
blas=1.0=mkl
16+
bleach=4.1.0=pyhd3eb1b0_0
17+
blinker=1.4=py39haa95532_0
18+
boost-cpp=1.73.0=h2bbff1b_12
19+
bottleneck=1.3.5=py39h080aedc_0
20+
brotli=1.0.9=h2bbff1b_7
21+
brotli-bin=1.0.9=h2bbff1b_7
22+
brotlipy=0.7.0=py39h2bbff1b_1003
23+
bzip2=1.0.8=he774522_0
24+
c-ares=1.18.1=h2bbff1b_0
25+
ca-certificates=2022.10.11=haa95532_0
26+
cachetools=4.2.2=pyhd3eb1b0_0
27+
certifi=2022.12.7=py39haa95532_0
28+
cffi=1.15.1=py39h2bbff1b_3
29+
charset-normalizer=2.0.4=pyhd3eb1b0_0
30+
click=8.0.4=py39haa95532_0
31+
colorama=0.4.6=py39haa95532_0
32+
commonmark=0.9.1=pyhd3eb1b0_0
33+
cryptography=38.0.4=py39h21b164f_0
34+
dataclasses=0.8=pyh6d0b6a4_7
35+
debugpy=1.5.1=py39hd77b12b_0
36+
decorator=5.1.1=pyhd3eb1b0_0
37+
defusedxml=0.7.1=pyhd3eb1b0_0
38+
entrypoints=0.4=py39haa95532_0
39+
executing=0.8.3=pyhd3eb1b0_0
40+
flit-core=3.6.0=pyhd3eb1b0_0
41+
freetype=2.12.1=ha860e81_0
42+
future=0.18.2=py39haa95532_1
43+
gflags=2.2.2=ha925a31_0
44+
gitdb=4.0.7=pyhd3eb1b0_0
45+
gitpython=3.1.18=pyhd3eb1b0_1
46+
glog=0.5.0=hd77b12b_0
47+
idna=3.4=py39haa95532_0
48+
importlib-metadata=4.11.3=py39haa95532_0
49+
intel-openmp=2021.4.0=haa95532_3556
50+
ipykernel=6.15.2=py39haa95532_0
51+
ipython=8.7.0=py39haa95532_0
52+
ipython_genutils=0.2.0=pyhd3eb1b0_1
53+
ipywidgets=7.6.5=pyhd3eb1b0_1
54+
jedi=0.18.1=py39haa95532_1
55+
jinja2=3.1.2=py39haa95532_0
56+
jpeg=9e=h2bbff1b_0
57+
jsonschema=4.16.0=py39haa95532_0
58+
jupyter_client=7.4.8=py39haa95532_0
59+
jupyter_core=4.11.1=py39haa95532_0
60+
jupyterlab_pygments=0.1.2=py_0
61+
jupyterlab_widgets=1.0.0=pyhd3eb1b0_1
62+
lerc=3.0=hd77b12b_0
63+
libboost=1.73.0=h6c2663c_12
64+
libbrotlicommon=1.0.9=h2bbff1b_7
65+
libbrotlidec=1.0.9=h2bbff1b_7
66+
libbrotlienc=1.0.9=h2bbff1b_7
67+
libcurl=7.86.0=h86230a5_0
68+
libdeflate=1.8=h2bbff1b_5
69+
libffi=3.4.2=hd77b12b_6
70+
libiconv=1.16=h2bbff1b_2
71+
libpng=1.6.37=h2a8f88b_0
72+
libprotobuf=3.20.1=h23ce68f_0
73+
libsodium=1.0.18=h62dcd97_0
74+
libssh2=1.10.0=hcd4344a_0
75+
libthrift=0.15.0=he1d8c1a_0
76+
libtiff=4.5.0=h8a3f274_0
77+
libwebp=1.2.4=h2bbff1b_0
78+
libwebp-base=1.2.4=h2bbff1b_0
79+
libxml2=2.9.14=h0ad7f3c_0
80+
libxslt=1.1.35=h2bbff1b_0
81+
lz4-c=1.9.4=h2bbff1b_0
82+
markupsafe=2.1.1=py39h2bbff1b_0
83+
matplotlib-inline=0.1.6=py39haa95532_0
84+
mistune=0.8.4=py39h2bbff1b_1000
85+
mkl=2021.4.0=haa95532_640
86+
mkl-service=2.4.0=py39h2bbff1b_0
87+
mkl_fft=1.3.1=py39h277e83a_0
88+
mkl_random=1.2.2=py39hf11a4ad_0
89+
nbconvert=5.5.0=py_0
90+
nbformat=5.1.3=pyhd3eb1b0_0
91+
nest-asyncio=1.5.6=py39haa95532_0
92+
notebook=6.4.12=py39haa95532_0
93+
numexpr=2.8.4=py39h5b0cc5e_0
94+
numpy=1.23.5=py39h3b20f71_0
95+
numpy-base=1.23.5=py39h4da318b_0
96+
openssl=1.1.1s=h2bbff1b_0
97+
packaging=22.0=py39haa95532_0
98+
pandas=1.5.2=py39hf11a4ad_0
99+
pandoc=2.12=haa95532_1
100+
pandocfilters=1.5.0=pyhd3eb1b0_0
101+
parso=0.8.3=pyhd3eb1b0_0
102+
pickleshare=0.7.5=pyhd3eb1b0_1003
103+
pillow=9.3.0=py39hdc2b20a_1
104+
pip=22.3.1=py39haa95532_0
105+
prometheus_client=0.14.1=py39haa95532_0
106+
prompt-toolkit=3.0.36=py39haa95532_0
107+
protobuf=3.20.1=py39hd77b12b_0
108+
psutil=5.9.0=py39h2bbff1b_0
109+
pure_eval=0.2.2=pyhd3eb1b0_0
110+
pyarrow=8.0.0=py39h953b917_0
111+
pycparser=2.21=pyhd3eb1b0_0
112+
pydeck=0.7.1=py39haa95532_0
113+
pygments=2.11.2=pyhd3eb1b0_0
114+
pympler=0.9=py_0
115+
pyopenssl=22.0.0=pyhd3eb1b0_0
116+
pyrsistent=0.18.0=py39h196d8e1_0
117+
pysocks=1.7.1=py39haa95532_0
118+
python=3.9.16=h6244533_0
119+
python-dateutil=2.8.2=pyhd3eb1b0_0
120+
pytz=2022.7=py39haa95532_0
121+
pywin32=305=py39h2bbff1b_0
122+
pywinpty=2.0.2=py39h5da7b33_0
123+
pyyaml=6.0=py39h2bbff1b_1
124+
pyzmq=23.2.0=py39hd77b12b_0
125+
re2=2022.04.01=hd77b12b_0
126+
requests=2.28.1=py39haa95532_0
127+
rich=12.5.1=py39haa95532_0
128+
semver=2.13.0=pyhd3eb1b0_0
129+
send2trash=1.8.0=pyhd3eb1b0_1
130+
setuptools=65.6.3=py39haa95532_0
131+
six=1.16.0=pyhd3eb1b0_1
132+
smmap=4.0.0=pyhd3eb1b0_0
133+
snappy=1.1.9=h6c2663c_0
134+
sqlite=3.40.1=h2bbff1b_0
135+
stack_data=0.2.0=pyhd3eb1b0_0
136+
streamlit=1.17.0=pypi_0
137+
streamlit-chat=0.0.2.1=pypi_0
138+
terminado=0.17.1=py39haa95532_0
139+
testpath=0.6.0=py39haa95532_0
140+
tk=8.6.12=h2bbff1b_0
141+
toml=0.10.2=pyhd3eb1b0_0
142+
toolz=0.12.0=py39haa95532_0
143+
tornado=6.2=py39h2bbff1b_0
144+
traitlets=5.7.1=py39haa95532_0
145+
typing-extensions=4.4.0=py39haa95532_0
146+
typing_extensions=4.4.0=py39haa95532_0
147+
tzdata=2022g=h04d1e81_0
148+
tzlocal=2.1=py39haa95532_1
149+
urllib3=1.26.14=py39haa95532_0
150+
utf8proc=2.6.1=h2bbff1b_0
151+
validators=0.18.2=pyhd3eb1b0_0
152+
vc=14.2=h21ff451_1
153+
vs2015_runtime=14.27.29016=h5e58377_2
154+
watchdog=2.1.6=py39haa95532_0
155+
wcwidth=0.2.5=pyhd3eb1b0_0
156+
webencodings=0.5.1=py39haa95532_1
157+
wheel=0.37.1=pyhd3eb1b0_0
158+
widgetsnbextension=3.5.2=py39haa95532_0
159+
win_inet_pton=1.1.0=py39haa95532_0
160+
wincertstore=0.2=py39haa95532_2
161+
winpty=0.4.3=4
162+
xz=5.2.10=h8cc25b3_1
163+
yaml=0.2.5=he774522_0
164+
zeromq=4.3.4=hd77b12b_0
165+
zipp=3.11.0=py39haa95532_0
166+
zlib=1.2.13=h8cc25b3_0
167+
zstd=1.5.2=h19a0ad4_0
4 Bytes
Binary file not shown.
13 Bytes
Binary file not shown.

scripts/main.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
from notetaker import NoteTaker
44
from notebot import NoteBot
55

6+
import time
7+
68
import streamlit as st
79
from streamlit_chat import message
810

9-
import re
10-
import time
11-
1211
# Page Config
1312
st.set_page_config(layout='wide')
1413

1514
# Session States
15+
# We want to use session states to manage the execution of each widget,
16+
# so a widget that is not click on will not be excuted
1617
if "generated" not in st.session_state:
1718
st.session_state["generated"] = False
18-
st.session_state["downloaded"] = True
19+
st.session_state["downloaded"] = False
1920
st.session_state["asked"] = False
2021
st.session_state["most_recent_note"] = ""
2122
st.session_state["user_chat_history"] = []
2223
st.session_state["notebot_response_history"] = []
2324

24-
2525
# Welcome page
2626
st.title("i-Note-it")
2727
st.caption("---Enhance Note-Taking Experience with Artificial Intelligence.")
@@ -32,12 +32,13 @@
3232
NoteTakingService = NoteTaker()
3333
NoteBotService = NoteBot()
3434

35+
# Left, Right Columns
3536
col1, col2 = st.columns(2, gap="medium")
3637

3738
with col1:
3839
st.header("Your Text")
3940
generate_button = st.button("Generate")
40-
text = st.text_area(":keyboard: Input the text ", height=300, max_chars=5000, help="Copy & Paste the text you want to convert into markdown note") # Corresponds to approximately 2040 tokens (max. tokens for the model)
41+
text = st.text_area(":keyboard: Input the text ", height=300, max_chars=5000, help="Copy & Paste or type the text you want to convert into markdown note") # Corresponds to approximately 2040 tokens (max. tokens for the model)
4142

4243
with col2:
4344
st.header("Your Note")
@@ -52,7 +53,7 @@
5253
try:
5354
generated_note = NoteTakingService.run(text)
5455
generate_success = True
55-
except KeyError:
56+
except KeyError:
5657
st.error("Try with fewer text!")
5758

5859
if generate_success:
@@ -61,13 +62,13 @@
6162
with st.spinner('Wait for it...'):
6263
time.sleep(3)
6364

64-
# if st.session_state["downloaded"]:
65-
# download_button = st.download_button("Download", post_processed_note, 'i-Note-it.md')
6665
st.session_state["most_recent_note"] = post_processed_note
6766
st.session_state["generated"] = False
6867

68+
st.download_button("Download", st.session_state["most_recent_note"], 'i-Note-it.md')
6969
st.markdown(st.session_state["most_recent_note"])
7070

71+
# NoteBot Section
7172
with st.expander("Ask your NoteBot!"):
7273

7374
question = st.text_input("Question")
@@ -76,7 +77,6 @@
7677
st.session_state["user_chat_history"].clear()
7778
bot_hist = st.session_state["notebot_response_history"].clear()
7879

79-
8080
if question:
8181
st.session_state["asked"] = True
8282

@@ -87,7 +87,7 @@
8787
user_hist.append(question)
8888
bot_hist.append(NoteBotService.run(text,question))
8989

90-
90+
# Dialogue DIsplay
9191
for i in range(len(user_hist)-1, -1, -1):
9292
message(bot_hist[i], key=str(i) +'_bot')
9393
message(user_hist[i], is_user=True, key=str(i) + '_user')

scripts/notebot.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@
33
import requests
44

55
class NoteBot():
6+
""" i-Note-it NoteBot
7+
"""
68
def __init__(self):
7-
"""_summary_
8-
9-
Args:
10-
instruction (_type_, optional): _description_. Defaults to None.
9+
"""init
1110
"""
1211
self.instruction1 = "Context: "
1312
self.instruction2 = "\nQuestion: "
1413
self.instruction3 = "\nAnswer: "
1514

16-
17-
1815
def get_response(self, transcript, question, to_json=True):
19-
"""_summary_
16+
""" Get NoteBot Model Response
2017
2118
Args:
22-
transcript (_type_): _description_
23-
question (_type_): _description_
19+
transcript (str): input transcript
20+
question (str): question to ask
21+
to_json (bool, optional): convert to json format. Defaults to True.
22+
23+
Returns:
24+
dict or str: to_json=True -> dict, to_json=False -> str
2425
"""
2526
payload = {
2627
"prompt": f"{self.instruction1}{transcript}{self.instruction2}{question}{self.instruction3}",
@@ -68,18 +69,18 @@ def get_response(self, transcript, question, to_json=True):
6869
return response
6970

7071
def run(self, transcript, question, to_json=True, get_text=True):
71-
"""_summary_
72+
""" Run the Model
7273
7374
Args:
74-
input_text (_type_): _description_
75-
to_json (bool, optional): _description_. Defaults to True.
75+
transcript (str): input transcript
76+
question (str): question to ask
77+
to_json (bool, optional): convert to json format. Defaults to True.
78+
get_text (bool, optional): Get the model completion response. Defaults to True.
7679
7780
Returns:
78-
_type_: _description_
81+
str or dict: get_text=True -> str, get_text=False -> dict
7982
"""
8083
if get_text:
8184
return self.get_response(transcript, question, to_json)['completions'][0]['data']['text']
8285
else:
83-
return self.get_response(transcript, question, to_json)
84-
85-
86+
return self.get_response(transcript, question, to_json)

scripts/notetaker.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
11
from config import API_TOKEN, NOTETAKER_MODEL_URL
2-
import requests
32

3+
import requests
44

55
class NoteTaker:
6-
"""_summary_
6+
"""i-Note-it NoteTaker
77
"""
88
def __init__(self, instruction=None):
9-
"""_summary_
9+
"""init
10+
11+
Args:
12+
instruction (str, optional): Prompt for the Note Taking Model. Defaults to None.
1013
"""
1114
if instruction == None:
1215
self.instruction = "Imagine you are the best notetaker in the world. Write the most streamlined and hierarchical bullet point notes with sections for this text:\n"
1316
else:
1417
self.instruction = instruction
1518

1619
def request_note(self, input_text, to_json=True):
17-
"""
20+
"""Get NoteTaker Model Response
1821
1922
Args:
20-
input_text (_type_): _description_
23+
input_text (str): input transcript
24+
to_json (bool, optional): convert to json format. Defaults to True.
25+
26+
Returns:
27+
dict or str: to_json=True -> dict, to_json=False -> str
2128
"""
2229
payload = {
2330
"prompt": f"{self.instruction}{input_text}\n##\n",
2431
"numResults": 1,
25-
"maxTokens": 2048,
26-
"temperature": 0,
32+
"maxTokens": 64,
33+
"temperature": 0.7,
2734
"topKReturn": 0,
2835
"topP":1,
2936
"countPenalty": {
@@ -66,14 +73,15 @@ def request_note(self, input_text, to_json=True):
6673
return response
6774

6875
def run(self, input_text, to_json=True, get_text=True):
69-
"""_summary_
76+
"""Run the Model
7077
7178
Args:
72-
input_text (_type_): _description_
73-
to_json (bool, optional): _description_. Defaults to True.
79+
input_text (str): Input transcript
80+
to_json (bool, optional): convert to json format. Defaults to True.
81+
get_text (bool, optional): Get the model completion response. Defaults to True.
7482
7583
Returns:
76-
_type_: _description_
84+
str or dict: get_text=True -> str, get_text=False -> dict
7785
"""
7886
if get_text:
7987
return self.request_note(input_text, to_json)['completions'][0]['data']['text']

scripts/postprocess.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class PostProcessor:
2-
"""_summary_
2+
"""Post process the text from the i-Note-it NoteTaker to a markdown-ready text
33
"""
44
def __init__(self):
5-
"""_summary_
5+
"""init
66
"""
77
pass
88

0 commit comments

Comments
 (0)