-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
42 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
"use client"; | ||
import { FC } from "react"; | ||
import { type AssistantToolProps, useAssistantTool } from "./useAssistantTool"; | ||
|
||
export type AssistantTool = FC & { | ||
unstable_tool: AssistantToolProps<any, any>; | ||
}; | ||
|
||
export const makeAssistantTool = < | ||
TArgs extends Record<string, unknown>, | ||
TResult, | ||
>( | ||
tool: AssistantToolProps<TArgs, TResult>, | ||
) => { | ||
const Tool = () => { | ||
const Tool: AssistantTool = () => { | ||
useAssistantTool(tool); | ||
return null; | ||
}; | ||
Tool.unstable_tool = tool; | ||
return Tool; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
"use client"; | ||
import { FC } from "react"; | ||
import { | ||
type AssistantToolUIProps, | ||
useAssistantToolUI, | ||
} from "./useAssistantToolUI"; | ||
|
||
export type AssistantToolUI = FC & { | ||
unstable_tool: AssistantToolUIProps<any, any>; | ||
}; | ||
|
||
export const makeAssistantToolUI = < | ||
TArgs extends Record<string, unknown>, | ||
TResult, | ||
>( | ||
tool: AssistantToolUIProps<TArgs, TResult>, | ||
) => { | ||
const ToolUI = () => { | ||
const ToolUI: AssistantToolUI = () => { | ||
useAssistantToolUI(tool); | ||
return null; | ||
}; | ||
ToolUI.unstable_tool = tool; | ||
return ToolUI; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters