Skip to content
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

Add route to list model types #4846

Merged

Conversation

ImDarkTom
Copy link
Contributor

@ImDarkTom ImDarkTom commented Sep 8, 2024

Adds a route to list all valid model types as a JSON list.

This will benefit those working with the api as it will allow for an easy way to list model types.

I have seen people in the past request a feature like this ( such as #830 ) and this adds it in a safe and simple way.

server.py Outdated

@routes.get("/models")
def list_model_types(request):
return web.json_response(list(folder_paths.folder_names_and_paths))
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably only need to grab the keys here? the values are local system paths which shouldn't be sent over network api

Copy link
Collaborator

Choose a reason for hiding this comment

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

The endpoint should be something like GET /models/paths or GET /models/folders.
Since it is only returning the types of models or available folders.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably only need to grab the keys here? the values are local system paths which shouldn't be sent over network api

Using list() does only grab the keys, I might need to clarify that in code.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The endpoint should be something like GET /models/paths or GET /models/folders. Since it is only returning the types of models or available folders.

Wouldn't that interfere with if someone were to have an extra model path named either one of those? Probably unlikely but I think it would be better if there wasn't a chance for route conflict.

I can change the route if needed its just that setting it to /models seemed the most logical.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes that format would be a conflict. It works as /models, if a different name is needed it'd have to be eg /model_folders or something

@mcmonkey4eva mcmonkey4eva added User Support A user needs help with something, probably not a bug. Feature A new feature to add to ComfyUI. Good PR This PR looks good to go, it needs comfy's final review. and removed User Support A user needs help with something, probably not a bug. labels Sep 12, 2024
@comfyanonymous comfyanonymous merged commit 7183fd1 into comfyanonymous:master Sep 17, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A new feature to add to ComfyUI. Good PR This PR looks good to go, it needs comfy's final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants