-
Notifications
You must be signed in to change notification settings - Fork 79
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
8/n Read-only mode: Input rendering #962
Conversation
7/n Read-only mode: Prompt Menu (Left side triple dots) - Add ReadOnly prop to the Prompt Menu (triple dots on the left side of the component) ## Testplan 1. Pass readOnly=True prop in `AIConfigEditor` | readOnly={false} | readOnly={true} | | ------------- | ------------- | | <img width="1172" alt="Screenshot 2024-01-18 at 1 24 10 PM" src="https://github.com/lastmile-ai/aiconfig/assets/141073967/86842c3d-b864-45ef-bce4-77435c5d0518"> | <img width="1127" alt="Screenshot 2024-01-18 at 1 25 33 PM" src="https://github.com/lastmile-ai/aiconfig/assets/141073967/38c9ef53-dfe8-4eb8-b7f2-5f87adf2a708"> | --- Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/lastmile-ai/aiconfig/pull/961). * #962 * __->__ #961 * #957
3300213
to
14351df
Compare
14351df
to
9917af9
Compare
[easy][editor][client] 6/n Read-only mode: Global Parameters - refactor `isReadonly` -> `readOnly` inside `ParametersRenderer.tsx` - useState() to get readOnly bool ## Testplan 1. Pass readOnly=True prop in `AIConfigEditor` | readOnly={false} | readOnly={true} | | ------------- | ------------- | | <img width="981" alt="Screenshot 2024-01-18 at 11 29 08 AM" src="https://github.com/lastmile-ai/aiconfig/assets/141073967/07747d6a-37d1-4b00-a5fb-ae8475c19044"> | <img width="1044" alt="Screenshot 2024-01-18 at 11 32 28 AM" src="https://github.com/lastmile-ai/aiconfig/assets/141073967/673abdb3-7048-444c-9ba2-8ad746181478"> | ## Dependencies Built ontop of #939 #961 is next on the stack --- Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/lastmile-ai/aiconfig/pull/967). * #962 * __->__ #967
4f5461e
to
85accb3
Compare
3b5d645
to
561a694
Compare
switch (schema.type) { | ||
case "string": | ||
return ( | ||
<Textarea | ||
value={data ? (data as string) : ""} | ||
onChange={(e) => onChangeData(e.target.value)} | ||
disabled={readOnly} | ||
placeholder="Type a prompt" |
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.
should this say something else in readonly mode?
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.
Placeholder is a value for when there is no data already and asking user to do an action. In our case let's set this to "" in readOnly mode (can you test example where the input string is empty) for both readOnly and normal? Thanks!
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.
added spoiler
placeHolder no longer needed since spoiler will render input which will be an undefined/empty string
@@ -77,6 +80,7 @@ export default memo(function PromptInputSchemaRenderer(props: Props) { | |||
label="Prompt" | |||
onChange={(e) => props.onChangeInput(e.target.value)} | |||
placeholder="Type a prompt" | |||
disabled = {readOnly} |
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.
same here
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.
And here :p
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.
Same about making placeholder empty string for readOnly mode
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.
python/src/aiconfig/editor/client/src/components/JSONEditorToggleButton.tsx
Outdated
Show resolved
Hide resolved
return ( | ||
<Textarea | ||
value={input as string} | ||
onChange={(e) => onChangeInput(e.target.value)} | ||
disabled={readOnly} |
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.
Instead of disabled textarea, let's render the nicer TextRenderer that text outputs use (for all places in this PR). Maybe we could also wrap that with a Spoiler in case the input is long (see TextInputCellRenderer in lastmile - https://github.com/lastmile-ai/lastmile/blob/bd3b54248682aed2720f7c2c3caefc8ebda335ee/src/components/playground_v2/cell_renderers/TextInputCellRenderer.tsx#L143-L156)
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.
@@ -38,7 +40,7 @@ function EditableAttachmentRenderer({ | |||
onRemoveAttachment={onRemoveAttachment} | |||
onEditAttachment={() => setShowUploader(true)} | |||
/> | |||
) : ( | |||
) : !readOnly && ( | |||
<AttachmentUploader |
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.
If they have a prompt that takes attachments but it has none, will this just be a blank prompt? Might be better to just render the AttachmentUploader still and have the dropzone disabled to denote that it's an input for attachments?
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.
I don't feel too strongly here -- can you compare how they look?
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.
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.
I think the disabled dropzone is better than blank for now, otherwise there's no indication of what the input is 'supposed to be'. We do the same in lastmile so it is consistent as well
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.
updated
switch (schema.type) { | ||
case "string": | ||
return ( | ||
<Textarea | ||
value={data ? (data as string) : ""} | ||
onChange={(e) => onChangeData(e.target.value)} | ||
disabled={readOnly} |
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.
Same here r.e. using the TextRenderer w/ Spoiler
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.
updated
@@ -77,6 +80,7 @@ export default memo(function PromptInputSchemaRenderer(props: Props) { | |||
label="Prompt" | |||
onChange={(e) => props.onChangeInput(e.target.value)} | |||
placeholder="Type a prompt" | |||
disabled = {readOnly} |
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.
And here :p
@@ -14,7 +15,9 @@ export default memo(function JSONRenderer({ | |||
onChange, | |||
schema, | |||
}: Props) { | |||
return !onChange ? ( | |||
const { readOnly } = useContext(AIConfigContext); | |||
// Prism is a read only renderer. |
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.
Nice comment!
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.
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.
Accepting to unblock but pls land with Ryan and my comments!
561a694
to
824a479
Compare
|
Attempted to add read-only functionality wherever applicable to input renderings. ## Testplan | ![image1](https://github.com/lastmile-ai/aiconfig/assets/141073967/31405238-bbd1-42c0-a5fc-58102fe05021) | ![image2](https://github.com/lastmile-ai/aiconfig/assets/141073967/bb8d6543-25d0-4b61-826b-ded9ddab4295) | | --- | --- | | ![image1](https://github.com/lastmile-ai/aiconfig/assets/141073967/dcec6c8b-fbe8-4aea-b2f1-f55153866385) | ![image2](https://github.com/lastmile-ai/aiconfig/assets/141073967/8e90c287-3304-484e-8831-496b0f5cd2a8) | | ![image1](https://github.com/lastmile-ai/aiconfig/assets/141073967/38e2fc27-bb39-4143-8dc1-67876110f1c6) | ![image2](https://github.com/lastmile-ai/aiconfig/assets/141073967/34d4db13-74b5-4617-bb5c-5c851e41afb8) | | ![image1](https://github.com/lastmile-ai/aiconfig/assets/141073967/80953234-3a0c-4aa5-bfc5-7d7c9176be58) | ![image2](https://github.com/lastmile-ai/aiconfig/assets/141073967/4d66ec78-04f8-45ae-b396-a91e8f3355d3) | ## dependencies built ontop of #961
824a479
to
f3c043c
Compare
|
Addressed all comments, Shipping this diff. Will fix forward if anything else might have been missed |
8/n Read-only mode: Input rendering
Attempted to add read-only functionality wherever applicable to input renderings.
Testplan
dependencies
built ontop of #961