[docs]defrender_text_description(tools:list[BaseTool])->str:"""Render the tool name and description in plain text. Args: tools: The tools to render. Returns: The rendered text. Output will be in the format of: .. code-block:: markdown search: This tool is used for search calculator: This tool is used for math """descriptions=[]fortoolintools:ifhasattr(tool,"func")andtool.func:sig=signature(tool.func)description=f"{tool.name}{sig} - {tool.description}"else:description=f"{tool.name} - {tool.description}"descriptions.append(description)return"\n".join(descriptions)
[docs]defrender_text_description_and_args(tools:list[BaseTool])->str:"""Render the tool name, description, and args in plain text. Args: tools: The tools to render. Returns: The rendered text. Output will be in the format of: .. code-block:: markdown search: This tool is used for search, args: {"query": {"type": "string"}} calculator: This tool is used for math, \args: {"expression": {"type": "string"}} """tool_strings=[]fortoolintools:args_schema=str(tool.args)ifhasattr(tool,"func")andtool.func:sig=signature(tool.func)description=f"{tool.name}{sig} - {tool.description}"else:description=f"{tool.name} - {tool.description}"tool_strings.append(f"{description}, args: {args_schema}")return"\n".join(tool_strings)