DOC: Quickstart Code Fails for Retrieval Chain
Labels: name: area: vector store, name: auto:bug

### Issue with current documentation:

Hi.

I am a newcomer to Langchain following the Quickstart tutorial in a Jupyter Notebook, using the setup recommended by the installation guide. I am following the OpenAI tutorial, rather than the local LLM version.

I followed the exact code in the docs by pasting the cells into my notebook. All code works perfectly without a single error or warning. However, the code fails at this point:
```python
response = retrieval_chain.invoke({"input": "how can langsmith help with testing?"})
print(response["answer"])

# LangSmith offers several features that can help with testing:...
```

When I attempt to run this code, I get the following output in my notebook:
```
{
	"name": "ValidationError",
	"message": "2 validation errors for DocArrayDoc
text
  Field required [type=missing, input_value={'embedding': [-0.0144587... -0.015377209573652503]}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
metadata
  Field required [type=missing, input_value={'embedding': [-0.0144587... -0.015377209573652503]}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing",
	"stack": "---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
Cell In[18], line 1
----> 1 response = retrieval_chain.invoke({\"input\": \"how can langsmith help with testing?\"})
      2 print(response[\"answer\"])
      4 # LangSmith offers several features that can help with testing:...

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\runnables\\base.py:3590, in RunnableBindingBase.invoke(self, input, config, **kwargs)
   3584 def invoke(
   3585     self,
   3586     input: Input,
   3587     config: Optional[RunnableConfig] = None,
   3588     **kwargs: Optional[Any],
   3589 ) -> Output:
-> 3590     return self.bound.invoke(
   3591         input,
   3592         self._merge_configs(config),
   3593         **{**self.kwargs, **kwargs},
   3594     )

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\runnables\\base.py:1762, in RunnableSequence.invoke(self, input, config)
   1760 try:
   1761     for i, step in enumerate(self.steps):
-> 1762         input = step.invoke(
   1763             input,
   1764             # mark each step as a child run
   1765             patch_config(
   1766                 config, callbacks=run_manager.get_child(f\"seq:step:{i+1}\")
   1767             ),
   1768         )
   1769 # finish the root run
   1770 except BaseException as e:

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\runnables\\passthrough.py:415, in RunnableAssign.invoke(self, input, config, **kwargs)
    409 def invoke(
    410     self,
    411     input: Dict[str, Any],
    412     config: Optional[RunnableConfig] = None,
    413     **kwargs: Any,
    414 ) -> Dict[str, Any]:
--> 415     return self._call_with_config(self._invoke, input, config, **kwargs)

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\runnables\\base.py:975, in Runnable._call_with_config(self, func, input, config, run_type, **kwargs)
    971     context = copy_context()
    972     context.run(var_child_runnable_config.set, child_config)
    973     output = cast(
    974         Output,
--> 975         context.run(
    976             call_func_with_variable_args,
    977             func,  # type: ignore[arg-type]
    978             input,  # type: ignore[arg-type]
    979             config,
    980             run_manager,
    981             **kwargs,
    982         ),
    983     )
    984 except BaseException as e:
    985     run_manager.on_chain_error(e)

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\runnables\\config.py:323, in call_func_with_variable_args(func, input, config, run_manager, **kwargs)
    321 if run_manager is not None and accepts_run_manager(func):
    322     kwargs[\"run_manager\"] = run_manager
--> 323 return func(input, **kwargs)

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\runnables\\passthrough.py:402, in RunnableAssign._invoke(self, input, run_manager, config, **kwargs)
    389 def _invoke(
    390     self,
    391     input: Dict[str, Any],
   (...)
    394     **kwargs: Any,
    395 ) -> Dict[str, Any]:
    396     assert isinstance(
    397         input, dict
    398     ), \"The input to RunnablePassthrough.assign() must be a dict.\"
    400     return {
    401         **input,
--> 402         **self.mapper.invoke(
    403             input,
    404             patch_config(config, callbacks=run_manager.get_child()),
    405             **kwargs,
    406         ),
    407     }

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\runnables\\base.py:2327, in RunnableParallel.invoke(self, input, config)
   2314     with get_executor_for_config(config) as executor:
   2315         futures = [
   2316             executor.submit(
   2317                 step.invoke,
   (...)
   2325             for key, step in steps.items()
   2326         ]
-> 2327         output = {key: future.result() for key, future in zip(steps, futures)}
   2328 # finish the root run
   2329 except BaseException as e:

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\runnables\\base.py:2327, in <dictcomp>(.0)
   2314     with get_executor_for_config(config) as executor:
   2315         futures = [
   2316             executor.submit(
   2317                 step.invoke,
   (...)
   2325             for key, step in steps.items()
   2326         ]
-> 2327         output = {key: future.result() for key, future in zip(steps, futures)}
   2328 # finish the root run
   2329 except BaseException as e:

File C:\\ProgramData\\miniconda3\\Lib\\concurrent\\futures\\_base.py:456, in Future.result(self, timeout)
    454     raise CancelledError()
    455 elif self._state == FINISHED:
--> 456     return self.__get_result()
    457 else:
    458     raise TimeoutError()

File C:\\ProgramData\\miniconda3\\Lib\\concurrent\\futures\\_base.py:401, in Future.__get_result(self)
    399 if self._exception:
    400     try:
--> 401         raise self._exception
    402     finally:
    403         # Break a reference cycle with the exception in self._exception
    404         self = None

File C:\\ProgramData\\miniconda3\\Lib\\concurrent\\futures\\thread.py:58, in _WorkItem.run(self)
     55     return
     57 try:
---> 58     result = self.fn(*self.args, **self.kwargs)
     59 except BaseException as exc:
     60     self.future.set_exception(exc)

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\runnables\\base.py:3590, in RunnableBindingBase.invoke(self, input, config, **kwargs)
   3584 def invoke(
   3585     self,
   3586     input: Input,
   3587     config: Optional[RunnableConfig] = None,
   3588     **kwargs: Optional[Any],
   3589 ) -> Output:
-> 3590     return self.bound.invoke(
   3591         input,
   3592         self._merge_configs(config),
   3593         **{**self.kwargs, **kwargs},
   3594     )

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\runnables\\base.py:1762, in RunnableSequence.invoke(self, input, config)
   1760 try:
   1761     for i, step in enumerate(self.steps):
-> 1762         input = step.invoke(
   1763             input,
   1764             # mark each step as a child run
   1765             patch_config(
   1766                 config, callbacks=run_manager.get_child(f\"seq:step:{i+1}\")
   1767             ),
   1768         )
   1769 # finish the root run
   1770 except BaseException as e:

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\retrievers.py:121, in BaseRetriever.invoke(self, input, config)
    117 def invoke(
    118     self, input: str, config: Optional[RunnableConfig] = None
    119 ) -> List[Document]:
    120     config = ensure_config(config)
--> 121     return self.get_relevant_documents(
    122         input,
    123         callbacks=config.get(\"callbacks\"),
    124         tags=config.get(\"tags\"),
    125         metadata=config.get(\"metadata\"),
    126         run_name=config.get(\"run_name\"),
    127     )

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\retrievers.py:223, in BaseRetriever.get_relevant_documents(self, query, callbacks, tags, metadata, run_name, **kwargs)
    221 except Exception as e:
    222     run_manager.on_retriever_error(e)
--> 223     raise e
    224 else:
    225     run_manager.on_retriever_end(
    226         result,
    227         **kwargs,
    228     )

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\retrievers.py:216, in BaseRetriever.get_relevant_documents(self, query, callbacks, tags, metadata, run_name, **kwargs)
    214 _kwargs = kwargs if self._expects_other_args else {}
    215 if self._new_arg_supported:
--> 216     result = self._get_relevant_documents(
    217         query, run_manager=run_manager, **_kwargs
    218     )
    219 else:
    220     result = self._get_relevant_documents(query, **_kwargs)

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_core\\vectorstores.py:654, in VectorStoreRetriever._get_relevant_documents(self, query, run_manager)
    650 def _get_relevant_documents(
    651     self, query: str, *, run_manager: CallbackManagerForRetrieverRun
    652 ) -> List[Document]:
    653     if self.search_type == \"similarity\":
--> 654         docs = self.vectorstore.similarity_search(query, **self.search_kwargs)
    655     elif self.search_type == \"similarity_score_threshold\":
    656         docs_and_similarities = (
    657             self.vectorstore.similarity_search_with_relevance_scores(
    658                 query, **self.search_kwargs
    659             )
    660         )

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_community\\vectorstores\\docarray\\base.py:127, in DocArrayIndex.similarity_search(self, query, k, **kwargs)
    115 def similarity_search(
    116     self, query: str, k: int = 4, **kwargs: Any
    117 ) -> List[Document]:
    118     \"\"\"Return docs most similar to query.
    119 
    120     Args:
   (...)
    125         List of Documents most similar to the query.
    126     \"\"\"
--> 127     results = self.similarity_search_with_score(query, k=k, **kwargs)
    128     return [doc for doc, _ in results]

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\langchain_community\\vectorstores\\docarray\\base.py:106, in DocArrayIndex.similarity_search_with_score(self, query, k, **kwargs)
     94 \"\"\"Return docs most similar to query.
     95 
     96 Args:
   (...)
    103     Lower score represents more similarity.
    104 \"\"\"
    105 query_embedding = self.embedding.embed_query(query)
--> 106 query_doc = self.doc_cls(embedding=query_embedding)  # type: ignore
    107 docs, scores = self.doc_index.find(query_doc, search_field=\"embedding\", limit=k)
    109 result = [
    110     (Document(page_content=doc.text, metadata=doc.metadata), score)
    111     for doc, score in zip(docs, scores)
    112 ]

File e:\\Repos\\Practice Projects\\Langchain\\Quickstart\\quickstart\\Lib\\site-packages\\pydantic\\main.py:164, in BaseModel.__init__(__pydantic_self__, **data)
    162 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    163 __tracebackhide__ = True
--> 164 __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)

ValidationError: 2 validation errors for DocArrayDoc
text
  Field required [type=missing, input_value={'embedding': [-0.0144587... -0.015377209573652503]}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing
metadata
  Field required [type=missing, input_value={'embedding': [-0.0144587... -0.015377209573652503]}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.5/v/missing"
}
```

### Idea or request for content:

As I am a newcomer, I do not understand exactly what the issue is. Thus, I would like to request that the documentation be updated so that the code works correctly. In the meantime, I would appreciate any assistance so I can continue to learn Langchain through the quickstart and work my way through the rest of the docs .