n4ze3m / page-assist

Use your locally running AI models to assist you in your web browsing
https://chromewebstore.google.com/detail/page-assist-a-web-ui-for/jfgfiigpkhlkbnfnbobbkinehhfdhndo
MIT License
1.58k stars 150 forks source link

Error handling custom Ollama URLs with subpath ending with / #229

Open PierreMesure opened 3 weeks ago

PierreMesure commented 3 weeks ago

Hi,

Thank you so much for such a user-friendly extension, I just discovered it and I had to play a bit with the settings to get it to work with my Ollama instance. It isn't available at localhost:11434, I have it at a custom URL and custom path: https://xxx/ollama_api/.

I use Caddy to map the subpath to Ollama and I have other services running at https://xxx so querying https://xxx/ollama_api will return a 404. Querying https://xxx/ollama_api/ returns Ollama is running.

Now this configuration seems to mess a little bit with your extension as it tries to remove the / at the end. I can see my models in the list (because the extension successfully queries https://xxx/ollama_api/api/tags) but I still have an error message in the middle of the window because that central panel tries to query https://xxx/ollama_api.

image

My guess it that the culprit is this function. I understand the need for it but maybe it could be made a little smarter? Like testing the URL first with the "/" and removing it only if the address doesn't work? 😊

PierreMesure commented 3 weeks ago

I just tried to use http://esvaiws01.esv.local:8081/ollama_api///////// and it now works! 😁

image

n4ze3m commented 3 weeks ago

Oh no, I trimmed the ending slash because the Ollama API causes issues if the user adds it! 😊 Glad you found a solution—is it working? This is a great find for others with a similar issue.

PierreMesure commented 3 weeks ago

Yes, adding lots of //// works great but I think it could be good to test before trimming. Another option could be to trim only if there is no subpath in address. That would continue to solve headaches for most using Ollams locally with default address (localhost:11434) and people with a subpath are hopefully a bit more aware of their exact settings.

n4ze3m commented 3 weeks ago

I'll add a setting where you can disable this :) in an upcoming version

PierreMesure commented 3 weeks ago

Another option could be to trim only if there is no subpath in address.

I submitted a PR that does just that.