Convenience function that creates an ellmer tool from a module and registers it with a Chat object in one step.
Arguments
- chat
An ellmer Chat object.
- module
A DSPrrr module.
- name
Optional tool name.
- description
Optional tool description.
- .llm
Optional ellmer Chat object for the module to use when called. If not provided, the module's stored chat or default chat is used.
- annotations
Optional ellmer tool annotations list, passed through to
ellmer::tool().- output
Tool result serialization mode. See
as_ellmer_tool().- copy
Whether tool calls should use the supplied module directly or a fresh deep copy. See
as_ellmer_tool().- error
Tool error handling mode. See
as_ellmer_tool().
Examples
if (FALSE) { # \dontrun{
chat <- ellmer::chat_openai()
mod <- module(signature("query -> answer"), type = "predict")
# Register in one step
register_dsprrr_tool(chat, mod, name = "knowledge_lookup")
# Use the tool
chat$chat("Use the knowledge_lookup tool to answer: What is R?")
} # }