exo icon indicating copy to clipboard operation
exo copied to clipboard

Show downloaded models, improve error handling, ability to delete models, side bar with more detail, button to go back to chat history

Open cadenmackenzie opened this issue 1 year ago • 30 comments

I wanted a way to show which models have already been downloaded. Ultimately, I would like to add the ability to manage those models such as deleting them. Might make more sense in a sidebar where you chose the model and can manage it.

I also added more robust handling of errors in index.html to safely access them as I saw some warnings in the main branch when no errors were set.

In index.js I combined error handling into a single flow for the populateSelector method using response.json() instead of manually parsing. I also added a helper method to set the error to reduce duplicate code. Something I should have done with my last PR.

Open to suggestions on these changes.

cadenmackenzie avatar Nov 13 '24 23:11 cadenmackenzie

I am seeing now some of the robust error handling was intentional and merged in here. I can change back if that is preferred.

cadenmackenzie avatar Nov 13 '24 23:11 cadenmackenzie

+1 on the concept, but this is an issue:

image

dtnewman avatar Nov 14 '24 02:11 dtnewman

+1 on the concept, but this is an issue:

image

Oh wait, that's in Safari. It actually works on Chrome and Firefox. Still, should probably fix before merge.

image

dtnewman avatar Nov 14 '24 02:11 dtnewman

+1 on the concept, but this is an issue: image

Oh wait, that's in Safari. It actually works on Chrome and Firefox. Still, should probably fix before merge.

image

I fixed these issue in https://github.com/cadenmackenzie/exo/pull/1/files which you can merge into this PR

dtnewman avatar Nov 14 '24 02:11 dtnewman

Thanks for finding that! I went ahead and merged it in.

cadenmackenzie avatar Nov 14 '24 02:11 cadenmackenzie

Awesome!

Got it working with the suggested changes. Want to do some testing in the morning then will update this PR.

cadenmackenzie avatar Nov 14 '24 06:11 cadenmackenzie

Added new abstract method in ShardDownloader, implemented get_shard_download_status in HFShardDownloader leaning on get_local_snapshot_dir, get_weight_map, get_allow_patterns helper functions and then checks the percentage of model downloaded for models where local files are found. Removed old function for checking percentage.

Currently shows "downloaded" for fully downloaded models and "X% downloaded" for models not fully downloaded in dropdown.

I don't love how this is being refreshed using the modelPoolInterval because it lags a little for models that are actively being downloaded so might work on how to improve that.

I think it could be worth moving this logic as well as active downloads to a sidebar. I like how active downloads are being shown in the chat when initiated but if we moved that to a sidebar, it could be a centralized place to view all models, choose a model, see activity of downloaded models, and being able to remove local downloads to free up space. Similar to how you can remove local models in LM Studio.

Open to suggestions.

cadenmackenzie avatar Nov 14 '24 20:11 cadenmackenzie

Found an issue in handle_model_support that was creating HFShardDownloader without quick_check=true so it was starting download of models when being checked for download percentage.

Will work on get_shard_download_status refactor

cadenmackenzie avatar Nov 17 '24 00:11 cadenmackenzie

Hi @AlexCheema can you give me some more insight into what you want to be refactored? I initially thought we could reuse some of the download percentage logic that is happening during download but as far as I can tell, that is only checking against the remote during download in download_file(). Would you want to pull some of that logic out into another helper function to use in get_shard_download_status() or am I missing something?

cadenmackenzie avatar Nov 17 '24 20:11 cadenmackenzie

Hi @AlexCheema can you give me some more insight into what you want to be refactored? I initially thought we could reuse some of the download percentage logic that is happening during download but as far as I can tell, that is only checking against the remote during download in download_file(). Would you want to pull some of that logic out into another helper function to use in get_shard_download_status() or am I missing something?

Yeah I think pulling some of that logic out would make sense. I think it's in general in need of a good refactor if you want to take a go at that and will bump up the bounty to $300.

AlexCheema avatar Nov 18 '24 17:11 AlexCheema

Hi Alex, please review. I didn't modify download_file much but added a check using the new helper method.

Modified the get_shard_download_status to lean on the helper methods to calculate the overall percentage of files and return that. Also updated chatgpt_api to use that overall instead doing percent calculation there. Should fix the pattern matching issue that you identified as well.

cadenmackenzie avatar Nov 18 '24 23:11 cadenmackenzie

@AlexCheema pinging for your review

cadenmackenzie avatar Nov 20 '24 18:11 cadenmackenzie

Please resolve conflicts and ping me again. @cadenmackenzie

AlexCheema avatar Nov 21 '24 13:11 AlexCheema

@AlexCheema resolved

cadenmackenzie avatar Nov 21 '24 15:11 cadenmackenzie

Did you test this after the merge? Models aren't loading and getting syntax errors.

Screenshot 2024-11-22 at 19 28 48

