Skip to content

Commit 2002efb

Browse files
author
Dylan Huang
committed
support model as JSON
1 parent a53f31c commit 2002efb

4 files changed

Lines changed: 92 additions & 22 deletions

File tree

vite-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"react-chartjs-2": "^5.3.0",
2222
"react-dom": "^19.1.0",
2323
"react-router-dom": "^7.7.1",
24+
"react-tooltip": "^5.29.1",
2425
"zod": "^4.0.14"
2526
},
2627
"devDependencies": {

vite-app/pnpm-lock.yaml

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vite-app/src/components/EvaluationRow.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { TableCell, TableRowInteractive } from "./TableContainer";
1111
import { useState } from "react";
1212
import type { FilterGroup, FilterConfig } from "../types/filters";
1313
import { Tooltip } from "./Tooltip";
14+
import { JSONTooltip } from "./JSONTooltip";
1415

1516
// Add filter button component
1617
const AddFilterButton = observer(
@@ -190,9 +191,29 @@ const InvocationId = observer(({ invocationId }: { invocationId?: string }) => {
190191
);
191192
});
192193

193-
const RowModel = observer(({ model }: { model: string | undefined }) => (
194-
<span className="text-gray-900 truncate block">{model || "N/A"}</span>
195-
));
194+
const RowModel = observer(
195+
({ model }: { model: string | object | undefined }) => {
196+
const displayValue = model
197+
? typeof model === "string"
198+
? model
199+
: JSON.stringify(model)
200+
: "N/A";
201+
202+
// For strings, show full value without tooltip
203+
if (typeof model === "string" || !model) {
204+
return <span className="text-gray-900 block">{displayValue}</span>;
205+
}
206+
207+
// For objects, use JSONTooltip with truncation
208+
return (
209+
<JSONTooltip data={model}>
210+
<span className="text-gray-900 truncate block max-w-[200px] cursor-help">
211+
{displayValue}
212+
</span>
213+
</JSONTooltip>
214+
);
215+
}
216+
);
196217

197218
const RowScore = observer(({ score }: { score: number | undefined }) => {
198219
const scoreClass = score
Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react";
2+
import { Tooltip as ReactTooltip } from "react-tooltip";
23

34
interface TooltipProps {
45
children: React.ReactNode;
@@ -13,29 +14,35 @@ export const Tooltip: React.FC<TooltipProps> = ({
1314
position = "top",
1415
className = "",
1516
}) => {
16-
const getPositionClasses = () => {
17-
switch (position) {
18-
case "top":
19-
return "bottom-full left-1/2 transform -translate-x-1/2 mb-2";
20-
case "bottom":
21-
return "top-full left-1/2 transform -translate-x-1/2 mt-2";
22-
case "left":
23-
return "right-full top-1/2 transform -translate-y-1/2 mr-2";
24-
case "right":
25-
return "left-full top-1/2 transform -translate-y-1/2 ml-2";
26-
default:
27-
return "bottom-full left-1/2 transform -translate-x-1/2 mb-2";
28-
}
29-
};
17+
const tooltipId = `tooltip-${Math.random().toString(36).substr(2, 9)}`;
3018

3119
return (
32-
<div className={`relative group cursor-pointer ${className}`}>
33-
{children}
20+
<>
3421
<div
35-
className={`absolute ${getPositionClasses()} px-2 py-1 text-xs text-white bg-gray-800 rounded opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-10`}
22+
data-tooltip-id={tooltipId}
23+
className={`cursor-pointer ${className}`}
3624
>
37-
{content}
25+
{children}
3826
</div>
39-
</div>
27+
<ReactTooltip
28+
id={tooltipId}
29+
place={position}
30+
className="px-2 py-1 text-xs text-white bg-gray-800 rounded z-10"
31+
style={{
32+
fontSize: "0.75rem",
33+
lineHeight: "1rem",
34+
backgroundColor: "#1f2937",
35+
color: "white",
36+
borderRadius: "0.25rem",
37+
padding: "0.5rem",
38+
zIndex: 10,
39+
userSelect: "text",
40+
pointerEvents: "auto",
41+
}}
42+
noArrow={true}
43+
>
44+
{content}
45+
</ReactTooltip>
46+
</>
4047
);
4148
};

0 commit comments

Comments
 (0)