🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(jump-to-playground): allow for nullish tool_call_id and tool_calls (#9564)
Hassieb Pakzad28adf5b12947
diff --git a/web/src/features/playground/page/components/JumpToPlaygroundButton.tsx b/web/src/features/playground/page/components/JumpToPlaygroundButton.tsxindex 8b549b7240..e7eff1d8be 100644--- a/web/src/features/playground/page/components/JumpToPlaygroundButton.tsx+++ b/web/src/features/playground/page/components/JumpToPlaygroundButton.tsx@@ -238,8 +238,8 @@ const ParsedChatMessageListSchema = z.array(]),tool_calls: z.union([z.array(LLMToolCallSchema), z.array(OpenAIToolCallSchema)])- .optional(),- tool_call_id: z.string().optional(),+ .nullish(),+ tool_call_id: z.string().nullish(),additional_kwargs: z.object({tool_calls: z@@ -427,7 +427,9 @@ const parseGeneration = (let input = generation.input?.valueOf();- if (!!input && typeof input === "string") {+ if (!input) return null;++ if (typeof input === "string") {try {input = JSON.parse(input);@@ -461,14 +463,12 @@ const parseGeneration = (}}- if (!!input && typeof input === "object") {- const messageData = "messages" in input ? input["messages"] : input;-- const normalizedMessages = Array.isArray(messageData)- ? (messageData as any[]).map((msg) =>+ if (typeof input === "object" && "messages" in input) {+ const normalizedMessages = Array.isArray(input["messages"])+ ? (input["messages"] as any[]).map((msg) =>normalizeLangGraphMessage(msg, isLangGraph),)- : messageData;+ : input["messages"];const parsedMessages =ParsedChatMessageListSchema.safeParse(normalizedMessages);@@ -480,6 +480,7 @@ const parseGeneration = (const filteredMessages = parsedMessages.data.filter((m) => !isLangchainToolDefinitionMessage(m),);+return {messages: filteredMessages.map((msg) => transformToPlaygroundMessage(msg, filteredMessages))@@ -490,12 +491,12 @@ const parseGeneration = (};}- if (!!input && typeof input === "object" && "messages" in input) {- const normalizedMessages = Array.isArray(input["messages"])- ? (input["messages"] as any[]).map((msg) =>+ if (typeof input === "object") {+ const normalizedMessages = Array.isArray(input)+ ? (input as any[]).map((msg) =>normalizeLangGraphMessage(msg, isLangGraph),)- : input["messages"];+ : input;const parsedMessages =ParsedChatMessageListSchema.safeParse(normalizedMessages);@@ -507,6 +508,7 @@ const parseGeneration = (const filteredMessages = parsedMessages.data.filter((m) => !isLangchainToolDefinitionMessage(m),);+return {messages: filteredMessages.map((msg) => transformToPlaygroundMessage(msg, filteredMessages))