-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for tool calls in assistant output (#199)
- Loading branch information
1 parent
2b03d24
commit 93e12e0
Showing
9 changed files
with
117 additions
and
39 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@empiricalrun/types": minor | ||
"@empiricalrun/core": minor | ||
"@empiricalrun/ai": minor | ||
"web": minor | ||
"@empiricalrun/cli": minor | ||
--- | ||
|
||
feat: add support for assistant tool calls |
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,53 @@ | ||
import { ChatCompletionMessageToolCall } from "@empiricalrun/types"; | ||
import CodeViewer from "./ui/code-viewer"; | ||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./ui/tabs"; | ||
|
||
export function ToolCalls({ | ||
toolCalls, | ||
}: { | ||
toolCalls: ChatCompletionMessageToolCall[] | undefined; | ||
}) { | ||
if (!toolCalls) { | ||
return null; | ||
} | ||
if (toolCalls.length === 0) { | ||
return null; | ||
} | ||
const tabs = toolCalls.filter((t) => t.type === "function"); | ||
return ( | ||
<> | ||
<Tabs defaultValue={tabs[0]?.id} className="h-full"> | ||
<TabsList className=" rounded-sm w-full overflow-x-scroll justify-start no-scrollbar"> | ||
<p className=" font-semibold text-sm mr-2 text-white">Tool Calls</p> | ||
{tabs.map((tab) => ( | ||
<TabsTrigger | ||
key={tab.id} | ||
value={tab.id} | ||
className="text-xs rounded-sm" | ||
> | ||
{tab.function.name} | ||
</TabsTrigger> | ||
))} | ||
</TabsList> | ||
{tabs.map((tab) => ( | ||
<TabsContent | ||
key={tab.id} | ||
value={tab.id} | ||
// 2.25rem as the height of the tabs is h-9 by default. change this if tab height changes | ||
className="h-[calc(100%-3rem)]" | ||
> | ||
<CodeViewer | ||
value={JSON.stringify( | ||
JSON.parse(tab.function.arguments), | ||
null, | ||
2, | ||
)} | ||
language="text" | ||
readOnly | ||
/> | ||
</TabsContent> | ||
))} | ||
</Tabs> | ||
</> | ||
); | ||
} |
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