Skip to content

feat(ui): model relationship management #7963

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xiaden
Copy link

@xiaden xiaden commented Apr 27, 2025

Adds full support for managing model-to-model relationships in the UI and backend.

Introduces RelatedModels subpanel for linking and unlinking models in model management.

  • Adds REST API routes for adding, removing, and retrieving model relationships.
  • New database migration: creates model_relationships table for bidirectional links.
  • New service layer (model_relationships) for relationship management.
  • Updated frontend: Related models float to top of LoRA/Main grouped model comboboxes for quick access.
    • Added 'Show Only Related' toggle badge to MainModelPicker filter bar

Summary

Introduces a full system for managing model-to-model relationships.
New database migration: model_relationships table (bidirectional, FK constrained, cascade deletes, sorted input).
New service layer: model_relationships for API interaction.
New UI subpanel (RelatedModels) for linking/unlinking models in the Model Manager.
UI on frontend linked to relationships, pulling either to the top, or allowing filters.
Rebased due to snazzy new model selector that happened this week.

image
image
image
image
image
image
image


Notes

  • Linking currently allows connecting any models with matching base_model types (or any model with the base type any ) in the UI.
  • API has no frontend constraints on linking — assumes trusted input.
  • API prevents duplicates automatically.
  • May want a virtual field (related_model_ids) on models for optimized frontend access (instead of extra API calls).
    First PR, Please be gentle.

Related Issues / Discussions

Part of 7894 used_with tag support.


QA Instructions

Ran Lint, Prettier, pnpm test, Made sure UI and API routes functioned with DB open to watch.


Merge Plan

Unless a migration happens between now and PR, Rebase if needed and repush? Honestly not completely sure what's needed here, but more than willing to work for whatever is needed.


Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

@github-actions github-actions bot added api python PRs that change python files services PRs that change app services frontend PRs that change frontend files labels Apr 27, 2025
Copy link
Collaborator

@psychedelicious psychedelicious left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking great, thank you! I've added some minor comments.

There will be some conflicts while rebasing bc I've updated the new model picker again. It will be a bit trickier to add the related models toggle to it.

Fortunately, because we are not allowing users to relate two main models, it's OK to omit the related toggle. In the future when we extend the new picker to other model types (e.g. LoRAs), we will figure out how to integrate related models.

For now, please drop the changes to the new model picker.

You can delete ParamMainModelSelect.tsx, this file is no longer needed.

PS: I apologize for the delay in getting to review this!

@xiaden xiaden force-pushed the feat(ui)-model-relationship-management branch from 9631e4a to f8c63c1 Compare May 6, 2025 04:57
xiaden added 3 commits May 6, 2025 16:12
Adds full support for managing model-to-model relationships in the UI and backend.

Introduces RelatedModels subpanel for linking and unlinking models in model management.
 - Adds REST API routes for adding, removing, and retrieving model relationships.
 - New database migration: creates model_relationships table for bidirectional links.
 - New service layer (model_relationships) for relationship management.
 - Updated frontend: Related models float to top of LoRA/Main grouped model comboboxes for quick access.
     - Added 'Show Only Related' toggle badge to MainModelPicker filter bar

**Amended commit to remove changes to ParamMainModelSelect.tsx and MainModelPicker.tsx to avoid conflict with upstream deletion/ rewrite**
removed unused AnyModelConfig related methods,
removed unused get_related_model_key_count method.
Major cleanup of RelatedModels.tsx for improved readability, structure, and maintainability.
Dried out repetitive logic
Consolidated model type sorting into reusable helpers
Added disallowed model type relationships to prevent broken connections (e.g. VAE ↔ LoRA)
- Aware this introduces a new constraint—open to feedback (see PR comment)
Some naming and types may still need refinement; happy to revisit
@xiaden xiaden force-pushed the feat(ui)-model-relationship-management branch from f8c63c1 to 3dc2e71 Compare May 6, 2025 06:55
@xiaden
Copy link
Author

xiaden commented May 6, 2025

For the sake of a clean commit history, I reset and amended the PR commit to remove changes to ParamMainModelSelect.tsx and MainModelPicker.tsx. These files were either deleted or reworked upstream, so this avoids unnecessary conflicts.

I opted not to cherry-pick the deletion or do rebase acrobatics until the PR is approved, to keep things easier to track and adjust if needed.

Note: Some previous comments may now refer to code that no longer exists in the diff—feel free to flag anything still relevant, and I’ll handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api frontend PRs that change frontend files python PRs that change python files services PRs that change app services
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants