diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 65df33cb86..0587b81402 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: files: \.(jsx?|tsx?|css|.md)$ exclude: \.*__generated__.*$ additional_dependencies: - - prettier@3.2.4 + - prettier@3.3.3 - repo: https://github.com/pre-commit/mirrors-eslint rev: "8ddcbd412c0b348841f0f82c837702f432539652" hooks: diff --git a/app/src/pages/playground/PlaygroundChatTemplate.tsx b/app/src/pages/playground/PlaygroundChatTemplate.tsx index 57ab17f892..f43a5aa9eb 100644 --- a/app/src/pages/playground/PlaygroundChatTemplate.tsx +++ b/app/src/pages/playground/PlaygroundChatTemplate.tsx @@ -36,6 +36,7 @@ import { usePlaygroundContext } from "@phoenix/contexts/PlaygroundContext"; import { useChatMessageStyles } from "@phoenix/hooks/useChatMessageStyles"; import { ChatMessage, + createOpenAIResponseFormat, generateMessageId, PlaygroundChatTemplate as PlaygroundChatTemplateType, PlaygroundInstance, @@ -44,11 +45,16 @@ import { assertUnreachable } from "@phoenix/typeUtils"; import { safelyParseJSON } from "@phoenix/utils/jsonUtils"; import { ChatMessageToolCallsEditor } from "./ChatMessageToolCallsEditor"; +import { + RESPONSE_FORMAT_PARAM_CANONICAL_NAME, + RESPONSE_FORMAT_PARAM_NAME, +} from "./constants"; import { MessageContentRadioGroup, MessageMode, } from "./MessageContentRadioGroup"; import { MessageRolePicker } from "./MessageRolePicker"; +import { PlaygroundResponseFormat } from "./PlaygroundResponseFormat"; import { PlaygroundTools } from "./PlaygroundTools"; import { createToolCallForProvider, @@ -74,11 +80,18 @@ export function PlaygroundChatTemplate(props: PlaygroundChatTemplateProps) { ); const instances = usePlaygroundContext((state) => state.instances); const updateInstance = usePlaygroundContext((state) => state.updateInstance); + const upsertInvocationParameterInput = usePlaygroundContext( + (state) => state.upsertInvocationParameterInput + ); const playgroundInstance = instances.find((instance) => instance.id === id); if (!playgroundInstance) { throw new Error(`Playground instance ${id} not found`); } const hasTools = playgroundInstance.tools.length > 0; + const hasResponseFormat = + playgroundInstance.model.invocationParameters.find( + (p) => p.canonicalName === RESPONSE_FORMAT_PARAM_CANONICAL_NAME + ) != null; const { template } = playgroundInstance; if (template.__type !== "chat") { throw new Error(`Invalid template type ${template.__type}`); @@ -151,9 +164,28 @@ export function PlaygroundChatTemplate(props: PlaygroundChatTemplateProps) { paddingBottom="size-100" borderColor="dark" borderTopWidth="thin" - borderBottomWidth={hasTools ? "thin" : undefined} + borderBottomWidth={hasTools || hasResponseFormat ? "thin" : undefined} > +