AugustDev / enchanted

Enchanted is iOS and macOS app for chatting with private self hosted language models such as Llama2, Mistral or Vicuna using Ollama.
Apache License 2.0
3.1k stars 187 forks source link

[open-webui] Compatibility workaround for `"HEAD /ollama/ HTTP/1.1" 405 Method Not Allowed` #64

Closed rsik closed 5 months ago

rsik commented 5 months ago

Bug Report

Original: https://github.com/open-webui/open-webui/issues/1375

Description

The Enchanted macos app is not seemingly compatible with open-webui, this is a workaround and maybe insight to a bug. I am not sure if this is the only app with this issue, but I wanted to take advantage of the easy auth with JWT. I serve multiple vlans and family members and servers, so this was a win for me; maybe it'll help someone.

I also have a non-typical set up because of a mac studio and docker cannot reach GPU on Apple Silicon. So this is the tldr setup:

User > Enchanted (or app) > router: HAProxy (multiple vlans) > caddy + open-webui/ollama docker > mac studio: caddy + ollama (* origins)

Despite the above, I have tried it directly to open-webui without HAProxy or base Caddyfile and error without workaround. This is the Caddyfile for caddy + open-webui/ollama docker part:

:443 {
    tls /etc/caddy/cert.pem /etc/caddy/key.pem

    # Rewrite / path HEAD requests to /ollama path HEAD requests
    @head {
        method HEAD
    }
    rewrite @head /ollama

    # Reverse proxy all other requests to the Docker container
    reverse_proxy open-webui:8080
}

I am not sure of the security implications of this yet, but wanted to note this finally worked after quite a bit of troubleshooting.

Bug Summary: Enchanted requests "GET /ollama/api/tags HTTP/1.1" and follows up with a HEAD /ollama request to the base ollama API url, in this case https://site.tld/ollama but greeted with "HEAD /ollama/ HTTP/1.1" 405 Method Not Allowed and Enchanted cannot "reach" the server.

Steps to Reproduce:

  1. Set Enchanted base Ollama URL and token to open-webui/ollama and the token
  2. docker compose logs and see error

Expected Behavior: Send request and "HEAD /ollama HTTP/1.1" 200 OK

Actual Behavior: Send request and "HEAD /ollama/ HTTP/1.1" 405 Method Not Allowed

Environment

Reproduction Details

Confirmation:

Logs and Screenshots

Screenshot 2024-04-01 at 1 42 56 AM

Installation Method

Docker + separate ollama API

Additional Information

See description.

rsik commented 5 months ago

dev branch works in https://github.com/open-webui/open-webui/issues/1375

arsaboo commented 4 months ago

@rsik can you please explain how you added Open WebUI to Enchanted? My Open WebUI is available on https://openai.mydomain.com. What is the endpoint you add in Enchanted and how do you authenticate?

acamacho-unige commented 3 months ago

Same problem

rsik commented 1 month ago

@rsik can you please explain how you added Open WebUI to Enchanted? My Open WebUI is available on https://openai.mydomain.com. What is the endpoint you add in Enchanted and how do you authenticate?

If your domain is https://openai.mydomain.com/ then your endpoint would be https://openai.mydomain.com/ollama and you would use your JWT token from your profile in open webui