Update chunk.py
Browse files
chunk.py
CHANGED
|
@@ -10,3 +10,18 @@ def display_chunks(text, chunk_size=1000):
|
|
| 10 |
for j, chunk in enumerate(chunk_text(text, chunk_size)):
|
| 11 |
st.write(f"**Chunk {j+1}:**")
|
| 12 |
st.write(chunk)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
for j, chunk in enumerate(chunk_text(text, chunk_size)):
|
| 11 |
st.write(f"**Chunk {j+1}:**")
|
| 12 |
st.write(chunk)
|
| 13 |
+
|
| 14 |
+
# Function to save and download chunked text
|
| 15 |
+
def save_and_download_chunked_data(chunked_text, file_name="chunked_data.txt"):
|
| 16 |
+
# Combine chunks with delimiters (optional)
|
| 17 |
+
chunked_data = "\n---\n".join(chunked_text)
|
| 18 |
+
|
| 19 |
+
# Display download button in Streamlit
|
| 20 |
+
st.download_button(
|
| 21 |
+
label="Download Chunked Data",
|
| 22 |
+
data=chunked_data,
|
| 23 |
+
file_name=file_name,
|
| 24 |
+
mime="text/plain"
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
return chunked_data # Return the combined chunked data for further use if needed
|