Spaces:
Runtime error
Runtime error
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: | |
""") | |