Image generator#206
Open
theoteske wants to merge 7 commits into
Open
Conversation
Contributor
|
Dude you were killing me for a second, I had to do some remote add stuff but I finally was able to run a Pytest. app/tools/image_generator/tests/test_tools.py::test_image_generator_args_model PASSED [100%] ==================================================== 44 passed in 0.44s ===================================================== |
buriihenry
approved these changes
May 19, 2025
Contributor
buriihenry
left a comment
There was a problem hiding this comment.
Looking good. Share a loom video to show the process flow and the logic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR introduces a new Image Generator tool that creates high-quality educational images from text prompts. The tool leverages Black Forest Labs' Flux 1.1 Pro API for image generation and includes Google Cloud Storage integration for persistent image storage. It features educational context enhancement, content type detection and subsequent prompt enhancement, and safety filtering to ensure generated images are high quality and appropriate for educational use.
I have included a Loom video walkthrough.
Related Issue
N/A
Type of Change
Please select the type(s) of change that apply and delete those that do not.
Proposed Solution
The Image Generator tool is designed to create educational images with the following key components:
How to Test
Test Configuration:
Use the FastAPI Swagger UI at http://localhost:8000/docs to test the /submit-tool endpoint with the following JSON:
Expected Outcome:
The response should include:
image_b64field containing a base64-encoded imageprompt_usedfield showing the enhanced prompteducational_contextfield with "astronomy for middle school level"safety_appliedfield set totrueExample response:
If GCP storage is configured, the response will also include a
gcp_urlfield with a public URL to the stored image.Test Configuration:
Expected Outcome:
The response should show that the prompt was enhanced with the appropriate educational context:
prompt_usedfield should include "educational context: biology for high school level"Try another example with a different subject and grade level:
The response should show a simpler, more elementary-appropriate enhancement in the
prompt_usedfield.Test Configuration:
Expected Outcome:
The system should reject the unsafe content with an error response:
The logs should show:
Test Configuration:
Expected Outcome:
The system should return an error indicating that the prompt is required.
Unit Tests
The implementation includes comprehensive test coverage:
Core Functionality Tests:
test_executor: Tests the main executor functiontest_executor_without_gcp: Tests behavior without GCP configurationtest_executor_missing_inputs: Tests error handling for missing inputsImage Generation Tests:
test_generate_image_with_api_key: Tests basic image generationtest_generate_image_with_gcp_storage: Tests GCP storage integrationtest_generate_image_development_mode: Tests fallback behavior without API keyEducational Enhancement Tests:
test_generate_educational_image: Tests the full educational pipelinetest_enhance_prompt_with_educational_context: Tests context enhancementtest_detect_content_type: Tests content type detectionSafety Tests:
test_check_prompt_safety: Tests safety filteringtest_generate_educational_image_unsafe: Tests rejection of unsafe contentGCP Integration Tests:
test_upload_to_gcp_bucket: Tests GCP upload functionalitytest_generate_educational_image_without_gcp: Tests behavior without GCPDocumentation Updates
Indicate whether documentation needs to be updated due to this PR.
The README.md written in the PR includes comprehensive documentation covering:
Checklist
Additional Information