Skip to content

Commit

Permalink
fix: views (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
hughcrt authored Jul 17, 2024
1 parent 14c753a commit 2b10e46
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 45 deletions.
25 changes: 19 additions & 6 deletions packages/frontend/pages/logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,16 @@ export default function Logs() {
clearOnDefault: true,
})

const { view, update: updateView, remove: removeView } = useView(viewId)

const {
view,
update: updateView,
remove: removeView,
loading: viewLoading,
} = useView(viewId)

const serializedChecks = useMemo(() => {
// TODO: find a better way, because it will call two times /runs
if (view) {
return serializeLogic(view.data)
}
Expand Down Expand Up @@ -454,7 +461,13 @@ export default function Logs() {

return (
<Empty
enable={!loading && !projectLoading && project && !project.activated}
enable={
!viewLoading &&
!loading &&
!projectLoading &&
project &&
!project.activated
}
Icon={IconBrandOpenai}
title="Waiting for recordings..."
showProjectId
Expand Down Expand Up @@ -519,7 +532,7 @@ export default function Logs() {
<Group>
{view && (
<Group gap="xs">
<IconPicker
{/* <IconPicker
size={26}
variant="light"
value={view.icon}
Expand All @@ -528,7 +541,7 @@ export default function Logs() {
icon,
})
}}
/>
/> */}
<RenamableField
defaultValue={view.name}
onRename={(newName) => {
Expand All @@ -544,12 +557,12 @@ export default function Logs() {
</ActionIcon>
</Menu.Target>
<Menu.Dropdown>
<Menu.Item
{/* <Menu.Item
leftSection={<IconStackPop size={16} />}
onClick={() => duplicateView()}
>
Duplicate
</Menu.Item>
</Menu.Item> */}
<Menu.Item
color="red"
leftSection={<IconTrash size={16} />}
Expand Down
78 changes: 39 additions & 39 deletions packages/shared/checks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,45 +517,45 @@ export const CHECKS: Check[] = [
},
],
},
{
id: "tokens",
name: "Tokens",
disableInEvals: true,
uiType: "basic",
params: [
{
type: "select",
id: "field",
width: 100,
defaultValue: "total",
options: [
{
label: "Completion",
value: "completion",
},
{
label: "Prompt",
value: "prompt",
},
{
label: "Total",
value: "total",
},
],
},
{
type: "label",
label: "Tokens",
},
NUMBER_PARAM,
{
type: "number",
min: 0,
id: "tokens",
width: 70,
},
],
},
// {
// id: "tokens",
// name: "Tokens",
// disableInEvals: true,
// uiType: "basic",
// params: [
// {
// type: "select",
// id: "field",
// width: 100,
// defaultValue: "total",
// options: [
// {
// label: "Completion",
// value: "completion",
// },
// {
// label: "Prompt",
// value: "prompt",
// },
// {
// label: "Total",
// value: "total",
// },
// ],
// },
// {
// type: "label",
// label: "Tokens",
// },
// NUMBER_PARAM,
// {
// type: "number",
// min: 0,
// id: "tokens",
// width: 70,
// },
// ],
// },
{
id: "languages",
name: "Language",
Expand Down
11 changes: 11 additions & 0 deletions packages/shared/checks/serialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ function deserializeParamValue(
case "number":
return Number(decodeURIComponent(value))
case "date":
if (value === "lt" || value === "gt") {
return decodeURIComponent(value)
}
return new Date(decodeURIComponent(value))
default:
return undefined
Expand All @@ -62,6 +65,14 @@ export function serializeLogic(logic: CheckLogic): string {
return all.filter(Boolean).join(".")
} else if (param && typeof param === "object" && param.params) {
const data = Object.entries(param.params)
.sort(([keyA], [keyB]) => {
if (keyA === "operator") {
return -1
}
if (keyB === "operator") {
return 1
}
})
.map(([key, value]) => {
const filterParam = CHECKS.find(
(filter) => filter.id === param.id,
Expand Down

0 comments on commit 2b10e46

Please sign in to comment.