Skip to content

Commit 9cd403a

Browse files
authored
Merge pull request #275 from Annarhysa/main
New python project made by Annarhysa Albert
2 parents 5f99866 + 4bf51f4 commit 9cd403a

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Summarizer App/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.Streamlit/

Summarizer App/app.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import openai
2+
import streamlit as st
3+
4+
openai.api_key = st.secrets['api_secret']
5+
6+
st.header("Summarizer App using OpenAI ")
7+
article_text = st.text_area("Enter your scientific texts to summarize")
8+
output_size = st.radio( label = "What kind of output do you want? ", options= ["To-The-Point", "Concise", "Detailed"])
9+
10+
if output_size == "To-The-Point":
11+
out_token = 50
12+
elif output_size == "Concise":
13+
out_token = 128
14+
else:
15+
out_token = 516
16+
17+
18+
if (len(article_text)>100):
19+
# max = st.text_input("Enter the max words you want your text to be summarized in")
20+
if st.button("Generate Summary",type='primary'):
21+
response = openai.Completion.create( engine = "text-davinci-002", prompt = "Please summarize this scientific article for me in a few sentences: "+ article_text, max_tokens = out_token, temperature = 0.5)
22+
res = response["choices"][0]["text"]
23+
st.success(res)
24+
st.download_button("Download the result", res)
25+
26+
elif (len(article_text)<100):
27+
st.warning("The Sentence is not long enough")

0 commit comments

Comments
 (0)