Skip to content

feat(ContentToolResult): Add additional data and allow as tool return value#423

Merged
gadenbuie merged 14 commits into
tidyverse:mainfrom
gadenbuie:feat/content-tool-result-data
Apr 4, 2025
Merged

feat(ContentToolResult): Add additional data and allow as tool return value#423
gadenbuie merged 14 commits into
tidyverse:mainfrom
gadenbuie:feat/content-tool-result-data

Conversation

@gadenbuie

Copy link
Copy Markdown
Collaborator

Fixes #398
Fixes #399

@gadenbuie gadenbuie marked this pull request as ready for review April 3, 2025 18:50
@gadenbuie gadenbuie requested a review from hadley April 3, 2025 19:05
Comment thread R/content-tools.R Outdated
Comment thread R/content-tools.R Outdated
Comment thread R/content-tools.R Outdated
Comment thread R/content-tools.R Outdated
Comment thread R/chat.R
result <- stream_merge_chunks(private$provider, result, chunk)
}
turn <- value_turn(private$provider, result, has_type = !is.null(type))
turn <- private$match_tools(turn)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is that we match requests to the tool definitions up-front, which allows ContentToolRequest to carry the tool definition.

With this in place, we don't need to pass the tools into invoke_tools(), we can instead pass the turn directly. This could also be helpful in the display of a tool request.

(It also ensures we have paired results/requests in the very unlikely event the LLM requests a tool even if there are no tools defined.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach!

Comment thread R/content-tools.R Outdated
@gadenbuie gadenbuie requested a review from hadley April 3, 2025 20:51
Comment thread R/content.R Outdated

@hadley hadley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like great progress. The API is really starting to come together.

Comment thread R/content-tools.R Outdated
Comment thread R/chat.R
result <- stream_merge_chunks(private$provider, result, chunk)
}
turn <- value_turn(private$provider, result, has_type = !is.null(type))
turn <- private$match_tools(turn)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach!

Comment thread R/content-tools.R Outdated

@hadley hadley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Comment thread R/content-tools.R Outdated
@gadenbuie gadenbuie merged commit 9ffe282 into tidyverse:main Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Augment data attached to ContentToolResult Allow tool functions to return a ContentToolResult object

3 participants