feat(gui): Support hiding services and their details#746
feat(gui): Support hiding services and their details#746awwaawwa merged 6 commits intoPDFMathTranslate:mainfrom
Conversation
2. A dumb way to fix PDFMathTranslate#744, which keys still in Gradio, there is also have risk of key leakage, but the GUI view is more clean.
There was a problem hiding this comment.
PR Overview
This PR addresses issues with the gradio UI by fixing translator naming inconsistencies and adding two new configuration options to control enabled services and gradio detail visibility. Key changes include replacing "GorkTranslator" with "GrokTranslator" across multiple files, introducing configuration-based filtering for services via ENABLED_SERVICES, and adding a flag for hiding gradio details via HIDDEN_GRADIO_DETAILS.
Reviewed Changes
| File | Description |
|---|---|
| pdf2zh/gui.py | Renames translator, adds config handling for enabled services and gradio detail visibility, and updates dropdown defaults. |
| pdf2zh/converter.py | Updates translator reference from GorkTranslator to GrokTranslator. |
| pdf2zh/pdf2zh.py | Renames translator reference from GorkTranslator to GrokTranslator. |
| pdf2zh/translator.py | Renames class from GorkTranslator to GrokTranslator. |
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
pdf2zh/gui.py:585
- Setting the Dropdown's default value to an empty string may cause issues if it does not match any of the choices in enabled_services. Consider using a default value that is present in the enabled_services list.
value=""
|
sorry... i guess i have made a mistake. the assertion about enabled_services is too absolute, we need to keep the original when the configuration is not effective. I'll fix it later |
|
@tylzh97 @awwaawwa mask的问题,我再次确认了一下,gradio有bug。已经向上游提了issue,在上游确认后再进行修改。 |
|
@tylzh97 默认值可以保留Google和bing。这样的话也可以在其他api失效时能够有备用service作为补充。 |
Just display everything directly by default, it doesn't affect users who don't use this feature at all. |
|
Before the configuration system is completely refactored, we should not introduce too many changes in this area. The initialization of the translator will be completely changed in the configuration system refactoring. |
|
Gotcha. This is a very simple PR that can meet the real deployment needs. I will ensure that the performance in the default configuration state remains unchanged, and I will submit a patch later. As for Gradio, I am not familiar with nor have used Gradio Mask. Using '***' as a placeholder can ensure that our keys are not leaked. |
Let's handle it this way, this PR will serve as a workaround to temporarily support this requirement. The formal solution will be implemented after the configuration system restructuring is completed. |
这个方式应该做不到想要的效果,或者最简单的方式就是直接把相关的部分的type直接设置成password。无论是URL还是API key都设成password。等上游bug解决了,我们就可以动态的设置相关的mask了。 |
There was a problem hiding this comment.
PR Overview
This PR fixes UI issues in the Gradio interface and corrects naming inconsistencies with the translator classes, while also addressing typos. Key changes include:
- Renaming all occurrences of "GorkTranslator" to "GrokTranslator".
- Introducing new configuration keys ("ENABLED_SERVICES" and "HIDDEN_GRADIO_DETAILS") to control available services and hide API keys in the UI.
- Fixing typos in error messages and comments.
Reviewed Changes
| File | Description |
|---|---|
| pdf2zh/gui.py | Updated translator reference, added service configuration logic, and fixed error message wording. |
| pdf2zh/converter.py | Renamed translator reference from GorkTranslator to GrokTranslator. |
| pdf2zh/pdf2zh.py | Renamed translator reference from GorkTranslator to GrokTranslator. |
| pdf2zh/translator.py | Renamed class from GorkTranslator to GrokTranslator. |
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Please use |
|
有个小问题,目前这样的设计的话,是不是没有了在web上修改API的能力了? |
|
Can you write a simple document to describe this feature at https://github.com/Byaidu/PDFMathTranslate/blob/main/docs/ADVANCED.md. @tylzh97 |
When this function is needed, it's obviously not desirable for users to modify the API on the webui. |
是的 我就是这样设计的 因为部署给普通用户使用 也没必要让普通用户修改 API 了[捂脸] 如果需要修改 API 和 API_KEY 那么直接使用项目官网的网页版本就好了 私有化部署可能没有这个需求 |
可以选择不开启 "HIDDEN_GRADIO_DETAILS" 选项 , 这样也允许用户在 Gradio 中修改 API 以及 API_KEY |
There was a problem hiding this comment.
PR Overview
A feature update to support hiding services and their detailed information via two new configuration options while also correcting typos and renaming translators.
- Added documentation for the new configuration keys ENABLED_SERVICES and HIDDEN_GRADIO_DETAILS
- Renamed translator references from GorkTranslator to GrokTranslator across multiple modules
- Updated Gradio UI behavior to hide real API keys and enforce enabled service filtering
Reviewed Changes
| File | Description |
|---|---|
| docs/ADVANCED.md | Added documentation for new configuration options and updated JSON sample usage |
| pdf2zh/gui.py | Updated translator naming, introduced logic for enabled services, and masked API keys |
| pdf2zh/pdf2zh.py | Updated translator list to use GrokTranslator |
| pdf2zh/translator.py | Renamed class from GorkTranslator to GrokTranslator |
| pdf2zh/converter.py | Updated translator list initialization to use GrokTranslator |
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
pdf2zh/gui.py:668
- [nitpick] Consider revising the comment for clarity, for example: 'We use "***" to mask the real API key.'
value = "***" # We use "***" Present Real API_KEY
|
Thank you for your contribution. According to https://funstory-ai.github.io/BabelDOC/CONTRIBUTOR_REWARD/ , you can apply for a monthly membership redemption code for Immersive Translate. |
|
There is a https://github.com/tylzh97/PDFMathTranslate/blob/fix-gradio-ui/.github/workflows/fork-build.yml CI that can build ghcr docker for forks as well. The pdf2zh main branch just released 1.9.5, and the next release should be in about 3-5 days or a week. During this period, you can use the ghcr docker image built from the forked repository. |
|
Or you can also use the image with the dev tag from the main line. |
Gotcha, thanks. |








fix #744 problems
Adding two Configure "ENABLED_SERVICES" and "HIDDEN_GRADIO_DETAILS"
and fix some typos.