feat: Add multilingual prompt optimizer with LangGraph agent support #16894
+560
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I'm trying to accomplish
This PR aims to enhance the text-to-image generation workflow by adding intelligent prompt processing capabilities. Specifically, it:
Summary of changes in code
Added
scripts/txt2img_prompt_optimizer.py
- A new script that:Updated
requirements.txt
to include:python-dotenv
for environment variable managementlanggraph
for building the agent workflowUpdated
requirements_versions.txt
with specific versions:Updated
.gitignore
to exclude:.env
files containing sensitive API keysIssues fixed
This PR addresses the feature request in Issue #4576, which requested multilingual prompt support but was previously marked as "not planned".
The implementation:
Screenshots/videos:
Here's a demonstration of how our system handles backend translations and their effectiveness for prompts in various languages. We will use 'a kitten under a pine tree' as a prompt to test the effects across different languages.
Chinese (simplified):
Japanese;
French;
Spanish;
Vietnamese.
Kiswahili
Checklist: