Closed abpani closed 2 weeks ago
I am trying to upload a pdf file. then highlighting some part of it. and then trying to show the updated file in the same component.
with gr.Column(scale=1): file = PDF(label="Upload a document", interactive=True)
submit_btn.click(add_text, [chatbot, txt], [chatbot, txt]).then( bot, [chatbot], [chatbot]).then( clear_cuda_cache, None ).then(return_output_path, [], file)
import gradio as gr from gradio_pdf import PDF import base64
with gr.Blocks(gr.themes.Soft(primary_hue=gr.themes.colors.slate, secondary_hue=gr.themes.colors.purple)) as demo: with gr.Row():
with gr.Column(scale=1, variant = 'panel'): with gr.Row(equal_height=True): with gr.Column(scale=1): vector_index_btn = gr.Button('Create vector store', variant='primary') load_success_msg = gr.Textbox(show_label=False,lines=1, placeholder="Model loading ...") # hf_token = gr.Textbox(label='Enter your valid HF token_id', value='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', type = "password") with gr.Column(scale=1): llm = gr.Dropdown(choices= ["Qwen2.5", "stella_400m", 'stella_1.5B'], value="Qwen2.5", label="Select the LLM") model_load_btn = gr.Button('Load model', variant='primary') chatbot = gr.Chatbot([], elem_id="chatbot",label='Chatbox', height=530) # contains history txt = gr.Textbox(label= "Question", lines=2, placeholder="Enter your question and press shift+enter ") # user query with gr.Row(): with gr.Column(scale=1): submit_btn = gr.Button('Submit',variant='primary', size = 'sm') with gr.Column(scale=1): clear_btn = gr.Button('Clear',variant='stop',size = 'sm') with gr.Column(scale=1): file = PDF(label="Upload a document", interactive=True) # render = gr.HTML(f""" # <div style='height: 800px; width: 700px; background-color: pink;'></div> # """, visible=True) vector_index_btn.click(upload_and_create_vector_store,[file], [load_success_msg]) model_load_btn.click(load_models, [llm], load_success_msg, api_name="load_models") txt.submit(add_text, [chatbot, txt], [chatbot, txt]).then( bot, [chatbot], chatbot) submit_btn.click(add_text, [chatbot, txt], [chatbot, txt]).then( bot, [chatbot], [chatbot]).then( clear_cuda_cache, None ).then(return_output_path, [], file) clear_btn.click(lambda: None, None, chatbot, queue=False)
No response
Operating System: Linux gradio version: 5.1.0 gradio_client version: 1.4.0 ------------------------------------------------ gradio dependencies in your environment: aiofiles: 23.2.1 anyio: 4.6.2.post1 fastapi: 0.115.2 ffmpy: 0.4.0 gradio-client==1.4.0 is not installed. httpx: 0.27.2 huggingface-hub: 0.25.2 jinja2: 3.1.4 markupsafe: 2.1.5 numpy: 1.26.4 orjson: 3.10.7 packaging: 24.1 pandas: 2.2.3 pillow: 10.4.0 pydantic: 2.9.2 pydub: 0.25.1 python-multipart: 0.0.12 pyyaml: 6.0.2 ruff: 0.7.0 semantic-version: 2.10.0 tomlkit==0.12.0 is not installed. typer: 0.12.5 typing-extensions: 4.12.2 urllib3: 2.2.3 uvicorn: 0.32.0 authlib; extra == 'oauth' is not installed. itsdangerous; extra == 'oauth' is not installed. gradio_client dependencies in your environment: fsspec: 2024.6.1 httpx: 0.27.2 huggingface-hub: 0.25.2 packaging: 24.1 typing-extensions: 4.12.2 websockets: 12.0
I can work around it
Hi @abpani I would suggest opening an issue in the custom component’s repo: https://github.com/freddyaboulton/gradio-pdf
cc @freddyaboulton
Describe the bug
I am trying to upload a pdf file. then highlighting some part of it. and then trying to show the updated file in the same component.
with gr.Column(scale=1): file = PDF(label="Upload a document", interactive=True)
submit_btn.click(add_text, [chatbot, txt], [chatbot, txt]).then( bot, [chatbot], [chatbot]).then( clear_cuda_cache, None ).then(return_output_path, [], file)
Have you searched existing issues? 🔎
Reproduction
import gradio as gr from gradio_pdf import PDF import base64
with gr.Blocks(gr.themes.Soft(primary_hue=gr.themes.colors.slate, secondary_hue=gr.themes.colors.purple)) as demo: with gr.Row():
Screenshot
No response
Logs
No response
System Info
Severity
I can work around it