Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1420,7 +1420,7 @@ if example_input:
|
|
| 1420 |
search_glossary(result)
|
| 1421 |
st.markdown(' ')
|
| 1422 |
|
| 1423 |
-
st.write("Search history:")
|
| 1424 |
for example_input in session_state["search_queries"]:
|
| 1425 |
st.write(example_input)
|
| 1426 |
|
|
@@ -1438,40 +1438,42 @@ choice = st.sidebar.selectbox("Output File Type:", menu)
|
|
| 1438 |
|
| 1439 |
#model_choice = st.sidebar.radio("Select Model:", ('gpt-3.5-turbo', 'gpt-3.5-turbo-0301'))
|
| 1440 |
#user_prompt = st.text_area("Enter prompts, instructions & questions:", '', height=100)
|
| 1441 |
-
|
| 1442 |
-
|
| 1443 |
-
|
| 1444 |
-
|
| 1445 |
-
|
| 1446 |
-
|
| 1447 |
-
|
| 1448 |
-
|
| 1449 |
-
|
| 1450 |
-
|
| 1451 |
-
|
| 1452 |
-
|
| 1453 |
-
|
|
|
|
| 1454 |
|
| 1455 |
-
|
| 1456 |
-
if
|
| 1457 |
-
st.
|
| 1458 |
-
|
| 1459 |
-
|
| 1460 |
-
|
| 1461 |
-
st.markdown("**Chat with the model:**")
|
| 1462 |
-
for i, section in enumerate(list(document_sections)):
|
| 1463 |
-
if i in document_responses:
|
| 1464 |
-
st.markdown(f"**Section {i+1}**\n{document_responses[i]}")
|
| 1465 |
-
else:
|
| 1466 |
-
if st.button(f"Chat about Section {i+1}"):
|
| 1467 |
-
st.write('Reasoning with your inputs...')
|
| 1468 |
-
st.write('Response:')
|
| 1469 |
-
st.write(response)
|
| 1470 |
-
document_responses[i] = response
|
| 1471 |
-
filename = generate_filename(f"{user_prompt}_section_{i+1}", choice)
|
| 1472 |
-
create_file(filename, user_prompt, response, should_save)
|
| 1473 |
-
st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
|
| 1474 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1475 |
|
| 1476 |
num_columns_video=st.slider(key="num_columns_video", label="Choose Number of Video Columns", min_value=1, max_value=10, value=2)
|
| 1477 |
display_videos_and_links(num_columns_video) # Video Jump Grid
|
|
|
|
| 1420 |
search_glossary(result)
|
| 1421 |
st.markdown(' ')
|
| 1422 |
|
| 1423 |
+
#st.write("Search history:")
|
| 1424 |
for example_input in session_state["search_queries"]:
|
| 1425 |
st.write(example_input)
|
| 1426 |
|
|
|
|
| 1438 |
|
| 1439 |
#model_choice = st.sidebar.radio("Select Model:", ('gpt-3.5-turbo', 'gpt-3.5-turbo-0301'))
|
| 1440 |
#user_prompt = st.text_area("Enter prompts, instructions & questions:", '', height=100)
|
| 1441 |
+
AddAFileForContext=False
|
| 1442 |
+
if AddAFileForContext:
|
| 1443 |
+
|
| 1444 |
+
collength, colupload = st.columns([2,3]) # adjust the ratio as needed
|
| 1445 |
+
with collength:
|
| 1446 |
+
#max_length = st.slider(key='maxlength', label="File section length for large files", min_value=1000, max_value=128000, value=12000, step=1000)
|
| 1447 |
+
max_length = 128000
|
| 1448 |
+
with colupload:
|
| 1449 |
+
uploaded_file = st.file_uploader("Add a file for context:", type=["pdf", "xml", "json", "xlsx", "csv", "html", "htm", "md", "txt"])
|
| 1450 |
+
document_sections = deque()
|
| 1451 |
+
document_responses = {}
|
| 1452 |
+
if uploaded_file is not None:
|
| 1453 |
+
file_content = read_file_content(uploaded_file, max_length)
|
| 1454 |
+
document_sections.extend(divide_document(file_content, max_length))
|
| 1455 |
|
| 1456 |
+
|
| 1457 |
+
if len(document_sections) > 0:
|
| 1458 |
+
if st.button("๐๏ธ View Upload"):
|
| 1459 |
+
st.markdown("**Sections of the uploaded file:**")
|
| 1460 |
+
for i, section in enumerate(list(document_sections)):
|
| 1461 |
+
st.markdown(f"**Section {i+1}**\n{section}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1462 |
|
| 1463 |
+
st.markdown("**Chat with the model:**")
|
| 1464 |
+
for i, section in enumerate(list(document_sections)):
|
| 1465 |
+
if i in document_responses:
|
| 1466 |
+
st.markdown(f"**Section {i+1}**\n{document_responses[i]}")
|
| 1467 |
+
else:
|
| 1468 |
+
if st.button(f"Chat about Section {i+1}"):
|
| 1469 |
+
st.write('Reasoning with your inputs...')
|
| 1470 |
+
st.write('Response:')
|
| 1471 |
+
st.write(response)
|
| 1472 |
+
document_responses[i] = response
|
| 1473 |
+
filename = generate_filename(f"{user_prompt}_section_{i+1}", choice)
|
| 1474 |
+
create_file(filename, user_prompt, response, should_save)
|
| 1475 |
+
st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
|
| 1476 |
+
|
| 1477 |
|
| 1478 |
num_columns_video=st.slider(key="num_columns_video", label="Choose Number of Video Columns", min_value=1, max_value=10, value=2)
|
| 1479 |
display_videos_and_links(num_columns_video) # Video Jump Grid
|