| hf_run_tools | R Documentation |
Execute tool calls requested by the last assistant message in an
hf_conversation, append tool-result messages, and ask the model for the
next response. The loop repeats until the model returns a response without
tool calls.
hf_run_tools(conversation, tools, max_turns = 5L, token = NULL, ...)
conversation |
An |
tools |
Named list of R functions, keyed by tool name. |
max_turns |
Integer. Maximum tool-execution/model-response iterations. |
token |
Character string or NULL. API token for authentication. |
... |
Additional parameters passed to the chat-completions request. |
Updated hf_conversation object.
## Not run:
tool <- hf_tool("add", "Add two numbers.", c(x = "number", y = "number"))
convo <- hf_conversation(model = "Qwen/Qwen2.5-72B-Instruct")
convo <- chat(convo, "What is 2 + 3?", tools = list(tool))
convo <- hf_run_tools(convo, list(add = function(x, y) x + y))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.