_get_parent_ids() — langchain Function Reference
Architecture documentation for the _get_parent_ids() function in event_stream.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7["_get_parent_ids()"] 7d90a3d0_d943_c43b_2fdd_f76b9bdccd55["_AstreamEventsCallbackHandler"] 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 -->|defined in| 7d90a3d0_d943_c43b_2fdd_f76b9bdccd55 eba20684_9ff6_3b4c_db54_51c72958ee21["tap_output_aiter()"] eba20684_9ff6_3b4c_db54_51c72958ee21 -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 7e0e4260_c649_7926_5bad_cfb55c871227["tap_output_iter()"] 7e0e4260_c649_7926_5bad_cfb55c871227 -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 e23900ac_414e_24b8_9643_d43f3281b4a2["on_chat_model_start()"] e23900ac_414e_24b8_9643_d43f3281b4a2 -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 095bb696_11f2_5caa_de95_fa70c67c0755["on_llm_start()"] 095bb696_11f2_5caa_de95_fa70c67c0755 -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 5ce0066a_597b_8984_5257_86b03f333f12["on_custom_event()"] 5ce0066a_597b_8984_5257_86b03f333f12 -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 5f307e5b_1e60_af07_da9e_835f68af6b95["on_llm_new_token()"] 5f307e5b_1e60_af07_da9e_835f68af6b95 -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 b2dca71f_0029_3088_214b_28f2cfc46a37["on_llm_end()"] b2dca71f_0029_3088_214b_28f2cfc46a37 -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 25b73ee9_d187_bf90_8093_8c67d1e8442b["on_chain_start()"] 25b73ee9_d187_bf90_8093_8c67d1e8442b -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 8adf3444_0643_10f8_eecf_d39f20af454a["on_chain_end()"] 8adf3444_0643_10f8_eecf_d39f20af454a -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 68bd61c8_48b7_bd17_2365_526f5a064b78["on_tool_start()"] 68bd61c8_48b7_bd17_2365_526f5a064b78 -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 a3150503_96ad_fc97_6c6b_a34fdb33ce4f["on_tool_error()"] a3150503_96ad_fc97_6c6b_a34fdb33ce4f -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 a6966d42_8b6a_57f5_bddd_1d5339558e7a["on_tool_end()"] a6966d42_8b6a_57f5_bddd_1d5339558e7a -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 422aead3_a229_fd99_9dd5_bb754ae08473["on_retriever_start()"] 422aead3_a229_fd99_9dd5_bb754ae08473 -->|calls| 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 style 2c05b944_8b57_0ec1_2c17_2b3f4c3562c7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/tracers/event_stream.py lines 148–165
def _get_parent_ids(self, run_id: UUID) -> list[str]:
"""Get the parent IDs of a run (non-recursively) cast to strings."""
parent_ids = []
while parent_id := self.parent_map.get(run_id):
str_parent_id = str(parent_id)
if str_parent_id in parent_ids:
msg = (
f"Parent ID {parent_id} is already in the parent_ids list. "
f"This should never happen."
)
raise AssertionError(msg)
parent_ids.append(str_parent_id)
run_id = parent_id
# Return the parent IDs in reverse order, so that the first
# parent ID is the root and the last ID is the immediate parent.
return parent_ids[::-1]
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _get_parent_ids() do?
_get_parent_ids() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/event_stream.py.
Where is _get_parent_ids() defined?
_get_parent_ids() is defined in libs/core/langchain_core/tracers/event_stream.py at line 148.
What calls _get_parent_ids()?
_get_parent_ids() is called by 14 function(s): on_chain_end, on_chain_start, on_chat_model_start, on_custom_event, on_llm_end, on_llm_new_token, on_llm_start, on_retriever_end, and 6 more.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free