Продолжаю следить за развитием ellmer. В новом релизе частично нарушена обратная совместимость — но только в части функционала, связанного с добавлением инструментов в чат. Ниже подробнее.
Что нового в версии 0.3.0
Унифицированный конструктор чатов
Раньше под каждого провайдера была своя функция-конструктор:
-
chat_openai()-
chat_anthropic()-
chat_google_gemini()Теперь используется единый конструктор
chat(), в который можно сразу передать нужный провайдер или модель:openai_chat <- chat("openai/gpt-4.1")
openai_chat$chat("Tell me a joke about an R programmer")
anthropic_chat <- chat("anthropic")
#> Using model = "claude-sonnet-4-20250514".
anthropic_chat$chat("Write an acrostic for tidyr")Улучшенная спецификация инструментов
Хедли поработал над интерфейсом инициализации инструментов, добавляемых в модель.
Новый интефейс выглядит так:
get_weather <- tool(
function(location, unit = "celsius") {
# Function implementation here
paste0("Weather in ", location, " is 22 ", unit)
},
name = "get_weather",
description = "Get current weather for a location",
arguments = list(
location = type_string("The city and state, e.g. San Francisco, CA"),
unit = type_enum(c("C", "F"), "Temperature unit: celsius/fahrenheit")
)
)
Что изменилось:
1. Аргументы функций теперь передаются в виде списка в
arguments;2. У остальных аргументов убрали префикс в виде точки.
Что бы максимально легко перевести свой код определения инструментов модели с предыдущих версий используйте любую LLM, и следующий промпт:
Help the user convert an ellmer 0.2.0 and earlier tool definition into a
ellmer 0.3.0 tool definition. Here's what changed:
* All arguments, apart from the first, should be named, and the argument
names no longer use `.` prefixes. The argument order should be function,
name (as a string), description, then arguments, then anything
* Previously `arguments` was passed as `...`, so all type specifications
should now be moved into a named list and passed to the `arguments`
argument. It can be omitted if the function has no arguments.
# old
tool(
add,
"Add two numbers together"
x = type_number(),
y = type_number()
)
# new
tool(
add,
name = "add",
description = "Add two numbers together",
arguments = list(
x = type_number(),
y = type_number()
)
)
Don't respond; just let the user provide function calls to convert.
И добавьте в него все
tool() описанные в предыдущих версиях ellmer.#новости_и_релизы_по_R