AlexCheema avatar Nov 22 '24 15:11 AlexCheema

Please assign me when fixed and ready for me to review @cadenmackenzie

AlexCheema avatar Nov 22 '24 15:11 AlexCheema

Hi @AlexCheema , my apologies. I did test it and it was working for me even without the inference_engine_classes defined. Not sure why.

I fixed it and installed Pylance.

cadenmackenzie avatar Nov 22 '24 16:11 cadenmackenzie

/modelpool is hanging for me. nothing shows up in the tinychat ui

AlexCheema avatar Nov 22 '24 17:11 AlexCheema

@AlexCheema merged in side bar changes and delete functionality and added functionality to use server sent events to show each model as its checked. Also shows loading icon in side bar until the first model is loaded. Quick demo

cadenmackenzie avatar Nov 24 '24 02:11 cadenmackenzie

When I delete a model, the following error appears: An unknown error occurred It does actually delete the model however tinychat shows this error.

AlexCheema avatar Nov 27 '24 06:11 AlexCheema

Trying to reproduce that error but I can't seem it do it. Can you send me your steps? What line is that error being thrown on?

cadenmackenzie avatar Nov 27 '24 19:11 cadenmackenzie

Okay, I can't reproduce now either so that's fine.

One more thing: could you add something that indicates whether a download is currently in progress? Sometimes a download could fail and you don't realise it or it could be in progress but got stuck. An indication of whether exo is actively trying to download a shard would be super helpful for debugging. @cadenmackenzie

AlexCheema avatar Nov 29 '24 07:11 AlexCheema

@AlexCheema I added a spinner animation to the model in the sidebar that is actively being downloaded. I can modify that to make it a progress bar or say "Downloading" if that is better. Demo here. Is that what you were envisioning?

Merge conflicts from main branch resolved.

cadenmackenzie avatar Nov 29 '24 16:11 cadenmackenzie

@AlexCheema I added a spinner animation to the model in the sidebar that is actively being downloaded. I can modify that to make it a progress bar or say "Downloading" if that is better. Demo here. Is that what you were envisioning?

Merge conflicts from main branch resolved.

I noticed this is being done from the frontend right now. Is there any way to use the backend as the source of truth to check if a model download is in progress instead? This will be incredibly useful for debugging e.g. if I'm using the API and I want to check what model downloads are in progress.

AlexCheema avatar Nov 30 '24 06:11 AlexCheema

@AlexCheema right now the frontend is matching what is being returned by /v1/download/progress and /modelpool to determine if a model download is in progress on the sidebar. do we want to try to combine some of that logic into one endpoint? Or add a check to /modelpool to return true or false if the model is being downloaded. /v1/download/progress is the current source of truth for checking if a download is in progress and polls every second when a download is in progress.

cadenmackenzie avatar Nov 30 '24 18:11 cadenmackenzie

@AlexCheema right now the frontend is matching what is being returned by /v1/download/progress and /modelpool to determine if a model download is in progress on the sidebar. do we want to try to combine some of that logic into one endpoint? Or add a check to /modelpool to return true or false if the model is being downloaded. /v1/download/progress is the current source of truth for checking if a download is in progress and polls every second when a download is in progress.

That works! I just wanted to make sure the source of truth for this was the server, not the frontend.

AlexCheema avatar Dec 02 '24 07:12 AlexCheema

can you clarify what you mean? Do you want the logic to be combined into one endpoint or are you okay that the server is the source of truth using the two endpoints and the matching of results on the frontend as it is right now? @AlexCheema

cadenmackenzie avatar Dec 02 '24 15:12 cadenmackenzie

can you clarify what you mean? Do you want the logic to be combined into one endpoint or are you okay that the server is the source of truth using the two endpoints and the matching of results on the frontend as it is right now? @AlexCheema

Unifying into one endpoint would be better.

I also added an endpoint to trigger a download here: https://github.com/exo-explore/exo/pull/526 It would be great if that could be triggered from the UI.

AlexCheema avatar Dec 03 '24 07:12 AlexCheema

@AlexCheema I got a working version of the endpoints combined but I have some concerns. If the endpoints are combined, the updates for the Download Progress Section rely on a response from /modelpool which is called every 5 seconds and checks the status of every model. Ultimately these feel like processes that should be kept in their own endpoints because /modelpool is checking each local model against the remote whereas /download/progress is using the node.node_download_progress during a download. If anything I think we could use the responses from /download/progress to update the sidebar for the model being downloaded so it is more real-time. Let me know if I am missing something as to why you would want these combined into one endpoint.

cadenmackenzie avatar Dec 04 '24 00:12 cadenmackenzie

Also added the trigger to start a download for partially downloaded or not downloaded models using the download endpoint. Demo here. @AlexCheema

cadenmackenzie avatar Dec 04 '24 00:12 cadenmackenzie