diff --git a/apps/opik-frontend/src/api/playground/useOpenApiRunStreaming.ts b/apps/opik-frontend/src/api/playground/useOpenApiRunStreaming.ts index 130976baf8..f62149bbb6 100644 --- a/apps/opik-frontend/src/api/playground/useOpenApiRunStreaming.ts +++ b/apps/opik-frontend/src/api/playground/useOpenApiRunStreaming.ts @@ -10,6 +10,7 @@ import { ProviderStreamingMessageType, } from "@/types/playground"; import { safelyParseJSON, snakeCaseObj } from "@/lib/utils"; +import { OPENAI_API_KEY } from "@/constants/playground"; interface GetOpenAIStreamParams { model: PLAYGROUND_MODEL | ""; @@ -24,7 +25,7 @@ const getOpenAIStream = async ({ signal, configs, }: GetOpenAIStreamParams) => { - const apiKey = window.localStorage.getItem("OPENAI_API_KEY") || ""; + const apiKey = window.localStorage.getItem(OPENAI_API_KEY) || ""; return fetch("https://api.openai.com/v1/chat/completions", { method: "POST", diff --git a/apps/opik-frontend/src/api/traces/useTraceCreateMutation.ts b/apps/opik-frontend/src/api/traces/useTraceCreateMutation.ts index 6b4eb71034..ca0db17535 100644 --- a/apps/opik-frontend/src/api/traces/useTraceCreateMutation.ts +++ b/apps/opik-frontend/src/api/traces/useTraceCreateMutation.ts @@ -26,7 +26,7 @@ const useTraceCreateMutation = () => { return useMutation({ mutationFn: async (trace: UseTraceCreateMutationParams) => { - return await api.post(TRACES_REST_ENDPOINT, snakeCaseObj(trace)); + return api.post(TRACES_REST_ENDPOINT, snakeCaseObj(trace)); }, onError: (error: AxiosError) => { const message = get( diff --git a/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundOutputs/PlaygroundOutput.tsx b/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundOutputs/PlaygroundOutput.tsx index 7590825ce9..d9bb4db787 100644 --- a/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundOutputs/PlaygroundOutput.tsx +++ b/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundOutputs/PlaygroundOutput.tsx @@ -69,17 +69,13 @@ const PlaygroundOutput = forwardRef( providerMessages, ]); - const exposedStop = useCallback(() => { - stop(); - }, [stop]); - useImperativeHandle( ref, () => ({ run: exposedRun, - stop: exposedStop, + stop: stop, }), - [exposedRun, exposedStop], + [exposedRun, stop], ); const renderContent = () => { diff --git a/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundOutputs/PlaygroundOutputs.tsx b/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundOutputs/PlaygroundOutputs.tsx index da91d9a84e..bdbe99d084 100644 --- a/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundOutputs/PlaygroundOutputs.tsx +++ b/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundOutputs/PlaygroundOutputs.tsx @@ -18,6 +18,7 @@ const PlaygroundOutputs = ({ prompts }: PlaygroundOutputsProps) => { const outputRefs = useRef>(new Map()); // a recommended by react docs way to work with ref lists + // https://react.dev/learn/manipulating-the-dom-with-refs#how-to-manage-a-list-of-refs-using-a-ref-callback const getOutputRefMap = () => { return outputRefs.current; }; diff --git a/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundPrompt/PlaygroundPrompt.tsx b/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundPrompt/PlaygroundPrompt.tsx index cc85d011ee..c9999ba499 100644 --- a/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundPrompt/PlaygroundPrompt.tsx +++ b/apps/opik-frontend/src/components/pages/PlaygroundPage/PlaygroundPrompt/PlaygroundPrompt.tsx @@ -51,13 +51,7 @@ const PlaygroundPrompt = ({ }: PlaygroundPromptProps) => { const { name, id, messages, model, configs } = prompt; - const provider = useMemo(() => { - if (!model) { - return ""; - } - - return getModelProvider(model); - }, [model]); + const provider = model ? getModelProvider(model) : ""; const lastProviderNameToInitializeConfig = useRef(provider); diff --git a/apps/opik-frontend/src/constants/playground.ts b/apps/opik-frontend/src/constants/playground.ts index fb7e3ae78d..d415760b3a 100644 --- a/apps/opik-frontend/src/constants/playground.ts +++ b/apps/opik-frontend/src/constants/playground.ts @@ -91,19 +91,19 @@ export const PLAYGROUND_MODELS = { // Reasoning Models { value: PLAYGROUND_MODEL.O1_PREVIEW, - label: "o1 Preview", + label: "O1 Preview", }, { value: PLAYGROUND_MODEL.O1_MINI, - label: "o1 Mini", + label: "O1 Mini", }, { value: PLAYGROUND_MODEL.O1_MINI_2024_09_12, - label: "o1 Mini 2024-09-12", + label: "O1 Mini 2024-09-12", }, { value: PLAYGROUND_MODEL.O1_PREVIEW_2024_09_12, - label: "o1 Preview 2024-09-12", + label: "O1 Preview 2024-09-12", }, // Other Models diff --git a/apps/opik-frontend/src/lib/playground.ts b/apps/opik-frontend/src/lib/playground.ts index 0955538d98..d8ddc3dcad 100644 --- a/apps/opik-frontend/src/lib/playground.ts +++ b/apps/opik-frontend/src/lib/playground.ts @@ -19,7 +19,6 @@ export const generateDefaultPlaygroundPromptMessage = ( return { content: "", role: PLAYGROUND_MESSAGE_ROLE.system, - ...message, id: generateRandomString(), };