Spaces:
Running
Running
adibak
commited on
Commit
·
3a1a1b8
1
Parent(s):
90c828a
additional changes
Browse files- app.py +20 -17
- helpers/file_manager.py +1 -1
- strings.json +1 -1
app.py
CHANGED
@@ -296,23 +296,26 @@ def set_up_chat_ui():
|
|
296 |
# Apparently, Streamlit stores uploaded files in memory and clears on browser close
|
297 |
# https://docs.streamlit.io/knowledge-base/using-streamlit/where-file-uploader-store-when-deleted
|
298 |
|
299 |
-
#
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
|
|
|
|
|
|
316 |
provider, llm_name = llm_helper.get_provider_model(
|
317 |
llm_provider_to_use,
|
318 |
use_ollama=RUN_IN_OFFLINE_MODE
|
|
|
296 |
# Apparently, Streamlit stores uploaded files in memory and clears on browser close
|
297 |
# https://docs.streamlit.io/knowledge-base/using-streamlit/where-file-uploader-store-when-deleted
|
298 |
|
299 |
+
# # check if pdf file is uploaded
|
300 |
+
# # (we can use the same file if the user doesn't upload a new one)
|
301 |
+
if 'pdf_file' in st.session_state:
|
302 |
+
# get validated page range
|
303 |
+
st.session_state['start_page'], st.session_state['end_page'] = filem.validate_page_range(
|
304 |
+
st.session_state['pdf_file'],
|
305 |
+
st.session_state['start_page'],
|
306 |
+
st.session_state['end_page']
|
307 |
+
)
|
308 |
+
# show sidebar text for page selection and file name
|
309 |
+
with st.sidebar:
|
310 |
+
st.text(f'Extracting pages {st.session_state["start_page"]} to {st.session_state["end_page"]} in {st.session_state["pdf_file"].name}')
|
311 |
+
|
312 |
+
# get pdf contents
|
313 |
+
st.session_state[ADDITIONAL_INFO] = filem.get_pdf_contents(
|
314 |
+
st.session_state['pdf_file'],
|
315 |
+
(st.session_state['start_page'],
|
316 |
+
st.session_state['end_page'])
|
317 |
+
)
|
318 |
+
|
319 |
provider, llm_name = llm_helper.get_provider_model(
|
320 |
llm_provider_to_use,
|
321 |
use_ollama=RUN_IN_OFFLINE_MODE
|
helpers/file_manager.py
CHANGED
@@ -32,7 +32,7 @@ def get_pdf_contents(
|
|
32 |
|
33 |
start, end = page_range # set start and end per the range (user-specified values)
|
34 |
|
35 |
-
|
36 |
text = ''
|
37 |
for page_num in range(start - 1, end):
|
38 |
page = reader.pages[page_num]
|
|
|
32 |
|
33 |
start, end = page_range # set start and end per the range (user-specified values)
|
34 |
|
35 |
+
print(f"Name: {pdf_file.name} Page range: {start} to {end}")
|
36 |
text = ''
|
37 |
for page_num in range(start - 1, end):
|
38 |
page = reader.pages[page_num]
|
strings.json
CHANGED
@@ -35,6 +35,6 @@
|
|
35 |
"Did you know that SlideDeck AI supports eight LLMs that generate contents in different styles?",
|
36 |
"Did you know that SlideDeck AI can create a presentation based on any uploaded PDF file?"
|
37 |
],
|
38 |
-
"chat_placeholder": "
|
39 |
"like_feedback": "If you like SlideDeck AI, please consider leaving a heart ❤\uFE0F on the [Hugging Face Space](https://huggingface.co/spaces/barunsaha/slide-deck-ai/) or a star ⭐ on [GitHub](https://github.com/barun-saha/slide-deck-ai). Your [feedback](https://forms.gle/JECFBGhjvSj7moBx9) is appreciated."
|
40 |
}
|
|
|
35 |
"Did you know that SlideDeck AI supports eight LLMs that generate contents in different styles?",
|
36 |
"Did you know that SlideDeck AI can create a presentation based on any uploaded PDF file?"
|
37 |
],
|
38 |
+
"chat_placeholder": "Write the topic or instructions here. You can also upload a PDF file.",
|
39 |
"like_feedback": "If you like SlideDeck AI, please consider leaving a heart ❤\uFE0F on the [Hugging Face Space](https://huggingface.co/spaces/barunsaha/slide-deck-ai/) or a star ⭐ on [GitHub](https://github.com/barun-saha/slide-deck-ai). Your [feedback](https://forms.gle/JECFBGhjvSj7moBx9) is appreciated."
|
40 |
}
|