File size: 3,089 Bytes
31ff6c1
 
 
 
422eddd
31ff6c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import streamlit as st
from utils import *
st.set_page_config(page_title="The first App", page_icon=":tangerine:")

if check_password("password"):
    st.markdown("## Welcome to the first app: summarizer")
    st.write("##")
    
    st.markdown("We have seen our summarization prompt from our notebook")
    st.code('''
    numberOfWords = '20'
    topics = "marry"

    prompt = f"""
    Your task is to generate a short summary from text below, delimited by triple backticks, in at most {numberOfWords} words,\n
    Firstly, extract relevant information and create a list of keywords without response,\n
    Then, check if {topics} is in your list, if not, just response no relevent topics about {topics} to summarise,\n
    if it is in your list, focusing on any aspects that mention {topics},\n
    Review: ```{text}```
    """
    ''', language = "python")
    
    st.markdown("""
    We have 3 variables above, numberOfWords, topics, and text, which means, our app will give users
    3 input windows or widgets, 
    - a Text input window for the text that need to be summarized, where users can copy and paste large text into it;
    - a short text input window, that user can choose to choose the topics he/she want the app to summarize;
    - a number input window, that user can select the length of summarization;
    
    - Additionally, a secret window that allow users to pass their own OpenAI API Key to use ChatGPT
    """)
    st.write("##")
    st.markdown("""
    The following streamlit widgets can help us to achieve requirement above:
    
    1. [st.text_area](https://docs.streamlit.io/library/api-reference/widgets/st.text_area) 
    
    Try to copy the following code to your app.py and rerun the local streamlit server
    
    ```python
    txt = st.text_area('Text to summarize', "")
    st.write(txt)
    ```
    """)
    
    txt = st.text_area('Text to summarize', "")
    st.write(txt)
    
    st.write("##")
    st.markdown("""
    2. [st.text_input](https://docs.streamlit.io/library/api-reference/widgets/st.text_input) 
    
    Copy the code and run it on your app.py
    
    ```python
    topics = st.text_input('Choose topics, seperated by ,', '')
    st.write(topics)
    ```
    """)
    
    topics = st.text_input('Choose topics, seperated by ,', '')
    st.write(topics)
    st.write("##")
    
    st.markdown("""
    3. [st.number_input](https://docs.streamlit.io/library/api-reference/widgets/st.number_input)
    
    Copy the code ane rerun on your app.py
    ```python
    number = st.number_input('words limit')
    st.write('The current number is ', number)
    ``` 
    """)
    
    number = st.number_input('words limit')
    st.write('The current number is ', number)
    st.write("##")
    st.markdown("""
    Now, your task is to download the initial app this week:
    
        - Read the code;
        - figuring our where are those widgets located in the code;
        - ask any question in the Discord;
        - bravely change the code on your computer, do some experiment 
    
    :smile:
    """)