Home / Function/ parse_tool_calls() — langchain Function Reference

parse_tool_calls() — langchain Function Reference

Architecture documentation for the parse_tool_calls() function in openai_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  6bbf0e48_c095_5f4e_dfb8_4947a3959e12["parse_tool_calls()"]
  c3f63ac2_81c2_ae51_1450_844466073e29["openai_tools.py"]
  6bbf0e48_c095_5f4e_dfb8_4947a3959e12 -->|defined in| c3f63ac2_81c2_ae51_1450_844466073e29
  6362cf2f_ac6d_027b_84a9_3cafe28b4ba5["parse_result()"]
  6362cf2f_ac6d_027b_84a9_3cafe28b4ba5 -->|calls| 6bbf0e48_c095_5f4e_dfb8_4947a3959e12
  8e9fd1fe_5de0_04e1_cb35_1696d2e6ac68["parse_result()"]
  8e9fd1fe_5de0_04e1_cb35_1696d2e6ac68 -->|calls| 6bbf0e48_c095_5f4e_dfb8_4947a3959e12
  cf81cf85_471b_b177_c7dd_c28a7117abfd["parse_tool_call()"]
  6bbf0e48_c095_5f4e_dfb8_4947a3959e12 -->|calls| cf81cf85_471b_b177_c7dd_c28a7117abfd
  style 6bbf0e48_c095_5f4e_dfb8_4947a3959e12 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/output_parsers/openai_tools.py lines 102–137

def parse_tool_calls(
    raw_tool_calls: list[dict],
    *,
    partial: bool = False,
    strict: bool = False,
    return_id: bool = True,
) -> list[dict[str, Any]]:
    """Parse a list of tool calls.

    Args:
        raw_tool_calls: The raw tool calls to parse.
        partial: Whether to parse partial JSON.
        strict: Whether to allow non-JSON-compliant strings.
        return_id: Whether to return the tool call id.

    Returns:
        The parsed tool calls.

    Raises:
        OutputParserException: If any of the tool calls are not valid JSON.
    """
    final_tools: list[dict[str, Any]] = []
    exceptions = []
    for tool_call in raw_tool_calls:
        try:
            parsed = parse_tool_call(
                tool_call, partial=partial, strict=strict, return_id=return_id
            )
            if parsed:
                final_tools.append(parsed)
        except OutputParserException as e:
            exceptions.append(str(e))
            continue
    if exceptions:
        raise OutputParserException("\n\n".join(exceptions))
    return final_tools

Domain

Subdomains

Frequently Asked Questions

What does parse_tool_calls() do?
parse_tool_calls() is a function in the langchain codebase, defined in libs/core/langchain_core/output_parsers/openai_tools.py.
Where is parse_tool_calls() defined?
parse_tool_calls() is defined in libs/core/langchain_core/output_parsers/openai_tools.py at line 102.
What does parse_tool_calls() call?
parse_tool_calls() calls 1 function(s): parse_tool_call.
What calls parse_tool_calls()?
parse_tool_calls() is called by 2 function(s): parse_result, parse_result.

Analyze Your Own Codebase

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

Try Supermodel Free