-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(prompts): Render model invocation params in prompt details view #5780
Merged
mikeldking
merged 4 commits into
prompts
from
cephalization/prompts/5777-show-invocation-params-prompt-details
Dec 19, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
68fcd12
feat(prompts): Render model invocation params in propt details view
cephalization b7807d7
Use fragment in PromptInvocationParameters
cephalization d2a6004
temporarily use component styles for lists until we can migrate
mikeldking 1851ba7
fix scrolling
mikeldking File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should likely be set to width=100% and have the parent constrain the width with a px value. That way we can render this list in both the prompt aside and the versions tab and let the parent decide how much space it takes up.