WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

LLMTool ["name",params,fun]

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

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

uses a description to prompt the LLM.

Details
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
See Also
Related Guides
History
Cite this Page
This functionality requires LLM access »

LLMTool ["name",params,fun]

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

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

uses a description to prompt the LLM.

Details

  • LLMTool is typically used to provide exact answers or up-to-date information to a large language model (LLM).
  • Using LLMTool modifies an LLM prompt to explain how to use the tool, what it does and its arguments.
  • The LLM can use the tool by specifying its "name", which should be descriptive of the actual tool function for triggering LLM usage effectively. Extra details about the tool can be given in "description".
  • Tool calls are parsed into an LLMToolRequest and the evaluation result is sent to the LLM as a string.
  • The format of params and fun is analogous to APIFunction .
  • Valid forms of params include:
  • "name" string parameter
    "name"type typed parameter
    {spec1,spec2,} list of parameters
  • Valid forms of type include:
  • "form" any form supported by Interpreter
    Interpreter [] any Interpreter object
    assoc an association giving details of how to treat the parameter
    tfun any function to be applied to the string
  • Possible elements in assoc include:
  • "Interpreter" "String" interpreter type
    "Help" Missing [] prompt information
    "Required" True whether the parameter is required

Examples

open all close all

Basic Examples  (2)

Define a tool for counting the number of characters in a string:

Wolfram Language code: tool = LLMTool["countcharacter", "string", StringLength[#string]&]

Use the tool in a call to an LLM:

Wolfram Language code: LLMSynthesize["How many letters in the word \"characters\" (use the tool) ?", LLMEvaluator -> <|"Tools" -> tool|>]

Define a tool for querying the population of cities by their name and describe it for the LLM:

Wolfram Language code: tool = LLMTool[{"cityPopulationFinder", "Query WolframAlpha to get the population of a city from its name."}, "city" -> "City", #city["Population"]&]

Use the tool in a call to an LLM:

Wolfram Language code: LLMSynthesize["Use the tool to write a few sentences about Chicago.", LLMEvaluator -> <|"Tools" -> tool|>]

Scope  (3)

Define a tool for computing power series expansion using multiple different inputs interpretations:

Wolfram Language code: series = LLMTool[{"series_expand", "compute taylor series of a Wolfram Expression"}, {"input" -> "Expression", "order" -> "Integer", "variable" -> "Expression"}, ToString[Normal@Series[#input, {#variable, 0, #order}], InputForm]&]

Ask the LLM a question requiring it to query a series expansion for the answer:

Wolfram Language code: LLMSynthesize["What is the tenth order coefficient of w*Sin[w] taylor expansion?", "CompletionText", LLMEvaluator -> LLMConfiguration[<|"Tools" -> series|>]]

Define a tool to expose the TravelDistance function, interpreting parameter as a list of cities:

Wolfram Language code: trip = LLMTool[{"CityTravelDistance", "Gives the estimated distance traveling to each city in the list"}, {"cityList" -> DelimitedSequence["City", ","]}, TravelDistance[#cityList]&]

Find shortest travel path:

Wolfram Language code: LLMSynthesize["Going from NewYork to Boston is it shorter to pass by Springfield or Providence ?", LLMEvaluator -> <|"Tools" -> trip|>]

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

Wolfram Language code: tool = LLMTool[{"runCode", "Run Wolfram Language code"}, "code", If[ChoiceDialog["Run this code? " <> #code], ToString[ToExpression[#code], InputForm], "Code not allowed"]&]

Run an LLM with the tool, returning all the evaluation properties:

Wolfram Language code: data = LLMSynthesize["Which is closer to Boston: San Francisco or London? Use the tool as you write your response.", All, LLMEvaluator -> <|"Tools" -> tool|>];

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

Wolfram Language code: data["CompletionText"]

Get the completion with tool calls preserved:

Wolfram Language code: data["CompletionToolsText"]

Get the LLMToolRequest and LLMToolResponse objects lists:

Wolfram Language code: data["ToolRequests"]
Wolfram Language code: data["ToolResponses"]

History

Introduced in 2023 (13.3)

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_2026_llmtool, author="Wolfram Research", title="{LLMTool}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/LLMTool.html}", note=[Accessed: 13-August-2026]}

BibLaTeX

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

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /