Home / Function/ embed_documents() — langchain Function Reference

embed_documents() — langchain Function Reference

Architecture documentation for the embed_documents() function in embeddings.py from the langchain codebase.

Function python LangChainCore Runnables calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  899cf409_68f4_e6ef_1223_d9393754b32d["embed_documents()"]
  8ffbd15a_923a_c258_fc8b_25df9b4cba69["MistralAIEmbeddings"]
  899cf409_68f4_e6ef_1223_d9393754b32d -->|defined in| 8ffbd15a_923a_c258_fc8b_25df9b4cba69
  0d87a6aa_6a08_89f5_f97a_08ce13e94bc8["embed_query()"]
  0d87a6aa_6a08_89f5_f97a_08ce13e94bc8 -->|calls| 899cf409_68f4_e6ef_1223_d9393754b32d
  1ebd0b7d_e260_a53f_7605_d0c94c73ee54["_get_batches()"]
  899cf409_68f4_e6ef_1223_d9393754b32d -->|calls| 1ebd0b7d_e260_a53f_7605_d0c94c73ee54
  style 899cf409_68f4_e6ef_1223_d9393754b32d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/mistralai/langchain_mistralai/embeddings.py lines 235–270

    def embed_documents(self, texts: list[str]) -> list[list[float]]:
        """Embed a list of document texts.

        Args:
            texts: The list of texts to embed.

        Returns:
            List of embeddings, one for each text.

        """
        try:
            batch_responses = []

            @self._retry
            def _embed_batch(batch: list[str]) -> Response:
                response = self.client.post(
                    url="/embeddings",
                    json={
                        "model": self.model,
                        "input": batch,
                    },
                )
                response.raise_for_status()
                return response

            batch_responses = [
                _embed_batch(batch) for batch in self._get_batches(texts)
            ]
            return [
                list(map(float, embedding_obj["embedding"]))
                for response in batch_responses
                for embedding_obj in response.json()["data"]
            ]
        except Exception:
            logger.exception("An error occurred with MistralAI")
            raise

Domain

Subdomains

Called By

Frequently Asked Questions

What does embed_documents() do?
embed_documents() is a function in the langchain codebase, defined in libs/partners/mistralai/langchain_mistralai/embeddings.py.
Where is embed_documents() defined?
embed_documents() is defined in libs/partners/mistralai/langchain_mistralai/embeddings.py at line 235.
What does embed_documents() call?
embed_documents() calls 1 function(s): _get_batches.
What calls embed_documents()?
embed_documents() is called by 1 function(s): embed_query.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free