-
Notifications
You must be signed in to change notification settings - Fork 2
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
23 changed files
with
738 additions
and
1,514 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react"; | ||
import { Loader } from "lucide-react"; | ||
import { ToolInvocation } from "ai"; | ||
|
||
// TODO: 暂时只支持谷歌搜索工具调用 | ||
function ChatTool({ tool }: { tool: ToolInvocation }) { | ||
return ( | ||
<div className="max-w-full rounded-md border"> | ||
<div className="flex items-center p-2"> | ||
<span className="font-medium">谷歌搜索:</span> | ||
{tool.args.keyword} | ||
{tool.state !== "result" && ( | ||
<Loader | ||
size={20} | ||
className="ml-1 inline animate-spin" | ||
strokeWidth={1.5} | ||
/> | ||
)} | ||
</div> | ||
{tool.state === "result" && ( | ||
<div className="space-y-2 border-t p-2"> | ||
{typeof tool.result === "string" && tool.result} | ||
{Array.isArray(tool.result) && | ||
tool.result.map((v: any, i: number) => ( | ||
<a | ||
key={i} | ||
className="block w-fit cursor-pointer underline decoration-transparent underline-offset-4 transition-colors hover:text-blue-400 hover:decoration-blue-400" | ||
href={v.link} | ||
target="_blank" | ||
> | ||
{v.title} | ||
</a> | ||
))} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default ChatTool; |
Oops, something went wrong.