MrJShen commited on
Commit
7878c8d
·
1 Parent(s): 0f59ab0

Upload 4 files

Browse files
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.set_page_config(
4
+ page_title="Welcome to AI club",
5
+ page_icon="👋",
6
+ )
7
+
8
+ ## Page layout
9
+ @st.cache_data
10
+ def main_layout():
11
+ st.sidebar.success("Select weekly task above.")
12
+ st.markdown(
13
+ """
14
+ This is our weekly tutorial pages.
15
+
16
+ **👈 Select the weekly tutorial/tasks from the sidebar** to follow step by step.
17
+
18
+ """
19
+ )
20
+
21
+ main_layout()
22
+
23
+ st.markdown("""
24
+ ### Our member profile
25
+ - Coming soon ...
26
+ ### Our AI apps
27
+ - Coming soon ...
28
+ ### Relevent Documents (only if you have time to explore them by yourself)
29
+ - [Streamlit HowTos](https://docs.streamlit.io/library/api-reference)
30
+ - [Hugging Face HowTos](https://huggingface.co/docs/hub/spaces)
31
+ - [Learn to ClickUp](https://help.clickup.com/hc/en-us/categories/5414365970455-Features)
32
+ """
33
+ )
pages/1_101_notebook_setup.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.set_page_config(page_title="Notebook Installation", page_icon=":notebook:")
4
+
5
+ st.markdown("# Steps to install Jupyter notebook")
6
+
7
+ st.markdown(
8
+ """
9
+ #### :red[For Windows 10 or above:]
10
+
11
+ ###### 1. Open CMD(Terminal) in your laptop
12
+ - You can type "cmd" in the "Type to search" window
13
+ - Then the Command Line (Terminal) should appear and you might run it;
14
+
15
+ ###### 2. Install Python 3.11 into your laptop
16
+ - Type in the following code in your CMD and press "Enter" to execute
17
+
18
+ ```cmd
19
+ winget install python.python.3.11
20
+ ```
21
+
22
+ ###### 3. Install Jupyter Notebook to your laptop
23
+ - Type in the following command in your CMD and press "Enter" to execute
24
+
25
+ ```cmd
26
+ pip install notebook
27
+ ```
28
+ ###### 4. Run notebook
29
+ - Type in the following command in your CMD and press "Enter" to execute
30
+
31
+ ```cmd
32
+ jupyter notebook
33
+ ```
34
+ - If you don't see a browser window popup,
35
+ you can copy the url output in the terminal and paste it into a new browser tab to open the notebook,
36
+ """
37
+ )
38
+ st.write("##")
39
+ st.markdown(
40
+ """
41
+ #### :blue[For MacOS:]
42
+
43
+ ###### 1. Install Python 3.11 into your laptop
44
+ - Check the webside [here](https://www.saintlad.com/install-python-3-on-mac/) for instruction
45
+
46
+ ###### 2. Upgrade pip3
47
+ - upgrade pip or pip3, type/copy the following into Mac terminal and execute
48
+
49
+ ```bash
50
+ pip3 install --upgrade pip
51
+ ```
52
+ ###### 3. Install jupyter notebook
53
+ - type/copy the following into Mac terminal and execute
54
+
55
+ ```bash
56
+ pip3 install jupyter
57
+ ```
58
+ ###### 4. Run notebook
59
+ - Type in the following command in your CMD and press "Enter" to execute
60
+
61
+ ```cmd
62
+ jupyter notebook
63
+ ```
64
+ - If you don't see a browser window popup, you can copy the url output in the terminal and paste it into a new browser tab to open the notebook.
65
+ """
66
+ )
67
+
pages/1_102_Manage_Your_API_Keys.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.set_page_config(page_title="API_Keys", page_icon=":secret:")
4
+
5
+ st.markdown("# Manage your API keys")
6
+
7
+ st.markdown(
8
+ """
9
+ Through out this term, you will use your API keys to access different servers such as Hugging Face and ChatGPT.
10
+ It is important to have a secured managment of your API keys on your computer.
11
+
12
+ **:red[REMEMBER:]**
13
+
14
+ Never display your keys in your code!
15
+
16
+ - To get your **:blue[OpenAI]** key, you can follow the link [here](https://elephas.app/blog/how-to-get-chatgpt-api-key-clh93ii2e1642073tpacu6w934j)
17
+ - To get your **:green[Hugging Face]** API key, you can follow the steps below:
18
+
19
+ 1. Click on your profile image(of Hugging Face) and click your account name under "Profile";
20
+ 2. In the left bar of your profile, click on "Settings";
21
+ 3. In the left bar of the Settings page, click on "Access Tokens";
22
+ 4. Click on "Copy the token" button, just right to the button "Show"
23
+ 5. Then you have copied your token in the clipboard, we can now moving on to store it locally.
24
+ """
25
+ )
26
+
27
+ st.write("##")
28
+
29
+ st.markdown(
30
+ """
31
+ #### Store API keys in the local environment
32
+
33
+ ###### :blue[For MacOS/Linux:]
34
+
35
+ ```bash
36
+ # 1. create .env file, for notebook, this can be done in your Jupyter notebook cell wiht "!" as prefix
37
+ touch .env
38
+
39
+ #2. hard code your key to .env
40
+ echo "HF_API_KEY=<Your Key here>" >> .env
41
+ ```
42
+ ###### :blue[For windows]
43
+
44
+ - Using the option 2 from the [link](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety )
45
+
46
+ ###### :blue[REMEMBER]:
47
+
48
+ - Different API keys should have different names! For example:
49
+ - For OpenAI (ChatGPT), your name of key should be "OPENAI_API_KEY";
50
+ - For Hugging Face, your name of key should be "HF_API_KEY"
51
+
52
+ """
53
+ )
54
+
55
+ st.write("##")
56
+
57
+ st.markdown(
58
+ """
59
+ #### Using your keys in notebook
60
+
61
+ Once we have done above successfully, we can call our API keys in Jupyter Notebook
62
+
63
+ 1. Fistly, we install a convinient library
64
+
65
+ ```cmd
66
+ !pip install python-dotenv
67
+ ```
68
+ remember: the prefix "!" is for Jupyter Notebook code cell only, if you are using command line directly, you don't need it.
69
+
70
+ 2. using the code snippet below in jupyter notebook code cell.
71
+
72
+ ```python
73
+ import os
74
+ from dotenv import load_dotenv
75
+ load_dotenv()
76
+
77
+ HF_API_KEY = os.getenv('HF_API_KEY') ## I use Hugging Face API key here as an example.
78
+ ```
79
+
80
+ - You can then execute the following code in notebook to check if it is succeed
81
+
82
+ ```python
83
+ print(HF_API_KEY)
84
+ # Remember: this is only in your notebook cell, for your own check, do not submit this to our code space later on.
85
+ ```
86
+
87
+
88
+ """
89
+ )
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ streamlit==1.24.0