render_tool#

langchain_cohere.react_multi_hop.prompt.render_tool(tool: BaseTool | None = None, json_schema: Dict | None = None) str[source]#
Renders a tool into prompt content. Either a BaseTool instance, or, a JSON

schema must be provided.

Parameters:
  • tool (BaseTool | None) – An instance of a BaseTool.

  • json_schema (Dict | None) – A dictionary containing the JSON schema representation of a tool.

Returns:

A string of prompt content.

Return type:

str

Example


from langchain_cohere.react_multi_hop.prompt import render_tool

json_schema = {

“name”: “example_tool”, “description”: “A description of example_tool”, “parameters”: {

“type”: “object”, “properties”: {

“foo”: {“type”: “string”, “description”: “A description of foo”}, “bar”: {“type”: “integer”, “description”: “A description of bar”},

}, “required”: [“foo”],

},

} print(render_tool(json_schema=json_schema))

tool = MyTool() print(render_tool(tool=tool))