Repository: ollama
Issue: Cannot get a model prefixed with a namespace from /v1/models/{model} endpoint
Labels: bug,api

### What is the issue?

My initial goal is to check if specific model is available using Ollama API.

I use OpenAI library `github.com/sashabaranov/go-openai` to do that.

The problem is when I try to get models which are not present in the main catalog and have an author prefix, I'm getting `404` and non-JSON response like if the routing is failing.

To eliminate the possibility of the library bug I tried to do the same with CURL.

The first thing I did is requests full list of models to be sure that the model is really in the list:

``` shell
curl http://localhost:11434/v1/models
```
which resulted in the following response:

```json
{"object":"list","data":[{"id":"T-lite-instruct-0.1.Q4_K_M.gguf:latest","object":"model","created":1730118522,"owned_by":"library"},{"id":"x/llama3.2-vision:11b-instruct-q8_0","object":"model","created":1729612391,"owned_by":"x"},{"id":"mannix/llama3.1-8b-lexi:q8_0","object":"model","created":1729272492,"owned_by":"mannix"},{"id":"llama3.2:3b-instruct-q4_K_M","object":"model","created":1727650425,"owned_by":"library"},{"id":"reader-lm:1.5b-q6_K","object":"model","created":1727092629,"owned_by":"library"},{"id":"qwen2:7b-instruct-q4_K_M","object":"model","created":1727092627,"owned_by":"library"},{"id":"phi3:14b-medium-4k-instruct-q4_K_M","object":"model","created":1727092620,"owned_by":"library"},{"id":"nuextract:3.8b-q4_K_M","object":"model","created":1727092619,"owned_by":"library"},{"id":"hermes3:8b-llama3.1-q6_K","object":"model","created":1727092618,"owned_by":"library"},{"id":"nomic-embed-text:latest","object":"model","created":1727092617,"owned_by":"library"},{"id":"nemotron-mini:4b-instruct-q4_K_M","object":"model","created":1727092615,"owned_by":"library"},{"id":"mxbai-embed-large:latest","object":"model","created":1727092614,"owned_by":"library"},{"id":"mistral-nemo:12b-instruct-2407-q4_K_M","object":"model","created":1727092613,"owned_by":"library"},{"id":"llama3.1:8b-instruct-q6_K","object":"model","created":1727092609,"owned_by":"library"},{"id":"gemma2:9b-instruct-q4_K_M","object":"model","created":1727092603,"owned_by":"library"},{"id":"gemma2:27b-instruct-q4_K_M","object":"model","created":1727092601,"owned_by":"library"},{"id":"deepseek-coder-v2:16b-lite-instruct-q4_K_M","object":"model","created":1727092600,"owned_by":"library"},{"id":"codellama:13b-instruct-q4_K_M","object":"model","created":1727092599,"owned_by":"library"},"id":"codegemma:latest","object":"model","created":1727092598,"owned_by":"library"},{"id":"phi3:3.8b-mini-instruct-4k-q4_K_M","object":"model","created":1713898146,"owned_by":"library"}]}
```

So here's the model I wanted to request: `{"id"
:"mannix/llama3.1-8b-lexi:q8_0","object":"model","created":1729272492,"owned_by":"mannix"}`

```shell
curl http://localhost:11434/v1/models/mannix/llama3.1-8b-lexi:q8_0
```
No luck:
```
404 page not found%
```

The problem is very obvious if you know how back-end works. It looks really like a routing problem.

The obvious solution for me was to encode the value to remove the `/` character from the URL:

```shell
curl http://localhost:11434/v1/models/mannix%2Fllama3.1-8b-lexi%3Aq8_0
```
I've got an error again:
```
404 page not found%
```

To ensure that I'm using correct endpoint, I've tried with another model:

```shell
curl http://localhost:11434/v1/models/qwen2:7b-instruct-q4_K_M
```
It worked:
```json
{"id":"qwen2:7b-instruct-q4_K_M","object":"model","created":1727092627,"owned_by":"library"}
```

When I request non-encoded model ID, Ollama logs show this:
```
ollama             | [GIN] 2024/11/06 - 15:59:11 | 404 |      13.715µs |      172.24.0.1 | GET      "/v1/models/mannix/llama3.1-8b-lexi:q8_0"
```

When I request encoded model ID, Ollama logs show this:
```
ollama             | [GIN] 2024/11/06 - 15:58:01 | 404 |      15.239µs |      172.24.0.1 | GET      "/v1/models/mannix/llama3.1-8b-lexi:q8_0"
```

Which is basically the same result, so I guess the reason of a failure may be in the fact that URL is being decoded before matching the route for some reason.

Most likely the same should be applicable for all previous Ollama versions and not only `0.4.0-rc6`

### OS

Docker

### GPU

AMD

### CPU

AMD

### Ollama version

0.4.0-rc6