Skip to content

A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.

Fix critical bug in non-PDF path, expose num_predict in UI, bump Streamlit to >=1.33.0

Tiioluwanib40f1e504f29
diff --git a/multimodal_apps/glm-ocr-pro/app.py b/multimodal_apps/glm-ocr-pro/app.py
index 9572d62..8547ad6 100644
--- a/multimodal_apps/glm-ocr-pro/app.py
+++ b/multimodal_apps/glm-ocr-pro/app.py
@@ -78,6 +78,8 @@ with col1:
use_grayscale = st.checkbox("Enable Grayscale (Recommended)", value=default_gray)
max_side = st.number_input("Max Side (px)", 400, 2400, default_side, step=100)
pdf_render_scale = st.number_input("PDF Rendering Scale", 1.0, 3.0, float(default_render), step=0.1)
+ num_predict = st.number_input("Max Output Tokens", 256, 8192, 2048, step=256)
+
if st.button("🚀 Extract Knowledge", type="primary", use_container_width=True):
if uploaded_file is None:
@@ -100,8 +102,8 @@ with col1:
max_side=max_side,
grayscale=use_grayscale,
pdf_render_scale=pdf_render_scale,
- ):
- full_text += chunk
+ num_predict=int(num_predict),
+ ): full_text += chunk
# Prettify rendering during stream
output_placeholder.markdown(full_text)
diff --git a/multimodal_apps/glm-ocr-pro/ocr_local.py b/multimodal_apps/glm-ocr-pro/ocr_local.py
index d5a82d9..7d16b90 100644
--- a/multimodal_apps/glm-ocr-pro/ocr_local.py
+++ b/multimodal_apps/glm-ocr-pro/ocr_local.py
@@ -145,7 +145,7 @@ def extract_markdown_local_stream(
yield f"## Page {idx}\n\n"
if optimize_images:
page_bytes = _optimize_image_bytes(page_bytes, max_side=max_side, grayscale=grayscale)
- yield from _run_single_image_local_stream(page_bytes, timeout_seconds=timeout_seconds, num_predict=num_predict)
+ yield from _run_single_image_local_stream(file_bytes, timeout_seconds=timeout_seconds, num_predict=num_predict)
yield "\n\n---\n\n"
else:
if optimize_images:
diff --git a/multimodal_apps/glm-ocr-pro/requirements.txt b/multimodal_apps/glm-ocr-pro/requirements.txt
index 0ee2930..215dbdd 100644
--- a/multimodal_apps/glm-ocr-pro/requirements.txt
+++ b/multimodal_apps/glm-ocr-pro/requirements.txt
@@ -1,3 +1,3 @@
-streamlit>=1.31.0
+streamlit>=1.33.0
pypdfium2>=4.30.0
pillow>=10.0.0
\ No newline at end of file