Spaces:
Sleeping
Sleeping
grapplerulrich
commited on
Commit
·
ad98547
1
Parent(s):
1f86974
Addon from previous commit
Browse files
app.py
CHANGED
@@ -59,6 +59,7 @@ def content_summary( url_id, content ):
|
|
59 |
else:
|
60 |
try:
|
61 |
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
|
|
|
62 |
summary = summarizer(content, max_length=130, min_length=30, do_sample=False, truncation=True)
|
63 |
except Exception as exception:
|
64 |
raise exception
|
@@ -98,15 +99,18 @@ def main():
|
|
98 |
st.json( results )
|
99 |
|
100 |
progress_bar = st.progress(0)
|
|
|
|
|
101 |
st.markdown('---')
|
102 |
|
103 |
# for result in results:
|
104 |
for index, result in enumerate(results):
|
105 |
with st.container():
|
|
|
106 |
url_id = uuid.uuid5( uuid.NAMESPACE_URL, result['link'] ).hex
|
107 |
-
|
108 |
try:
|
109 |
-
|
|
|
110 |
summary = content_summary( url_id, content )
|
111 |
for sentence in summary:
|
112 |
st.write(sentence['summary_text'])
|
@@ -120,11 +124,11 @@ def main():
|
|
120 |
st.markdown('[Website Link]({})'.format(result['link']))
|
121 |
|
122 |
with col2:
|
123 |
-
if st.button('Delete content cache', key=url_id + 'content'):
|
124 |
remove( 'page-content/' + url_id + '.txt' )
|
125 |
|
126 |
with col3:
|
127 |
-
if st.button('Delete summary cache', key=url_id + 'summary'):
|
128 |
remove( 'summaries/' + url_id + '.json' )
|
129 |
|
130 |
st.markdown('---')
|
|
|
59 |
else:
|
60 |
try:
|
61 |
summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
|
62 |
+
# https://huggingface.co/docs/transformers/v4.18.0/en/main_classes/pipelines#transformers.SummarizationPipeline
|
63 |
summary = summarizer(content, max_length=130, min_length=30, do_sample=False, truncation=True)
|
64 |
except Exception as exception:
|
65 |
raise exception
|
|
|
99 |
st.json( results )
|
100 |
|
101 |
progress_bar = st.progress(0)
|
102 |
+
|
103 |
+
st.header('Search results')
|
104 |
st.markdown('---')
|
105 |
|
106 |
# for result in results:
|
107 |
for index, result in enumerate(results):
|
108 |
with st.container():
|
109 |
+
st.markdown('### ' + result['title'])
|
110 |
url_id = uuid.uuid5( uuid.NAMESPACE_URL, result['link'] ).hex
|
|
|
111 |
try:
|
112 |
+
strings = get_url_content( result['link'] )
|
113 |
+
content = ' '.join( [ string for string in strings ] )
|
114 |
summary = content_summary( url_id, content )
|
115 |
for sentence in summary:
|
116 |
st.write(sentence['summary_text'])
|
|
|
124 |
st.markdown('[Website Link]({})'.format(result['link']))
|
125 |
|
126 |
with col2:
|
127 |
+
if st.button('Delete content from cache', key=url_id + 'content'):
|
128 |
remove( 'page-content/' + url_id + '.txt' )
|
129 |
|
130 |
with col3:
|
131 |
+
if st.button('Delete summary from cache', key=url_id + 'summary'):
|
132 |
remove( 'summaries/' + url_id + '.json' )
|
133 |
|
134 |
st.markdown('---')
|