Skip to content

Commit

Permalink
feat(prompts): default tags for prod / staging / dev (#5980)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeldking authored Jan 10, 2025
1 parent fb8c10c commit 3376475
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from "./userConstants";
export * from "./timeConstants";
export * from "./numberConstants";
export * from "./pointCloudConstants";
export * from "./promptConstants";
14 changes: 14 additions & 0 deletions app/src/constants/promptConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const DEFAULT_PROMPT_VERSTION_TAGS = [
{
name: "production",
description: "The version deployed to production",
},
{
name: "staging",
description: "The version deployed to staging",
},
{
name: "development",
description: "The version deployed for development",
},
];
18 changes: 17 additions & 1 deletion app/src/pages/prompt/PromptVersionTagsConfigCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {

import { Card } from "@arizeai/components";

import { Flex, Icon, Icons } from "@phoenix/components";
import { Flex, Icon, Icons, Link } from "@phoenix/components";
import { TextCell } from "@phoenix/components/table";
import { tableCSS } from "@phoenix/components/table/styles";
import { TableEmpty } from "@phoenix/components/table/TableEmpty";

Expand All @@ -30,6 +31,7 @@ export function PromptVersionTagsConfigCard({
id
name
description
promptVersionId
}
}
`,
Expand All @@ -45,6 +47,19 @@ export function PromptVersionTagsConfigCard({
{
header: "Description",
accessorKey: "description",
cell: TextCell,
},
{
header: "Version",
accessorKey: "promptVersionId",
cell: ({ row }) => {
const { promptId, promptVersionId } = row.original;
return (
<Link to={`/prompts/${promptId}/versions/${promptVersionId}`}>
{row.original.promptVersionId}
</Link>
);
},
},
{
id: "actions",
Expand Down Expand Up @@ -79,6 +94,7 @@ export function PromptVersionTagsConfigCard({
name: tag.name,
description: tag.description,
promptId: data.id,
promptVersionId: tag.promptVersionId,
}));
}, [data]);

Expand Down
35 changes: 28 additions & 7 deletions app/src/pages/prompt/TagPromptVersionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Suspense, useState } from "react";
import React, { Suspense, useMemo, useState } from "react";
import { graphql, useLazyLoadQuery, useMutation } from "react-relay";
import { useParams } from "react-router";
import { css } from "@emotion/react";
Expand All @@ -15,11 +15,11 @@ import {
PopoverArrow,
View,
} from "@phoenix/components";
import { DEFAULT_PROMPT_VERSTION_TAGS } from "@phoenix/constants";
import { useNotifySuccess } from "@phoenix/contexts";

import { TagPromptVersionButtonTagsQuery } from "./__generated__/TagPromptVersionButtonTagsQuery.graphql";
import { NewPromptVersionDialog } from "./NewPromptVersionTagDialog";

export function TagPromptVersionButton() {
const [showNewTagDialog, setShowNewTagDialog] = useState<boolean>(false);
const [fetchKey, setFetchKey] = useState<number>(0);
Expand Down Expand Up @@ -131,10 +131,21 @@ function TagList({
{ promptId, versionId },
{ fetchKey, fetchPolicy: "store-and-network" }
);
const allVersionTags =
data?.prompt?.versionTags?.map((tag) => tag.name) || [];
const versionTags = data?.promptVersion?.tags?.map((tag) => tag.name) || [];

const versionTags = useMemo(() => {
return data?.promptVersion?.tags?.map((tag) => tag.name) || [];
}, [data?.promptVersion?.tags]);

const allVersionTags = useMemo(() => {
return Array.from(
new Set([
...DEFAULT_PROMPT_VERSTION_TAGS.map(
(tagDefinition) => tagDefinition.name
),
...versionTags,
])
);
}, [versionTags]);
const [commitSetTag, isCommitting] = useMutation(graphql`
mutation TagPromptVersionButtonSetTagMutation(
$input: SetPromptVersionTagInput!
Expand All @@ -151,7 +162,7 @@ function TagList({
`);
return (
<ul>
{allVersionTags.map((tagName) => {
{allVersionTags.map((tagName: string) => {
const isTagSet = versionTags.includes(tagName);
return (
<li key={tagName}>
Expand All @@ -169,11 +180,21 @@ function TagList({
disabled={isTagSet || isCommitting}
onChange={(e) => {
if (e.target.checked) {
const isCreate = !versionTags.includes(tagName);
let description = "";
if (isCreate) {
const tagDefinition = DEFAULT_PROMPT_VERSTION_TAGS.find(
(tagDefinition) => tagDefinition.name === tagName
);
description = tagDefinition?.description || "";
}

commitSetTag({
variables: {
input: {
name: tagName,
promptVersionId: versionId,
description,
},
promptVersionId: versionId,
},
Expand All @@ -184,7 +205,7 @@ function TagList({
}
}}
/>
{tagName}
<span>{tagName}</span>
</Flex>
</View>
</li>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3376475

Please sign in to comment.