-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prompts): preview of last 5 versions (#5837)
* feat(prompts): preview of last 5 versions * feat(prompts): preview of last 5 versions * rename
- Loading branch information
1 parent
e2391de
commit 3c3c5e0
Showing
6 changed files
with
248 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React, { useMemo } from "react"; | ||
import { graphql, useFragment } from "react-relay"; | ||
import { css } from "@emotion/react"; | ||
|
||
import { Text } from "@arizeai/components"; | ||
|
||
import { Flex, Icon, Icons } from "@phoenix/components"; | ||
|
||
import { PromptLatestVersionsListFragment$key } from "./__generated__/PromptLatestVersionsListFragment.graphql"; | ||
|
||
const versionListItemCSS = css` | ||
padding-bottom: var(--ac-global-dimension-size-300); | ||
position: relative; | ||
`; | ||
export function PromptLatestVersionsList(props: { | ||
prompt: PromptLatestVersionsListFragment$key; | ||
}) { | ||
const { prompt } = props; | ||
const data = useFragment<PromptLatestVersionsListFragment$key>( | ||
graphql` | ||
fragment PromptLatestVersionsListFragment on Prompt { | ||
latestVersions: promptVersions(first: 5) { | ||
edges { | ||
version: node { | ||
id | ||
... on PromptVersion { | ||
description | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
prompt | ||
); | ||
const versions = useMemo(() => { | ||
return data?.latestVersions?.edges?.map((edge) => edge.version); | ||
}, [data]); | ||
|
||
if (!versions) { | ||
throw new Error("Expected prompt versions to be defined"); | ||
} | ||
|
||
return ( | ||
<ul> | ||
{versions.map((version) => { | ||
return ( | ||
<li key={version.id} css={versionListItemCSS}> | ||
<Flex direction="row" gap="size-200" alignItems="start"> | ||
<Icon svg={<Icons.Commit />} /> | ||
<Flex direction="column"> | ||
<span>{version.id}</span> | ||
<Text color="text-700">{version.description}</Text> | ||
</Flex> | ||
</Flex> | ||
{/* TODO(prompts): show that there are more */} | ||
<VersionsConnector /> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
); | ||
} | ||
|
||
const versionsConnectorCSS = css` | ||
position: absolute; | ||
top: 24px; | ||
left: 9px; | ||
height: calc(100% - 28px); | ||
border-right: 2px dashed var(--ac-global-color-grey-500); | ||
`; | ||
function VersionsConnector() { | ||
return <div css={versionsConnectorCSS} />; | ||
} |
10 changes: 8 additions & 2 deletions
10
app/src/pages/prompt/__generated__/PromptIndexPage__aside.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
app/src/pages/prompt/__generated__/PromptLatestVersionsListFragment.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
64 changes: 47 additions & 17 deletions
64
app/src/pages/prompt/__generated__/promptLoaderQuery.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.