Skip to content

Commit

Permalink
feat: add enrichments page (#547)
Browse files Browse the repository at this point in the history
Co-authored-by: 7HR4IZ3 <[email protected]>
  • Loading branch information
hughcrt and 7HR4IZ3 authored Sep 9, 2024
1 parent bf35e91 commit be54057
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 158 deletions.
34 changes: 11 additions & 23 deletions packages/frontend/components/layout/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ export default function Sidebar() {
resource: "logs",
},
{ label: "Users", icon: IconUsers, link: "/users", resource: "users" },
{
label: "Enrichments",
icon: IconSparkles,
link: "/enrichments",
resource: "enrichments",
disabled: isSelfHosted
? org.license && org.license.realtimeEvalsEnabled
: false,
},
],
},
{
Expand All @@ -314,15 +323,6 @@ export default function Sidebar() {
? org.license && !org.license.evalEnabled
: false,
},
{
label: "Evaluators",
icon: IconActivityHeartbeat,
link: "/evaluations/realtime",
resource: "evaluations",
disabled: isSelfHosted
? org.license && !org.license.evalEnabled
: false,
},
{
label: "Datasets",
icon: IconDatabase,
Expand All @@ -341,20 +341,6 @@ export default function Sidebar() {
resource: "logs",
subMenu: projectViews,
},
// {
// label: "Project",
// resource: "apiKeys",
// subMenu: [
// !!canUpgrade && {
// label: "Upgrade",
// onClick: openUpgrade,
// c: "vioplet",
// icon: IconBolt,
// disabled: !canUpgrade,
// resource: "billing",
// },
// ].filter((item) => item),
// },
].filter((item) => item);

async function createProject() {
Expand Down Expand Up @@ -397,6 +383,8 @@ export default function Sidebar() {
</Combobox.Option>
));

console.log(APP_MENU);

return (
<Flex
justify="space-between"
Expand Down
4 changes: 0 additions & 4 deletions packages/frontend/components/prompts/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export const ParamItem = ({ name, value, description }) => (
</Group>
);


const validateToolCalls = (toolCalls: any[]) => {
if (!Array.isArray(toolCalls)) return false;

Expand Down Expand Up @@ -138,7 +137,6 @@ export default function ProviderEditor({
},
});


return (
<>
<ParamItem
Expand Down Expand Up @@ -337,8 +335,6 @@ export default function ProviderEditor({
? undefined
: JSON.parse(jsonrepair(tempJSON.trim()));

console.log(empty, repaired);

if (!empty && !validateToolCalls(repaired)) {
throw new Error("Invalid tool calls format");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Empty from "@/components/layout/Empty";
import Paywall from "@/components/layout/Paywall";
import { useOrg } from "@/utils/dataHooks";
import { useEvaluator, useEvaluators } from "@/utils/dataHooks/evaluators";
import { slugify } from "@/utils/format";
import { useEnricher, useEnrichers } from "@/utils/dataHooks/evaluators";
import EVALUATOR_TYPES from "@/utils/evaluators";

import { slugify } from "@/utils/format";
import {
ActionIcon,
Badge,
Expand All @@ -18,51 +18,102 @@ import {
Title,
} from "@mantine/core";
import {
IconActivity,
IconActivityHeartbeat,
IconDotsVertical,
IconEdit,
IconPencil,
IconPlus,
IconTrash,
} from "@tabler/icons-react";
import { NextSeo } from "next-seo";
import { useRouter } from "next/router";
import Empty from "@/components/layout/Empty";

function EnricherCard({ id, initialData }) {
const { enricher, delete: deleteEnricher } = useEnricher(id, initialData);

const { description, icon: Icon } = EVALUATOR_TYPES[enricher.type];

return (
<Card p="lg" withBorder>
<Group justify="space-between">
<Stack>
<Group>
<Icon size={24} />
<Title order={3} size={16}>
{enricher.name}
</Title>
<Text c="dimmed" fw="semibold" size="sm">
{description}
</Text>
</Group>
<Group>
<Text c="dimmed" fw="semibold" size="sm">
{slugify(enricher.name)}
</Text>
</Group>
</Stack>

<Menu>
<Menu.Target>
<ActionIcon variant="transparent">
<IconDotsVertical color="gray" />
</ActionIcon>
</Menu.Target>

<Menu.Dropdown>
{/* <Menu.Item
leftSection={
<IconPencil color="blue" width="15px" height="15px" />
}
disabled
onClick={() => {}}
>
Update
</Menu.Item> */}
<Menu.Item
leftSection={<IconTrash color="red" width="15px" height="15px" />}
onClick={() => deleteEnricher()}
>
Delete
</Menu.Item>
</Menu.Dropdown>
</Menu>
</Group>
</Card>
);
}

const FEATURE_LIST = [
"Real-time LLM-based evaluations on production data",
"Enrich logs, with sentiment analysis, topic recognition, PII detection, and more",
"Use local models like Llama 3 or connect to external APIs",
"Automatic data labelling and scoring on production data, in real time",
"Sentiment analysis, topic recognition, PII detection, and more",
"Define custom LLM-based enrichers",
];

export default function RealtimeEvaluators() {
export default function Enrichments() {
const router = useRouter();
const { evaluators, isLoading } = useEvaluators();
const { enrichers, isLoading } = useEnrichers();
const { org } = useOrg();

if (isLoading) {
return <Loader />;
}

if (org?.plan === "free") {
if (org.plan === "free") {
return (
<Paywall
plan="enterprise"
feature="Realtime Evaluations"
feature="Data Enrichment"
Icon={IconActivityHeartbeat}
p="xl"
enabled={!org.license.realtimeEvalsEnabled}
description="Run evaluations on your production data in real-time."
description="Enrich your production data in real-time."
list={FEATURE_LIST}
>
<Container>
<Stack>
<Group align="center" justify="space-between">
<Group align="center">
<Title>Realtime Evaluations</Title>
<Title>Data Enrichments</Title>
<Badge variant="teal" color="violet">
Enteprise
Enterprise
</Badge>
</Group>

Expand All @@ -74,9 +125,9 @@ export default function RealtimeEvaluators() {
</Group>

<Text size="lg" mb="md">
Run evaluations on your production data in real-time. They can be
used to enrich your data with additional information, such as
sentiment analysis, topic recognition, and more.
Gain insight from your production data in real time, by adding
additional information, such as sentiment analysis, topic
recognition, and more.
</Text>
</Stack>
</Container>
Expand All @@ -86,18 +137,18 @@ export default function RealtimeEvaluators() {

return (
<Empty
enable={!evaluators.length}
enable={!enrichers.length}
Icon={IconActivityHeartbeat}
title="Real-time Evaluations"
buttonLabel="Create First Evaluator"
onClick={() => router.push("/evaluations/realtime/new")}
description="Run evaluations on your production data in real-time with task-optimized models."
title="Data Enrichment"
buttonLabel="Create First Enricher"
onClick={() => router.push("/enrichments/new")}
description="Enrich your production data in real-time."
>
<Container>
<Stack>
<Group align="center" justify="space-between">
<Group align="center">
<Title>Evaluators</Title>
<Title>Data Enrichment</Title>
<Badge variant="light" color="blue">
Beta
</Badge>
Expand All @@ -106,22 +157,22 @@ export default function RealtimeEvaluators() {
<Button
leftSection={<IconPlus size={12} />}
variant="default"
onClick={() => router.push("/evaluations/realtime/new")}
onClick={() => router.push("/enrichments/new")}
>
New Evaluator
Add Data Enricher
</Button>
</Group>

<Text size="xl" mb="md">
Run evaluations on your production data in real-time.
Enrich your production data in real-time.
</Text>

<Stack gap="xl">
{evaluators?.map((evaluator) => (
<EvaluationCard
key={evaluator.id}
id={evaluator.id}
initialData={evaluator}
{enrichers?.map((enricher) => (
<EnricherCard
key={enricher.id}
id={enricher.id}
initialData={enricher}
/>
))}
</Stack>
Expand All @@ -130,58 +181,3 @@ export default function RealtimeEvaluators() {
</Empty>
);
}

function EvaluationCard({ id, initialData }) {
const { evaluator, delete: deleteEvaluator } = useEvaluator(id, initialData);

const { description, icon: Icon } = EVALUATOR_TYPES[evaluator.type];

return (
<Card p="lg" withBorder>
<Group justify="space-between">
<Stack>
<Group>
<Icon size={24} />
<Title order={3} size={16}>
{evaluator.name}
</Title>
<Text c="dimmed" fw="semibold" size="sm">
{description}
</Text>
</Group>
<Group>
<Text c="dimmed" fw="semibold" size="sm">
{slugify(evaluator.name)}
</Text>
</Group>
</Stack>

<Menu>
<Menu.Target>
<ActionIcon variant="transparent">
<IconDotsVertical color="gray" />
</ActionIcon>
</Menu.Target>

<Menu.Dropdown>
<Menu.Item
leftSection={
<IconPencil color="blue" width="15px" height="15px" />
}
disabled
onClick={() => {}}
>
Update
</Menu.Item>
<Menu.Item
leftSection={<IconTrash color="red" width="15px" height="15px" />}
onClick={() => deleteEvaluator()}
>
Delete
</Menu.Item>
</Menu.Dropdown>
</Menu>
</Group>
</Card>
);
}
Loading

0 comments on commit be54057

Please sign in to comment.