ValidationError: 2 validation errors for DocArrayDoc returned when try to execute the RAG Search Example
Labels: name: area: vector store, name: auto:bug

### System Info

Langchain Version: 0.0.335
Platform: Win11
Python Version: 3.11.5

Hi experts,

I'm trying to execute the RAG Search Example on the Langchain Doc: https://python.langchain.com/docs/expression_language/get_started

**Here is the code:**
from langchain.chat_models import ChatOpenAI
from langchain.embeddings import OpenAIEmbeddings
from langchain.prompts import ChatPromptTemplate
from langchain.vectorstores import DocArrayInMemorySearch
from langchain.schema import StrOutputParser
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough

vectorstore = DocArrayInMemorySearch.from_texts(
    ["harrison worked at kensho", "bears like to eat honey"],
    embedding=OpenAIEmbeddings(),
)
retriever = vectorstore.as_retriever()

template = """Answer the question based only on the following context:
{context}

Question: {question}
"""
prompt = ChatPromptTemplate.from_template(template)
model = ChatOpenAI()
output_parser = StrOutputParser()

setup_and_retrieval = RunnableParallel(
    {"context": retriever, "question": RunnablePassthrough()}
)
chain = setup_and_retrieval | prompt | model | output_parser

chain.invoke("where did harrison work?")

**but the example fails with the ValidationError: 2 validation errors for DocArrayDoc.**
**Here is the error details:**
C:\Project\pythonProjectAI\.venv\Lib\site-packages\pydantic\_migration.py:283: UserWarning: `pydantic.error_wrappers:ValidationError` has been moved to `pydantic:ValidationError`.
  warnings.warn(f'`{import_path}` has been moved to `{new_location}`.')
Traceback (most recent call last):
  File "C:\Project\pythonProjectAI\AI.py", line 28, in <module>
    chain.invoke("where did harrison work?")
  File "C:\Project\pythonProjectAI\.venv\Lib\site-packages\langchain\schema\runnable\base.py", line 1427, in invoke
    input = step.invoke(
            ^^^^^^^^^^^^
  File "C:\Project\pythonProjectAI\.venv\Lib\site-packages\langchain\schema\runnable\base.py", line 1938, in invoke
    output = {key: future.result() for key, future in zip(steps, futures)}
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Project\pythonProjectAI\.venv\Lib\site-packages\langchain\schema\runnable\base.py", line 1938, in <dictcomp>
    output = {key: future.result() for key, future in zip(steps, futures)}
                   ^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Lib\concurrent\futures\_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Python\Lib\concurrent\futures\_base.py", line 401, in __get_result
    raise self._exception
  File "C:\Program Files\Python\Lib\concurrent\futures\thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Project\pythonProjectAI\.venv\Lib\site-packages\langchain\schema\retriever.py", line 112, in invoke
    return self.get_relevant_documents(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Project\pythonProjectAI\.venv\Lib\site-packages\langchain\schema\retriever.py", line 211, in get_relevant_documents
    raise e
  File "C:\Project\pythonProjectAI\.venv\Lib\site-packages\langchain\schema\retriever.py", line 204, in get_relevant_documents
    result = self._get_relevant_documents(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Project\pythonProjectAI\.venv\Lib\site-packages\langchain\schema\vectorstore.py", line 657, in _get_relevant_documents
    docs = self.vectorstore.similarity_search(query, **self.search_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Project\pythonProjectAI\.venv\Lib\site-packages\langchain\vectorstores\docarray\base.py", line 127, in similarity_search
    results = self.similarity_search_with_score(query, k=k, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Project\pythonProjectAI\.venv\Lib\site-packages\langchain\vectorstores\docarray\base.py", line 106, in similarity_search_with_score
    query_doc = self.doc_cls(embedding=query_embedding)  # type: ignore
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Project\pythonProjectAI\.venv\Lib\site-packages\pydantic\main.py", line 164, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 2 validation errors for DocArrayDoc
text
  Field required [type=missing, input_value={'embedding': [-0.0192381..., 0.010137099064823456]}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
metadata
  Field required [type=missing, input_value={'embedding': [-0.0192381..., 0.010137099064823456]}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing


### Who can help?

_No response_

### Information

- [X] The official example notebooks/scripts
- [ ] My own modified scripts

### Related Components

- [ ] LLMs/Chat Models
- [ ] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [ ] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async

### Reproduction

from langchain.chat_models import ChatOpenAI
from langchain.embeddings import OpenAIEmbeddings
from langchain.prompts import ChatPromptTemplate
from langchain.vectorstores import DocArrayInMemorySearch
from langchain.schema import StrOutputParser
from langchain.schema.runnable import RunnableParallel, RunnablePassthrough

vectorstore = DocArrayInMemorySearch.from_texts(
    ["harrison worked at kensho", "bears like to eat honey"],
    embedding=OpenAIEmbeddings(),
)
retriever = vectorstore.as_retriever()

template = """Answer the question based only on the following context:
{context}

Question: {question}
"""
prompt = ChatPromptTemplate.from_template(template)
model = ChatOpenAI()
output_parser = StrOutputParser()

setup_and_retrieval = RunnableParallel(
    {"context": retriever, "question": RunnablePassthrough()}
)
chain = setup_and_retrieval | prompt | model | output_parser

chain.invoke("where did harrison work?")

### Expected behavior

The example runs well.