Skip to content

Fix Gradio env input overflow for providers with extra config fields#1150

Open
xueyu-jia wants to merge 1 commit into
PDFMathTranslate:mainfrom
xueyu-jia:fix-gradio-env-input-overflow
Open

Fix Gradio env input overflow for providers with extra config fields#1150
xueyu-jia wants to merge 1 commit into
PDFMathTranslate:mainfrom
xueyu-jia:fix-gradio-env-input-overflow

Conversation

@xueyu-jia

Copy link
Copy Markdown

Summary

Fixes an IndexError in the Gradio UI when selecting providers that define more environment variables than the UI exposes.
iterated over all translator env fields and wrote them into a fixed-size list of four UI updates. Providers such as OpenAI
define additional fields like OPENAI_STREAM, OPENAI_STOP_TOKENS, and OPENAI_MAX_TOKENS, which caused an IndexError.

  • keeps the prompt update as the final output
  • preserves extra translator env values from saved config or translator defaults during translation

Testing

  • Ran python -m py_compile pdf2zh/gui.py
  • Ran git diff --check -- pdf2zh/gui.py
  • Started the Gradio UI locally
  • Switched to OpenAI provider and confirmed no IndexError is raised

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants