Skip to content

Commit

Permalink
feat: useAssistantTool allow disabling tools (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Dec 28, 2024
1 parent 267c521 commit 2c7dec0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/dull-owls-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@assistant-ui/react": patch
---

feat: useAssistantTool allow disabling tools
5 changes: 4 additions & 1 deletion packages/react/src/model-config/useAssistantTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type AssistantToolProps<
> = Tool<TArgs, TResult> & {
toolName: string;
render?: ToolCallContentPartComponent<TArgs, TResult> | undefined;
disabled?: boolean | undefined;
};

export const useAssistantTool = <
Expand All @@ -32,7 +33,9 @@ export const useAssistantTool = <
}, [toolUIsStore, tool.toolName, tool.render]);

useEffect(() => {
const { toolName, render, ...rest } = tool;
const { toolName, render, disabled, ...rest } = tool;
if (disabled) return;

const config = {
tools: {
[toolName]: rest,
Expand Down

0 comments on commit 2c7dec0

Please sign in to comment.