Skip to content
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

Add an optional post-tool function to handle tool responses #72

Merged
merged 4 commits into from
Feb 18, 2025

Conversation

rishsriv
Copy link
Member

This is useful if we want to do something with the tool responses in real-time (such as showing status updates to a user), without waiting for the entire tool run to finish.

Also added tests for this, where we write the tool responses to a stream and check for their values.

@rishsriv rishsriv merged commit 67f12a6 into main Feb 18, 2025
2 checks passed
@rishsriv rishsriv deleted the rishabh/add-hooks branch February 18, 2025 16:16
@@ -616,6 +629,12 @@ async def _process_openai_response(
except Exception as e:
raise Exception(f"Error executing tool `{func_name}`: {e}")

if post_tool_function:
if inspect.iscoroutinefunction(post_tool_function):
Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL about inspect.iscoroutinefunction!

Copy link
Member Author

Choose a reason for hiding this comment

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

That was a find by @wendy-aw!

@wendy-aw wendy-aw mentioned this pull request Feb 19, 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.

2 participants