andrewnguonly / Lumos

A RAG LLM co-pilot for browsing the web, powered by local LLMs
MIT License
1.39k stars 102 forks source link

On opening popup: API connectivity check tries DEFAULT_HOST each time #96

Closed moppman closed 8 months ago

moppman commented 8 months ago

Hi Andrew,

in the extension's console log, I'm seeing a Failed to load resource: net::ERR_CONNECTION_REFUSED error for the http://localhost:11434/api/tags route every time I open the Lumos popup. That's because my Ollama instance is running on another host in the network and not on localhost. I've set the correct host in the options menu, and Lumos is working as expected otherwise.

I think we're seeing some kind of data race originating from here: https://github.com/andrewnguonly/Lumos/blob/e34cf7cdca9a2d79dc61762a97d3cb0be53ee5ef/src/components/ChatBar.tsx#L274

My guess: when the popup opens, selectedHost is still set to DEFAULT_HOST because setSelectedHost hasn't updated it from localStorage yet.

This is on Lumos v1.0.7.

Thanks for your work on this cool extension!

andrewnguonly commented 8 months ago

Got it. I need to move the API check immediately after retrieving the host option from the local storage. The same needs to happen on the Options page as well. Thanks for bringing this up!

andrewnguonly commented 8 months ago

New information... Developers don't have control over emitted network error messages from Chome, but they can be hidden: https://stackoverflow.com/questions/4500741/suppress-chrome-failed-to-load-resource-messages-in-console

Either way, there are still some changes to be made to catch explicit errors originating from the extension.