ValueError: variable chat_history should be a list of base messages, got [HumanMessage(content='input message'), "output response"]
Labels: name: area: memory, name: auto:bug

### System Info

google-cloud-aiplatform==1.35.0,
langchain-0.0.354

### Who can help?

_No response_

### Information

- [ ] The official example notebooks/scripts
- [X] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [ ] Vector Stores / Retrievers
- [X] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [X] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

```python
class ChatbotHistory:
    def __init__(self, max_size=5):
        self.buffer = deque(maxlen=max_size)

    def add_interaction(self, user_message, bot_response):
        # Assuming HumanMessage is a class that stores a message content
        self.buffer.append(HumanMessage(content=user_message))
        self.buffer.append(bot_response)

    def get_history(self):
        return list(self.buffer)

    def get_history_as_string(self):
        history_string = ""
        for message in self.buffer:
            if isinstance(message, HumanMessage):
                history_string += f"User: {message.content}\n"
            else:  # Assuming bot responses are strings
                history_string += f"Bot: {message}\n"
        return history_string.strip()

    def clear_history(self):
        self.buffer.clear()

def format_docs(docs):
    return "\n\n".join(doc.page_content for doc in docs)


def contextualized_question(input: dict):
    llm = VertexAI(model_name='text-bison@001', max_output_tokens=512, temperature=0.2)
    contextualize_q_system_prompt = """Given a chat history and the latest user question \
    which might reference context in the chat history, formulate a standalone question \
    which can be understood without the chat history. Do NOT answer the question, \
    just reformulate it if needed and otherwise return it as is."""
    contextualize_q_prompt = ChatPromptTemplate.from_messages(
        [
            ("system", contextualize_q_system_prompt),
            MessagesPlaceholder(variable_name="chat_history"),
            ("human", "{question}"),
        ]
    )
    contextualize_q_chain = contextualize_q_prompt | llm | StrOutputParser()

    if input.get("chat_history"):
        return contextualize_q_chain
    else:
        return input["question"]


if not message:
        message = request.form.get('userInput')
    template = """
        CONTEXT: {context}
        Question: {question}
        Helpful Answer:

        **Resource:** [reference source name]
    """
    # rag_prompt_custom = PromptTemplate.from_template(template)
    
    qa_prompt = ChatPromptTemplate.from_messages(
    [
        ("system", template),
        MessagesPlaceholder(variable_name="chat_history"),
        ("human", "{question}"),
    ]
    )
    
    rag_chain = (
        RunnablePassthrough.assign(
            context=contextualized_question | temp_retriever | format_docs
        )
        | qa_prompt
        | llm
    )
    
    response = rag_chain.invoke({"question": message, "chat_history": memory.get_history()})
    memory.add_interaction(message, response)
```

### Expected behavior

I expected to have string or json format output response as an output of invoke(),
but it showed me an error saying,

```
ValueError: variable chat_history should be a list of base messages, got [HumanMessage(content='input message'), "output response"]
```