LLMTool

LLMTool["name",params,fun]

represents a tool for use by an LLM enabling it to run fun on parameters specified by params.

LLMTool[{"name","description"},params,fun]

uses a description to prompt the LLM.

Details

  • "name" is the name used by the LLM to refer to the tool.
  • "description" can be used to give prompt information to the LLM about how to use the tool.
  • params and fun follow a format analogous to APIFunction.
  • Valid forms of params include:
  • "name"string parameter
    "name"typetyped parameter
    {spec1,spec2,}list of parameters
  • Valid forms of type include:
  • "form"form supported by Interpreter
    tfunfunction to be applied to the string
    assocassociation giving details of how to treat the parameter
  • Possible elements in assoc include:
  • "Interpreter""String"interpreter type
    "Help"Missing[]prompt information
    "Required"Truewhether the parameter is required

Examples

Basic Examples  (2)

Define a tool for getting the populations of cities:

Use the tool in a call to an LLM:

Define a tool with some prompting for running Wolfram Language code:

Run an LLM with the tool, returning metadata about the evaluation:

Get the completion written by the LLM with prompting and tool calls removed:

Get the completion with tool calls preserved:

Get the associations of LLMToolRequest and LLMToolResponse objects:

Wolfram Research (2023), LLMTool, Wolfram Language function, https://reference.wolfram.com/language/ref/LLMTool.html.

Text

Wolfram Research (2023), LLMTool, Wolfram Language function, https://reference.wolfram.com/language/ref/LLMTool.html.

CMS

Wolfram Language. 2023. "LLMTool." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LLMTool.html.

APA

Wolfram Language. (2023). LLMTool. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LLMTool.html

BibTeX

@misc{reference.wolfram_2023_llmtool, author="Wolfram Research", title="{LLMTool}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/LLMTool.html}", note=[Accessed: 28-November-2023 ]}

BibLaTeX

@online{reference.wolfram_2023_llmtool, organization={Wolfram Research}, title={LLMTool}, year={2023}, url={https://reference.wolfram.com/language/ref/LLMTool.html}, note=[Accessed: 28-November-2023 ]}