Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,63 +1,64 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import openai
|
| 3 |
-
import nltk
|
| 4 |
-
nltk.download('punkt')
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
-
# Define function to generate keywords
|
| 10 |
-
def generate_keywords(text):
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
# Define function to generate summary
|
| 33 |
-
def generate_summary(text):
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
# Set up Streamlit app
|
| 55 |
-
st.title("Text Summarization and Keyword Extraction")
|
| 56 |
-
|
| 57 |
-
text = st.text_area("Enter some text:")
|
| 58 |
-
|
| 59 |
-
if st.button("Generate Keywords"):
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
if st.button("Generate Summary"):
|
| 63 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
# import openai
|
| 3 |
+
# import nltk
|
| 4 |
+
# nltk.download('punkt')
|
| 5 |
|
| 6 |
+
st.write("ok")
|
| 7 |
+
# # Set up OpenAI API credentials
|
| 8 |
+
# openai.api_key = "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"
|
| 9 |
|
| 10 |
+
# # Define function to generate keywords
|
| 11 |
+
# def generate_keywords(text):
|
| 12 |
+
# num_keywords = 6
|
| 13 |
+
# cleaned_text = text.strip()
|
| 14 |
|
| 15 |
+
# response = openai.Completion.create(
|
| 16 |
+
# engine="text-davinci-002",
|
| 17 |
+
# prompt=f"What are {num_keywords} highly related keywords for the following text?\n{cleaned_text}\n\nKeywords:",
|
| 18 |
+
# max_tokens=50,
|
| 19 |
+
# n=1,
|
| 20 |
+
# stop=None,
|
| 21 |
+
# temperature=0.5,
|
| 22 |
+
# best_of=num_keywords,
|
| 23 |
+
# )
|
| 24 |
+
|
| 25 |
+
# generated_text = response.choices[0].text.strip()
|
| 26 |
+
|
| 27 |
+
# keywords = generated_text.split(',')
|
| 28 |
+
|
| 29 |
+
# st.write("Top Keywords:")
|
| 30 |
+
# for i, keyword in enumerate(keywords[:num_keywords]):
|
| 31 |
+
# st.write(f"{i+1}. {keyword.strip()}")
|
| 32 |
+
|
| 33 |
+
# # Define function to generate summary
|
| 34 |
+
# def generate_summary(text):
|
| 35 |
+
# summary_length = 2
|
| 36 |
+
|
| 37 |
+
# cleaned_text = text.strip()
|
| 38 |
+
|
| 39 |
+
# response = openai.Completion.create(
|
| 40 |
+
# engine="text-davinci-002",
|
| 41 |
+
# prompt=f"Please summarize the following text in {summary_length} sentences:\n{cleaned_text}\n\nSummary:",
|
| 42 |
+
# max_tokens=100,
|
| 43 |
+
# n=1,
|
| 44 |
+
# stop=None,
|
| 45 |
+
# temperature=0.5,
|
| 46 |
+
# )
|
| 47 |
+
|
| 48 |
+
# generated_text = response.choices[0].text.strip()
|
| 49 |
+
# st.write("Description:")
|
| 50 |
+
# # st.write(generated_text)
|
| 51 |
+
# sentences = nltk.sent_tokenize(generated_text)
|
| 52 |
+
# for sentence in sentences:
|
| 53 |
+
# st.write(sentence)
|
| 54 |
+
|
| 55 |
+
# # Set up Streamlit app
|
| 56 |
+
# st.title("Text Summarization and Keyword Extraction")
|
| 57 |
+
|
| 58 |
+
# text = st.text_area("Enter some text:")
|
| 59 |
+
|
| 60 |
+
# if st.button("Generate Keywords"):
|
| 61 |
+
# generate_keywords(text)
|
| 62 |
+
|
| 63 |
+
# if st.button("Generate Summary"):
|
| 64 |
+
# generate_summary(text)
|