diff --git a/examples/gradio_upload.py b/examples/gradio_upload.py index 4b8425d..1db1464 100644 --- a/examples/gradio_upload.py +++ b/examples/gradio_upload.py @@ -5,7 +5,7 @@ from smolagents import ( ) agent = CodeAgent( - tools=[], model=HfApiModel(), max_steps=4, verbosity_level=0 + tools=[], model=HfApiModel(), max_steps=4, verbosity_level=1 ) GradioUI(agent, file_upload_folder='./data').launch() diff --git a/src/smolagents/gradio_ui.py b/src/smolagents/gradio_ui.py index 26c2998..e6d52e5 100644 --- a/src/smolagents/gradio_ui.py +++ b/src/smolagents/gradio_ui.py @@ -120,15 +120,21 @@ class GradioUI: """ if file is None: - return "No file uploaded" + return gr.Textbox( + "No file uploaded", visible=True + ), file_uploads_log try: mime_type, _ = mimetypes.guess_type(file.name) except Exception as e: - return f"Error: {e}" + return gr.Textbox( + f"Error: {e}", visible=True + ), file_uploads_log if mime_type not in allowed_file_types: - return "File type disallowed" + return gr.Textbox( + "File type disallowed", visible=True + ), file_uploads_log # Sanitize file name original_name = os.path.basename(file.name) @@ -181,7 +187,7 @@ class GradioUI: ) # If an upload folder is provided, enable the upload feature if self.file_upload_folder is not None: - upload_file = gr.File(label="Upload a file", height=1) + upload_file = gr.File(label="Upload a file") upload_status = gr.Textbox( label="Upload Status", interactive=False, visible=False )