From 75b7000b1b3f5329841d6293ffdcc1bf1e993be9 Mon Sep 17 00:00:00 2001 From: Xander Song Date: Wed, 16 Oct 2024 11:41:48 -0700 Subject: [PATCH] feat(playground): wire up tool calling ui (#5029) --- .../generative/ToolChoiceSelector.tsx | 4 +- .../playground/PlaygroundChatTemplate.tsx | 4 +- app/src/pages/playground/PlaygroundOutput.tsx | 77 +++++++++++++++++-- app/src/pages/playground/PlaygroundTool.tsx | 1 + .../PlaygroundOutputSubscription.graphql.ts | 29 +++++-- .../__tests__/playgroundUtils.test.ts | 2 +- app/src/store/playground/playgroundStore.tsx | 9 ++- app/src/store/playground/types.ts | 43 ++++++++++- src/phoenix/server/api/subscriptions.py | 4 +- 9 files changed, 146 insertions(+), 27 deletions(-) diff --git a/app/src/components/generative/ToolChoiceSelector.tsx b/app/src/components/generative/ToolChoiceSelector.tsx index b0a89d095c..32a0404fc3 100644 --- a/app/src/components/generative/ToolChoiceSelector.tsx +++ b/app/src/components/generative/ToolChoiceSelector.tsx @@ -35,7 +35,7 @@ type ToolChoicePickerProps = { /** * The current choice including the default {@link ToolChoice} and any user defined tools */ - choice: ToolChoice; + choice: ToolChoice | undefined; /** * Callback for when the tool choice changes */ @@ -52,7 +52,7 @@ export function ToolChoicePicker({ toolNames, }: ToolChoicePickerProps) { const currentKey = - typeof choice === "string" + choice == null || typeof choice === "string" ? choice : addToolNamePrefix(choice.function.name); return ( diff --git a/app/src/pages/playground/PlaygroundChatTemplate.tsx b/app/src/pages/playground/PlaygroundChatTemplate.tsx index 531064f5f5..bea1b63f1d 100644 --- a/app/src/pages/playground/PlaygroundChatTemplate.tsx +++ b/app/src/pages/playground/PlaygroundChatTemplate.tsx @@ -243,7 +243,9 @@ function SortableMessageItem({ } extra={ - + {message.content != null && ( + + )}