code: from typing import Dict, List, Optional
  
  from langchain.agents.load_tools import (
      _EXTRA_LLM_TOOLS,
      _EXTRA_OPTIONAL_TOOLS,
      _LLM_TOOLS,
  )
  
  from langflow.custom import customs
  from langflow.interface.base import LangChainTypeCreator
  from langflow.interface.tools.constants import (
      ALL_TOOLS_NAMES,
      CUSTOM_TOOLS,
      FILE_TOOLS,
      OTHER_TOOLS,
  )
  from langflow.interface.tools.util import get_tool_params
  from langflow.services.utils import get_settings_manager
  
  from langflow.template.field.base import TemplateField
  from langflow.template.template.base import Template
  from langflow.utils import util
  from langflow.utils.util import build_template_from_class
  
  TOOL_INPUTS = {
      "str": TemplateField(
          field_type="str",
          required=True,
          is_list=False,
          show=True,
          placeholder="",
          value="",
      ),
      "llm": TemplateField(
          field_type="BaseLanguageModel", required=True, is_list=False, show=True
      ),
      "func": TemplateField(
          field_type="function",
          required=True,
          is_list=False,
          show=True,
          multiline=True,
      ),
      "code": TemplateField(
          field_type="str",
          required=True,
          is_list=False,
          show=True,
          value="",
          multiline=True,
      ),
      "path": TemplateField(
          field_type="file",
          required=True,
          is_list=False,
          show=True,
          value="",
          suffixes=[".json", ".yaml", ".yml"],
          file_types=["json", "yaml", "yml"],
      ),
  }
  
  
  class ToolCreator(LangChainTypeCreator):
      type_name: str = "tools"
      tools_dict: Optional[Dict] = None
  
      @property
      def type_to_loader_dict(self) -> Dict:
          settings_manager = get_settings_manager()
          if self.tools_dict is None:
              all_tools = {}
  
              for tool, tool_fcn in ALL_TOOLS_NAMES.items():
                  tool_params = get_tool_params(tool_fcn)
  
                  tool_name = tool_params.get("name") or tool
  
                  if (
                      tool_name in settings_manager.settings.TOOLS
                      or settings_manager.settings.DEV
                  ):
                      if tool_name == "JsonSpec":
                          tool_params["path"] = tool_params.pop("dict_")  # type: ignore
                      all_tools[tool_name] = {
                          "type": tool,
                          "params": tool_params,
                          "fcn": tool_fcn,
                      }
  
              self.tools_dict = all_tools
  
          return self.tools_dict
  
      def get_signature(self, name: str) -> Optional[Dict]:
          """Get the signature of a tool."""
  
          base_classes = ["Tool", "BaseTool"]
          fields = []
          params = []
          tool_params = {}
  
          # Raise error if name is not in tools
          if name not in self.type_to_loader_dict.keys():
              raise ValueError("Tool not found")
  
          tool_type: str = self.type_to_loader_dict[name]["type"]  # type: ignore
  
          # if tool_type in _BASE_TOOLS.keys():
          #     params = []
          if tool_type in _LLM_TOOLS.keys():
              params = ["llm"]
          elif tool_type in _EXTRA_LLM_TOOLS.keys():
              extra_keys = _EXTRA_LLM_TOOLS[tool_type][1]
              params = ["llm"] + extra_keys
          elif tool_type in _EXTRA_OPTIONAL_TOOLS.keys():
              extra_keys = _EXTRA_OPTIONAL_TOOLS[tool_type][1]
              params = extra_keys
          # elif tool_type == "Tool":
          #     params = ["name", "description", "func"]
          elif tool_type in CUSTOM_TOOLS:
              # Get custom tool params
              params = self.type_to_loader_dict[name]["params"]  # type: ignore
              base_classes = ["function"]
              if node := customs.get_custom_nodes("tools").get(tool_type):
                  return node
          elif tool_type in FILE_TOOLS:
              params = self.type_to_loader_dict[name]["params"]  # type: ignore
              base_classes += [name]
          elif tool_type in OTHER_TOOLS:
              tool_dict = build_template_from_class(tool_type, OTHER_TOOLS)
              fields = tool_dict["template"]
  
              # Pop unnecessary fields and add name
              fields.pop("_type")  # type: ignore
              fields.pop("return_direct")  # type: ignore
              fields.pop("verbose")  # type: ignore
  
              tool_params = {
                  "name": fields.pop("name")["value"],  # type: ignore
                  "description": fields.pop("description")["value"],  # type: ignore
              }
  
              fields = [
                  TemplateField(name=name, field_type=field["type"], **field)
                  for name, field in fields.items()  # type: ignore
              ]
              base_classes += tool_dict["base_classes"]
  
          # Copy the field and add the name
          for param in params:
              field = TOOL_INPUTS.get(param, TOOL_INPUTS["str"]).copy()
              field.name = param
              field.advanced = False
              if param == "aiosession":
                  field.show = False
                  field.required = False
  
              fields.append(field)
  
          template = Template(fields=fields, type_name=tool_type)
  
          tool_params = {**tool_params, **self.type_to_loader_dict[name]["params"]}
          return {
              "template": util.format_dict(template.to_dict()),
              **tool_params,
              "base_classes": base_classes,
          }
  
      def to_list(self) -> List[str]:
          """List all load tools"""
  
          return list(self.type_to_loader_dict.keys())
  
  
  tool_creator = ToolCreator()
  
