Home / Function/ _results_to_docs_and_scores() — langchain Function Reference

_results_to_docs_and_scores() — langchain Function Reference

Architecture documentation for the _results_to_docs_and_scores() function in vectorstores.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  930a5ad0_324c_9f12_2f5f_6ee76cbc3551["_results_to_docs_and_scores()"]
  d4a05de9_1f0f_3b21_8171_181bb47227ef["vectorstores.py"]
  930a5ad0_324c_9f12_2f5f_6ee76cbc3551 -->|defined in| d4a05de9_1f0f_3b21_8171_181bb47227ef
  606e28c0_f5b8_541a_3421_640b6c15492e["_results_to_docs()"]
  606e28c0_f5b8_541a_3421_640b6c15492e -->|calls| 930a5ad0_324c_9f12_2f5f_6ee76cbc3551
  561ae42b_0831_86cc_0c0f_9b97d4c4ec09["similarity_search_by_vector_with_relevance_scores()"]
  561ae42b_0831_86cc_0c0f_9b97d4c4ec09 -->|calls| 930a5ad0_324c_9f12_2f5f_6ee76cbc3551
  931a8250_c45c_2dfc_c4d4_c2956f5c59b1["similarity_search_with_score()"]
  931a8250_c45c_2dfc_c4d4_c2956f5c59b1 -->|calls| 930a5ad0_324c_9f12_2f5f_6ee76cbc3551
  style 930a5ad0_324c_9f12_2f5f_6ee76cbc3551 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/chroma/langchain_chroma/vectorstores.py lines 39–55

def _results_to_docs_and_scores(results: Any) -> list[tuple[Document, float]]:
    return [
        # TODO: Chroma can do batch querying,
        # we shouldn't hard code to the 1st result
        (
            Document(page_content=result[0], metadata=result[1] or {}, id=result[2]),
            result[3],
        )
        for result in zip(
            results["documents"][0],
            results["metadatas"][0],
            results["ids"][0],
            results["distances"][0],
            strict=False,
        )
        if result[0] is not None
    ]

Subdomains

Frequently Asked Questions

What does _results_to_docs_and_scores() do?
_results_to_docs_and_scores() is a function in the langchain codebase, defined in libs/partners/chroma/langchain_chroma/vectorstores.py.
Where is _results_to_docs_and_scores() defined?
_results_to_docs_and_scores() is defined in libs/partners/chroma/langchain_chroma/vectorstores.py at line 39.
What calls _results_to_docs_and_scores()?
_results_to_docs_and_scores() is called by 3 function(s): _results_to_docs, similarity_search_by_vector_with_relevance_scores, similarity_search_with_score.

Analyze Your Own Codebase

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

Try Supermodel Free