Repository navigation
Draw VIP pictures with Krea 2 and MOSS only #313
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| LOCK TABLE provider_models, workflows, workflow_assignments IN SHARE ROW EXCLUSIVE MODE; | ||
|
|
||
| UPDATE provider_models | ||
| SET enabled = TRUE, | ||
| config = config - 'disabled_by_vip_two_pictures_v1' | ||
| WHERE config ? 'disabled_by_vip_two_pictures_v1'; | ||
|
|
||
| UPDATE workflows | ||
| SET enabled = TRUE | ||
| WHERE key = 'image_generation_fibo' | ||
| AND EXISTS ( | ||
| SELECT 1 FROM workflow_assignments | ||
| WHERE workflow_key = 'image_generation_fibo' | ||
| AND (inference_overrides ->> 'vip_two_pictures_v1_workflow_enabled')::BOOLEAN | ||
| ); | ||
|
|
||
| UPDATE workflow_assignments | ||
| SET enabled = TRUE, | ||
| inference_overrides = inference_overrides | ||
| - 'disabled_by_vip_two_pictures_v1' | ||
| - 'vip_two_pictures_v1_workflow_enabled' | ||
| WHERE inference_overrides ? 'disabled_by_vip_two_pictures_v1'; | ||
|
|
||
| UPDATE workflow_assignments | ||
| SET provider_model_id = (inference_overrides ->> 'vip_two_pictures_v1_previous_model_id')::BIGINT, | ||
| inference_overrides = inference_overrides - 'vip_two_pictures_v1_previous_model_id' | ||
| WHERE inference_overrides ? 'vip_two_pictures_v1_previous_model_id'; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| -- VIP draws drop their third picture, and aifarm-draw no longer serves Fibo 2.0 Dev | ||
| -- (`fibo_generate`). Every text-to-image fallback on Fibo 2.0 Dev moves to MOSS-Image, | ||
| -- or to Krea 2 where the workflow already routes to MOSS-Image; `image_generation_fibo` and | ||
| -- the Fibo 2.0 Dev model are disabled. Fibo 2.0 Edit Turbo keeps the edits. Nothing | ||
| -- changes unless the Krea 2, MOSS-Image and Fibo 2.0 Dev models exist. Every switched | ||
| -- row records its previous model and every disabled row carries a marker, so the down | ||
| -- migration restores the previous routing exactly. | ||
|
|
||
| LOCK TABLE llm_providers, provider_models, workflows, workflow_assignments | ||
| IN SHARE ROW EXCLUSIVE MODE; | ||
|
|
||
| DO $$ | ||
| BEGIN | ||
| IF EXISTS ( | ||
| SELECT 1 FROM workflow_assignments | ||
| WHERE inference_overrides ? 'vip_two_pictures_v1_previous_model_id' | ||
| OR inference_overrides ? 'disabled_by_vip_two_pictures_v1' | ||
| ) OR EXISTS ( | ||
| SELECT 1 FROM provider_models WHERE config ? 'disabled_by_vip_two_pictures_v1' | ||
| ) THEN | ||
| RAISE EXCEPTION 'VIP two-picture routing marker collision'; | ||
| END IF; | ||
| END $$; | ||
|
|
||
| CREATE TEMPORARY TABLE vip_two_pictures ON COMMIT DROP AS | ||
| SELECT | ||
| (SELECT max(model.id) FROM provider_models AS model | ||
| WHERE model.provider_id = provider.id AND model.enabled | ||
| AND model.config ->> 'endpoint_name' = 'krea2_generate') AS krea2_id, | ||
| (SELECT max(model.id) FROM provider_models AS model | ||
| WHERE model.provider_id = provider.id AND model.enabled | ||
| AND model.config ->> 'endpoint_name' = 'moss_generate') AS moss_id, | ||
| (SELECT max(model.id) FROM provider_models AS model | ||
| WHERE model.provider_id = provider.id AND model.enabled | ||
| AND model.config ->> 'endpoint_name' = 'fibo_generate') AS dev_id | ||
| FROM llm_providers AS provider | ||
| WHERE provider.name = 'aifarm-draw'; | ||
|
|
||
| DELETE FROM vip_two_pictures WHERE krea2_id IS NULL OR moss_id IS NULL OR dev_id IS NULL; | ||
|
|
||
| UPDATE workflow_assignments AS assignment | ||
| SET provider_model_id = CASE | ||
| WHEN EXISTS ( | ||
| SELECT 1 FROM workflow_assignments AS other | ||
| WHERE other.workflow_key = assignment.workflow_key | ||
| AND other.id <> assignment.id | ||
| AND other.enabled | ||
| AND other.provider_model_id = models.moss_id | ||
| ) THEN models.krea2_id | ||
| ELSE models.moss_id | ||
| END, | ||
|
iamwavecut marked this conversation as resolved.
Resolved
|
||
| inference_overrides = assignment.inference_overrides || jsonb_build_object( | ||
| 'vip_two_pictures_v1_previous_model_id', assignment.provider_model_id | ||
| ) | ||
| FROM vip_two_pictures AS models | ||
| WHERE assignment.provider_model_id = models.dev_id | ||
| AND assignment.role = 'fallback' | ||
| AND assignment.workflow_key LIKE 'image\_generation%' | ||
| AND assignment.workflow_key <> 'image_generation_fibo'; | ||
|
iamwavecut marked this conversation as resolved.
Resolved
|
||
|
|
||
| UPDATE workflow_assignments AS assignment | ||
| SET enabled = FALSE, | ||
| inference_overrides = assignment.inference_overrides || jsonb_build_object( | ||
| 'disabled_by_vip_two_pictures_v1', TRUE, | ||
| 'vip_two_pictures_v1_workflow_enabled', workflow.enabled | ||
| ) | ||
| FROM vip_two_pictures, workflows AS workflow | ||
| WHERE workflow.key = assignment.workflow_key | ||
| AND assignment.workflow_key = 'image_generation_fibo' | ||
| AND assignment.enabled; | ||
|
|
||
| UPDATE workflows | ||
| SET enabled = FALSE | ||
| WHERE key = 'image_generation_fibo' | ||
| AND enabled | ||
| AND EXISTS ( | ||
| SELECT 1 FROM workflow_assignments | ||
| WHERE workflow_key = 'image_generation_fibo' | ||
| AND (inference_overrides ->> 'vip_two_pictures_v1_workflow_enabled')::BOOLEAN | ||
| ); | ||
|
|
||
| UPDATE provider_models AS model | ||
| SET enabled = FALSE, | ||
| config = model.config || '{"disabled_by_vip_two_pictures_v1": true}'::jsonb | ||
| FROM vip_two_pictures AS models | ||
| WHERE model.id = models.dev_id | ||
| AND NOT EXISTS ( | ||
| SELECT 1 FROM workflow_assignments AS assignment | ||
| WHERE assignment.provider_model_id = model.id AND assignment.enabled | ||
| ); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.