Improper chat_template when using Ollama
Labels: name: auto:bug, name: area: models

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Example Code

I have noticed that the prompt produced by LangChain when using ```ChatOllama(model='mixtral')``` was not in the proper format. 

This can be replicated using the following:

```
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "mistralai/Mixtral-8x7B-v0.1"
tokenizer = AutoTokenizer.from_pretrained(model_id)

##messages example
messages = [
    {"role": "system", "content": "You are a chef"},
    {"role": "user", "content": "What is your favourite condiment?"},
    {"role": "assistant", "content": "Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!"},
    {"role": "user", "content": "Do you have mayonnaise recipes?"}
]

##converting messages example to LC format
messages_lc = [(m['role'],m['content']) for m in messages]

```

For the proper format:

```
tokenizer.apply_chat_template(messages,tokenize=False)
```
This would produce:
```
"

 
\nYou are a chef\n
\n\nWhat is your favourite condiment? 
 Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen! 


 Do you have mayonnaise recipes? 
"
```

Where as the LangChain format:

```
from langchain_community.chat_models import ChatOllama
from langchain.prompts import ChatPromptTemplate

chat = ChatOllama(model='mixtral')
chat_resp = (ChatPromptTemplate.from_messages(messages_lc) | chat_tmp ).invoke({},{'callbacks': [ConsoleCallbackHandler()]})
```
I then copied the tokens sent to the LLM (using the ConsoleCallbackHandler) into ```tokens```  and decoded them:

```
tokenizer.decode(tokens)
```
To receive this:
```
" 
  
 You are a chef 
\n
 What is your favourite condiment? 
\nWell, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!\n
 Do you have mayonnaise recipes? 
 

```



### Description

I'm trying to use LangChain with ChatOllama.

Output tokens decoded were:
 ```
" 
  
 You are a chef 
\n
 What is your favourite condiment? 
\nWell, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!\n
 Do you have mayonnaise recipes? 
 

```
Where the proper format is:
```
"

 
\nYou are a chef\n
\n\nWhat is your favourite condiment? 
 Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen! 


 Do you have mayonnaise recipes? 
"
```

### System Info

langchain==0.0.350
langchain-community==0.0.3
langchain-core==0.1.0

Python 3.11.4

MacOS Sonoma

### Related Components

- [X] LLMs/Chat Models
- [ ] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [X] Callbacks/Tracing
- [ ] Async