Repository: ollama
Issue: mixtral:8x22b model does not work with system prompt only
Labels: bug

### What is the issue?

The `mixtral:8x22b-instruct` model does not work correctly when only the system prompt is provided. In such cases, an empty prompt is sent, leading to irrelevant output.

This behavior may be related to the internal handling of prompts or recent changes made in the system prompt handling, as referenced in #4228.

mixtral:8x22b-instruct template: https://ollama.com/library/mixtral:8x22b-instruct/blobs/138b3322e0da
Mixtral 8x22B template in docs: https://github.com/ollama/ollama/blob/main/docs/template.md#mistral

#### Steps to Reproduce

1. Input the following system prompt only into the `mixtral:8x22b-instruct` model.
    ```bash
    curl http://localhost:11434/api/chat -d '{
        "model": "mixtral:8x22b-instruct-v0.1-q4_K_M",
        "stream": false,
        "messages": [
            {
                "role": "system",
                "content": "Hello, I am Ollama. I am here to help you with your questions. What would you like to know?\n\nWhat is the capital of Japan?"
            }
        ]
      }'
    ```
2. The Ollama log shows that the `prompt` field is empty.
   `prompt=\"\"\r\n`
    ```bash
    {"log":"time=2024-10-04T08:03:17.462Z level=DEBUG source=routes.go:1417 msg=\"chat request\" images=0 prompt=\"\"\r\n","stream":"stdout","time":"2024-10-04T08:03:17.462471779Z"}
    ```
4. The output is unrelated to the input content.
    ```bash
    {"model":"mixtral:8x22b-instruct-v0.1-q4_K_M","created_at":"2024-10-04T08:03:40.224484198Z","message":{"role":"assistant","content":",\n.\nA new study by the University of Maryland and Johns Hopkins Medicine has found ..."}
    ```

#### Expected Behavior
The `mixtral:8x22b-instruct` model should work with system prompt only, similar to other models like `gemma2:27b`.


#### Actual Results

mixtral:8x22b-instruct, system prompt only: NG
<details><summary>Results</summary>
<p>

input:
```bash
curl http://localhost:11434/api/chat -d '{
    "model": "mixtral:8x22b-instruct-v0.1-q4_K_M",
    "stream": false,
    "messages": [
        {
            "role": "system",
            "content": "Hello, I am Ollama. I am here to help you with your questions. What would you like to know?\n\nWhat is the capital of Japan?"
        }
    ]
}'
```

Ollama log:  
```bash
{"log":"time=2024-10-04T08:03:17.462Z level=DEBUG source=routes.go:1417 msg=\"chat request\" images=0 prompt=\"\"\r\n","stream":"stdout","time":"2024-10-04T08:03:17.462471779Z"}
```

Output:  
```bash
{"model":"mixtral:8x22b-instruct-v0.1-q4_K_M","created_at":"2024-10-04T08:03:40.224484198Z","message":{"role":"assistant","content":",\n.\nA new study by the University of Maryland and Johns Hopkins Medicine has found ..."}
```

This result is not related to the input.

</p>
</details> 

mixtral:8x22b-instruct, system prompt + user prompt: OK

<details><summary>Results</summary>
<p>

Input
```bash
curl http://localhost:11434/api/chat -d '{
    "model": "mixtral:8x22b-instruct-v0.1-q4_K_M",
    "stream": false,
    "messages": [
        {
            "role": "system",
            "content": "Hello, I am Ollama. I am here to help you with your questions. What would you like to know?"
        },
        {
            "role": "user",
            "content": "What is the capital of Japan?"
        }
    ]
}'
```

Ollama log:  
```bash
{"log":"time=2024-10-04T08:08:04.464Z level=DEBUG source=routes.go:1417 msg=\"chat request\" images=0 prompt=\"
 Hello, I am Ollama. I am here to help you with your questions. What would you like to know?\\n\\nWhat is the capital of Japan?
\"\r\n","stream":"stdout","time":"2024-10-04T08:08:04.464656724Z"}
```

Output:  
```bash
{"model":"mixtral:8x22b-instruct-v0.1-q4_K_M","created_at":"2024-10-04T08:08:06.219305367Z","message":{"role":"assistant","content":" The capital of Japan is Tokyo. It's also the country's largest city and one of the world's most populous metropolitan areas."},"done_reason":"stop","done":true,"total_duration":1853131385,"load_duration":11283091,"prompt_eval_count":38,"prompt_eval_duration":348092000,"eval_count":32,"eval_duration":1361906000}
```
</p>
</details> 

Other model example `gemma2:27b`, system prompt only: OK
<details><summary>Results</summary>
<p>

Input
```bash
curl http://localhost:11434/api/chat -d '{
    "model": "gemma2:27b-instruct-q4_K_M",
    "stream": false,
    "messages": [
        {
            "role": "system",
            "content": "Hello, I am Ollama. I am here to help you with your questions. What would you like to know?\n\nWhat is the capital of Japan?"
        }
    ]
}'
```

Ollama log:  
```bash
{"log":"time=2024-10-04T08:12:01.403Z level=DEBUG source=routes.go:1417 msg=\"chat request\" images=0 prompt=\"\u003cstart_of_turn\u003euser\\nHello, I am Ollama. I am here to help you with your questions. What would you like to know?\\n\\nWhat is the capital of Japan? \u003cend_of_turn\u003e\\n\u003cstart_of_turn\u003emodel\\n\"\r\n","stream":"stdout","time":"2024-10-04T08:12:01.40376108Z"}
```

Output:  
```bash
{"model":"gemma2:27b-instruct-q4_K_M","created_at":"2024-10-04T08:10:22.460284079Z","message":{"role":"assistant","content":"The capital of Japan is **Tokyo**. 🏯  \n"},"done_reason":"stop","done":true,"total_duration":6504495197,"load_duration":6057933332,"prompt_eval_count":42,"prompt_eval_duration":66685000,"eval_count":13,"eval_duration":376322000}
```
</p>
</details> 

#### Potentially Related Issues

- https://github.com/ollama/ollama/issues/5547
- https://github.com/ollama/ollama/issues/6176

### OS

Linux

### GPU

Nvidia

### CPU

Intel

### Ollama version

0.3.12