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
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ async def get_root(request):
def get_embeddings(self):
embeddings = folder_paths.get_filename_list("embeddings")
return web.json_response(list(map(lambda a: os.path.splitext(a)[0], embeddings)))

@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


@routes.get("/models/{folder}")
async def get_models(request):
Expand Down