Home / Function/ parse_ai_message_to_openai_tool_action() — langchain Function Reference

parse_ai_message_to_openai_tool_action() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  03b76997_d9d9_fcb9_f76a_f61d5102a4c6["parse_ai_message_to_openai_tool_action()"]
  254556a4_f4d5_d2d1_ca58_c969fccaa45d["openai_tools.py"]
  03b76997_d9d9_fcb9_f76a_f61d5102a4c6 -->|defined in| 254556a4_f4d5_d2d1_ca58_c969fccaa45d
  69f1ed51_f459_63d1_12bd_66856735c9e5["parse_result()"]
  69f1ed51_f459_63d1_12bd_66856735c9e5 -->|calls| 03b76997_d9d9_fcb9_f76a_f61d5102a4c6
  style 03b76997_d9d9_fcb9_f76a_f61d5102a4c6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/agents/output_parsers/openai_tools.py lines 15–36

def parse_ai_message_to_openai_tool_action(
    message: BaseMessage,
) -> list[AgentAction] | AgentFinish:
    """Parse an AI message potentially containing tool_calls."""
    tool_actions = parse_ai_message_to_tool_action(message)
    if isinstance(tool_actions, AgentFinish):
        return tool_actions
    final_actions: list[AgentAction] = []
    for action in tool_actions:
        if isinstance(action, ToolAgentAction):
            final_actions.append(
                OpenAIToolAgentAction(
                    tool=action.tool,
                    tool_input=action.tool_input,
                    log=action.log,
                    message_log=action.message_log,
                    tool_call_id=action.tool_call_id,
                ),
            )
        else:
            final_actions.append(action)
    return final_actions

Subdomains

Called By

Frequently Asked Questions

What does parse_ai_message_to_openai_tool_action() do?
parse_ai_message_to_openai_tool_action() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/agents/output_parsers/openai_tools.py.
Where is parse_ai_message_to_openai_tool_action() defined?
parse_ai_message_to_openai_tool_action() is defined in libs/langchain/langchain_classic/agents/output_parsers/openai_tools.py at line 15.
What calls parse_ai_message_to_openai_tool_action()?
parse_ai_message_to_openai_tool_action() is called by 1 function(s): parse_result.

Analyze Your Own Codebase

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

Try Supermodel Free