apis: langchain.agents.load_tools._EXTRA_LLM_TOOLS.keys langchain.agents.load_tools._LLM_TOOLS.keys langchain.agents.load_tools._EXTRA_OPTIONAL_TOOLS.keys
extract_api: [((709, 811), 'langflow.template.field.base.TemplateField', 'TemplateField', ([], {'field_type': '"""str"""', 'required': '(True)', 'is_list': '(False)', 'show': '(True)', 'placeholder': '""""""', 'value': '""""""'}), "(field_type='str', required=True, is_list=False, show=True,\n    placeholder='', value='')\n", (722, 811), False, 'from langflow.template.field.base import TemplateField\n'), ((875, 965), 'langflow.template.field.base.TemplateField', 'TemplateField', ([], {'field_type': '"""BaseLanguageModel"""', 'required': '(True)', 'is_list': '(False)', 'show': '(True)'}), "(field_type='BaseLanguageModel', required=True, is_list=False,\n    show=True)\n", (888, 965), False, 'from langflow.template.field.base import TemplateField\n'), ((989, 1087), 'langflow.template.field.base.TemplateField', 'TemplateField', ([], {'field_type': '"""function"""', 'required': '(True)', 'is_list': '(False)', 'show': '(True)', 'multiline': '(True)'}), "(field_type='function', required=True, is_list=False, show=\n    True, multiline=True)\n", (1002, 1087), False, 'from langflow.template.field.base import TemplateField\n'), ((1143, 1245), 'langflow.template.field.base.TemplateField', 'TemplateField', ([], {'field_type': '"""str"""', 'required': '(True)', 'is_list': '(False)', 'show': '(True)', 'value': '""""""', 'multiline': '(True)'}), "(field_type='str', required=True, is_list=False, show=True,\n    value='', multiline=True)\n", (1156, 1245), False, 'from langflow.template.field.base import TemplateField\n'), ((1310, 1474), 'langflow.template.field.base.TemplateField', 'TemplateField', ([], {'field_type': '"""file"""', 'required': '(True)', 'is_list': '(False)', 'show': '(True)', 'value': '""""""', 'suffixes': "['.json', '.yaml', '.yml']", 'file_types': "['json', 'yaml', 'yml']"}), "(field_type='file', required=True, is_list=False, show=True,\n    value='', suffixes=['.json', '.yaml', '.yml'], file_types=['json',\n    'yaml', 'yml'])\n", (1323, 1474), False, 'from langflow.template.field.base import TemplateField\n'), ((1728, 1750), 'langflow.services.utils.get_settings_manager', 'get_settings_manager', ([], {}), '()\n', (1748, 1750), False, 'from langflow.services.utils import get_settings_manager\n'), ((5139, 5183), 'langflow.template.template.base.Template', 'Template', ([], {'fields': 'fields', 'type_name': 'tool_type'}), '(fields=fields, type_name=tool_type)\n', (5147, 5183), False, 'from langflow.template.template.base import Template\n'), ((1849, 1872), 'langflow.interface.tools.constants.ALL_TOOLS_NAMES.items', 'ALL_TOOLS_NAMES.items', ([], {}), '()\n', (1870, 1872), False, 'from langflow.interface.tools.constants import ALL_TOOLS_NAMES, CUSTOM_TOOLS, FILE_TOOLS, OTHER_TOOLS\n'), ((3091, 3108), 'langchain.agents.load_tools._LLM_TOOLS.keys', '_LLM_TOOLS.keys', ([], {}), '()\n', (3106, 3108), False, 'from langchain.agents.load_tools import _EXTRA_LLM_TOOLS, _EXTRA_OPTIONAL_TOOLS, _LLM_TOOLS\n'), ((1904, 1929), 'langflow.interface.tools.util.get_tool_params', 'get_tool_params', (['tool_fcn'], {}), '(tool_fcn)\n', (1919, 1929), False, 'from langflow.interface.tools.util import get_tool_params\n'), ((3165, 3188), 'langchain.agents.load_tools._EXTRA_LLM_TOOLS.keys', '_EXTRA_LLM_TOOLS.keys', ([], {}), '()\n', (3186, 3188), False, 'from langchain.agents.load_tools import _EXTRA_LLM_TOOLS, _EXTRA_OPTIONAL_TOOLS, _LLM_TOOLS\n'), ((3314, 3342), 'langchain.agents.load_tools._EXTRA_OPTIONAL_TOOLS.keys', '_EXTRA_OPTIONAL_TOOLS.keys', ([], {}), '()\n', (3340, 3342), False, 'from langchain.agents.load_tools import _EXTRA_LLM_TOOLS, _EXTRA_OPTIONAL_TOOLS, _LLM_TOOLS\n'), ((4038, 4087), 'langflow.utils.util.build_template_from_class', 'build_template_from_class', (['tool_type', 'OTHER_TOOLS'], {}), '(tool_type, OTHER_TOOLS)\n', (4063, 4087), False, 'from langflow.utils.util import build_template_from_class\n'), ((3746, 3779), 'langflow.custom.customs.get_custom_nodes', 'customs.get_custom_nodes', (['"""tools"""'], {}), "('tools')\n", (3770, 3779), False, 'from langflow.custom import customs\n'), ((4571, 4630), 'langflow.template.field.base.TemplateField', 'TemplateField', ([], {'name': 'name', 'field_type': "field['type']"}), "(name=name, field_type=field['type'], **field)\n", (4584, 4630), False, 'from langflow.template.field.base import TemplateField\n')]