Skip to content

Add on_tool_result()/on_tool_request() callbacks #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Feb 11, 2025

Addresses #33

Since taking a first pass at this, I've realized it'd be better if on_tool_result()/on_tool_request() expected a function that returns a string. And, that string would then be yielded by .chat() and friends (when echo="text"). This way, adding custom tool UI in Shiny or at the console would be fairly trivial, just do something like:

@chat.on_tool_request
def _(request):
    return f"Calling tool {request.name}..."

@chat.on_tool_result
def _(result):
    return f"Got tool result: {result.value}"

And, to make it easier to create good Shiny UI (i.e., put in a card, maybe with a title and progress indicator), we could perhaps have <shiny-chat-tool-request> and <shiny-chat-tool-result> component helpers?

cc @gadenbuie

@cpsievert
Copy link
Collaborator Author

#69 supersedes this

@cpsievert cpsievert closed this Mar 7, 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.

1 participant