Add tools declaration for the LLM to use
add_tools_declaration.Rd
add_tools_declaration
lets you add some tools (functions) that can be used if needed by the LLM to answer specific questions
Details
Lets you add some tools (functions) that can be used by the LLM. This only works for models where the tool calling function is supported, which is the case for Llama3.1 for example. The structure expected is a R list.
Examples
tool_list <- list(
list(type="function",
"function"=list(
name="get_flight_times",
description="get the flight times between two cities",
parameters= list(
type="object",
properties = list(
departure=list(
type="string",
description="the departure city (airport code)"
),
arrival=list(
type="string",
description="the arrival city (airport code)"
)
),
required=c("departure", "arrival")
)
)))
myflow_test <- ai_workflow() |>
set_connector("ollama") |>
set_model(model_name= "llama3.1:8b-instruct-q5_K_M") |>
set_n_predict(1000) |>
set_temperature(0.8) |>
set_default_missing_parameters_in_workflow() |>
add_tools_declaration(tool_list)
#> → Default IP address has been set to 127.0.0.1.
#> → Default port has been set to 11434.
#> → Frequency Penalty was not specified and given a default value of 1.
#> → Presence Penalty was not specified and given a default value of 1.5.
#> → Repeat Penalty was not specified and given a default value of 1.2.
#> → Mode was not specified and 'chat' was selected by default.
#> → System Prompt was not specified and given a default value of 'You are a helpful AI assistant.'.