-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prompts): Render model invocation params in prompt details view (#…
…5780) * feat(prompts): Render model invocation params in propt details view * Use fragment in PromptInvocationParameters * temporarily use component styles for lists until we can migrate * fix scrolling --------- Co-authored-by: Mikyo King <mikyo@arize.com>
- Loading branch information
1 parent
cf4c65f
commit 55afe18
Showing
12 changed files
with
458 additions
and
178 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React, { useMemo } from "react"; | ||
import { graphql, useFragment } from "react-relay"; | ||
import isObject from "lodash/isObject"; | ||
|
||
import { Flex, List, ListItem, Text, View } from "@arizeai/components"; | ||
|
||
import { PromptInvocationParameters__main$key } from "./__generated__/PromptInvocationParameters__main.graphql"; | ||
|
||
function PromptInvocationParameterItem({ | ||
keyName, | ||
value, | ||
}: { | ||
keyName: string; | ||
value: unknown; | ||
}) { | ||
return ( | ||
<View paddingStart="size-100" paddingEnd="size-100"> | ||
<Flex direction="row" justifyContent="space-between"> | ||
<Text weight="heavy">{keyName}</Text> | ||
<Text>{String(value)}</Text> | ||
</Flex> | ||
</View> | ||
); | ||
} | ||
|
||
type PromptInvocationParametersProps = { | ||
promptVersion: PromptInvocationParameters__main$key; | ||
}; | ||
|
||
export function PromptInvocationParameters({ | ||
promptVersion, | ||
}: PromptInvocationParametersProps) { | ||
const { invocationParameters } = | ||
useFragment<PromptInvocationParameters__main$key>( | ||
graphql` | ||
fragment PromptInvocationParameters__main on PromptVersion { | ||
invocationParameters | ||
} | ||
`, | ||
promptVersion | ||
); | ||
const parameters = useMemo(() => { | ||
if (!isObject(invocationParameters)) { | ||
return []; | ||
} | ||
return Object.entries(invocationParameters).map(([key, value]) => ({ | ||
key, | ||
value, | ||
})); | ||
}, [invocationParameters]); | ||
|
||
if (parameters.length === 0) { | ||
return ( | ||
<View padding="size-200"> | ||
<Flex justifyContent="center" alignItems="center"> | ||
<Text>No parameters saved for this prompt</Text> | ||
</Flex> | ||
</View> | ||
); | ||
} | ||
|
||
return ( | ||
<List listSize="small"> | ||
{parameters.map(({ key, value }) => ( | ||
<ListItem key="key"> | ||
<PromptInvocationParameterItem keyName={key} value={value} /> | ||
</ListItem> | ||
))} | ||
</List> | ||
); | ||
} |
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
49 changes: 47 additions & 2 deletions
49
app/src/pages/prompt/__generated__/PromptIndexPage__main.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
app/src/pages/prompt/__generated__/PromptInvocationParameters__main.graphql.ts
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.