Skip to content

Commit

Permalink
[OPIK-536]: pr comment fixes;
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasha committed Dec 13, 2024
1 parent 32faa60 commit 7ba6370
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 | "";
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,13 @@ const PlaygroundOutput = forwardRef<PlaygroundOutputRef, PlaygroundOutputProps>(
providerMessages,
]);

const exposedStop = useCallback(() => {
stop();
}, [stop]);

useImperativeHandle(
ref,
() => ({
run: exposedRun,
stop: exposedStop,
stop: stop,
}),
[exposedRun, exposedStop],
[exposedRun, stop],
);

const renderContent = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const PlaygroundOutputs = ({ prompts }: PlaygroundOutputsProps) => {
const outputRefs = useRef<Map<number, PlaygroundOutputRef>>(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;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions apps/opik-frontend/src/constants/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion apps/opik-frontend/src/lib/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const generateDefaultPlaygroundPromptMessage = (
return {
content: "",
role: PLAYGROUND_MESSAGE_ROLE.system,

...message,
id: generateRandomString(),
};
Expand Down

0 comments on commit 7ba6370

Please sign in to comment.