-
Notifications
You must be signed in to change notification settings - Fork 45
Optimize gradio #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize gradio #53
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR optimizes the Gradio web interface by reorganizing imports, adding file preview functionality, and improving UI layout. The changes enhance the user experience by providing better file preview capabilities and cleaner code organization.
- Refactored utility imports into a centralized module structure
- Added file preview functionality for uploaded files with support for CSV and text formats
- Reorganized UI components layout and updated translation entries
Reviewed Changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| webui/utils/preview_file.py | New utility function for file preview with CSV and text support |
| webui/utils/cache.py | Minor import reordering for consistency |
| webui/utils/init.py | New init file exposing utility functions |
| webui/translation.json | Added translation entries for new UI components |
| webui/app.py | Refactored imports, added file preview components, reorganized UI layout |
| graphgen/configs/*.yaml | Moved configuration options to maintain consistent ordering |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| with codecs.open(path, "r", encoding="utf-8") as f: | ||
| text = f.read(5000) | ||
| if len(text) == 5000: | ||
| text += "\n\n... (truncated at 5000 chars)" |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 5000 should be defined as a named constant at the module level to improve maintainability and make the truncation limit configurable.
|
|
||
| try: | ||
| if ext == ".csv": | ||
| df = pd.read_csv(path, nrows=10) |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 10 for CSV row limit should be defined as a named constant at the module level to improve maintainability.
| preview_file, inputs=upload_file, outputs=[preview_code, preview_df] | ||
| ).then( | ||
| lambda x: gr.update(visible=True), inputs=upload_file, outputs=token_counter |
Copilot
AI
Sep 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lambda function should be extracted to a named function to improve code readability and maintainability.
This PR optimizes the Gradio web interface by reorganizing imports, adding file preview functionality, and improving UI layout. The changes enhance the user experience by providing better file preview capabilities and cleaner code organization.