Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion R/content.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,17 @@ show_image <- function(x) {
#' @param arguments Named list of arguments to call the function with.
#' @param tool ellmer automatically matches a tool request to the tools defined
#' for the chatbot. If `NULL`, the request did not match a defined tool.
#' @param extra Provider-specific metadata associated with the tool request.
#' Automatically managed by \pkg{ellmer}.
ContentToolRequest <- new_class(
"ContentToolRequest",
parent = Content,
properties = list(
id = prop_string(),
name = prop_string(),
arguments = class_list,
tool = NULL | ToolDef
tool = NULL | ToolDef,
extra = class_list
)
)
method(format, ContentToolRequest) <- function(
Expand Down
13 changes: 9 additions & 4 deletions R/provider-google.R
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,14 @@ method(value_turn, ProviderGoogleGemini) <- function(
ContentText(content$text)
}
} else if (has_name(content, "functionCall")) {
extra <- compact(list(
thoughtSignature = content$thoughtSignature
))
ContentToolRequest(
content$functionCall$name,
content$functionCall$name,
content$functionCall$args
content$functionCall$args,
extra = extra
)
} else if (has_name(content, "inlineData")) {
ContentImageInline(
Expand Down Expand Up @@ -456,12 +460,13 @@ method(as_json, list(ProviderGoogleGemini, ContentToolRequest)) <- function(
x,
...
) {
list(
compact(list(
functionCall = list(
name = x@id,
args = x@arguments
)
)
),
thoughtSignature = x@extra$thoughtSignature
))
}

# https://ai.google.dev/api/caching#FunctionResponse
Expand Down
7 changes: 4 additions & 3 deletions man/Content.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.