class_docstr: OpenAPIServiceConnector connects to OpenAPI services, allowing for the invocation of methods specified in
  an OpenAPI specification of that service. It integrates with ChatMessage interface, where messages are used to
  determine the method to be called and the parameters to be passed. The message payload should be a JSON formatted
  string consisting of the method name and the parameters to be passed to the method. The method name and parameters
  are then used to invoke the method on the OpenAPI service. The response from the service is returned as a
  ChatMessage.
  
  Before using this component, one needs to register functions from the OpenAPI specification with LLM.
  This can be done using the OpenAPIServiceToFunctions component.
docstr: Parses the message to extract the method invocation descriptor.
  
  :param message: ChatMessage containing the tools calls
  :type message: ChatMessage
  :return: A list of function invocation payloads
  :rtype: List[Dict[str, Any]]
  :raises ValueError: If the content is not valid JSON or lacks required fields.
code: def _parse_message(
      self, message: ChatMessage
  ) -> List[Dict[str, Any]]:
      """
      Parses the message to extract the method invocation descriptor.
  
      :param message: ChatMessage containing the tools calls
      :type message: ChatMessage
      :return: A list of function invocation payloads
      :rtype: List[Dict[str, Any]]
      :raises ValueError: If the content is not valid JSON or lacks required fields.
      """
      function_payloads = []
      try:
          tool_calls = json.loads(message.content)
      except json.JSONDecodeError:
          raise ValueError(
              "Invalid JSON content, expected OpenAI tools message.",
              message.content,
          )
  
      for tool_call in tool_calls:
          # this should never happen, but just in case do a sanity check
          if "type" not in tool_call:
              raise ValueError(
                  "Message payload doesn't seem to be a tool invocation descriptor",
                  message.content,
              )
  
          # In OpenAPIServiceConnector we know how to handle functions tools only
          if tool_call["type"] == "function":
              function_call = tool_call["function"]
              function_payloads.append(
                  {
                      "arguments": json.loads(
                          function_call["arguments"]
                      ),
                      "name": function_call["name"],
                  }
              )
      return function_payloads
  
file_path: haystack/haystack/components/connectors/openapi_service.py
imports: import json
  import logging
  from typing import List, Dict, Any, Optional
  from haystack import component
  from haystack.dataclasses import ChatMessage, ChatRole
  from haystack.lazy_imports import LazyImport
label_desc: Use image node_id 3 for calling the OpenAPIServiceConnector obj's underlying member method code with example usage: obj._parse_message(message) and returns: function_payloads