Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -262,6 +262,10 @@ def process_pdf(pdf, fmt, ctx_size, snippet_num, prompt):
|
|
262 |
logging.error(f"Error processing PDF: {e}")
|
263 |
return f"Error processing PDF: {str(e)}", "", []
|
264 |
|
|
|
|
|
|
|
|
|
265 |
# Main Interface
|
266 |
with gr.Blocks(theme=gr.themes.Default()) as demo:
|
267 |
# Store context size value
|
@@ -287,6 +291,16 @@ with gr.Blocks(theme=gr.themes.Default()) as demo:
|
|
287 |
label="π Output Format"
|
288 |
)
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
gr.Markdown("### Context Size")
|
291 |
with gr.Row():
|
292 |
for size_name, size_value in CONTEXT_SIZES.items():
|
|
|
262 |
logging.error(f"Error processing PDF: {e}")
|
263 |
return f"Error processing PDF: {str(e)}", "", []
|
264 |
|
265 |
+
The main error is the context_size not being defined before it's used in the button click handlers. Let's fix the order of component definitions and handlers. Here's the corrected UI section:
|
266 |
+
python
|
267 |
+
|
268 |
+
Copy
|
269 |
# Main Interface
|
270 |
with gr.Blocks(theme=gr.themes.Default()) as demo:
|
271 |
# Store context size value
|
|
|
291 |
label="π Output Format"
|
292 |
)
|
293 |
|
294 |
+
# First define the slider
|
295 |
+
context_size = gr.Slider(
|
296 |
+
minimum=1000,
|
297 |
+
maximum=200000,
|
298 |
+
step=1000,
|
299 |
+
value=32000,
|
300 |
+
label="π Custom Context Size"
|
301 |
+
)
|
302 |
+
|
303 |
+
# Then define the context size buttons
|
304 |
gr.Markdown("### Context Size")
|
305 |
with gr.Row():
|
306 |
for size_name, size_value in CONTEXT_SIZES.items():
|