Skip to content
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

Merged
merged 1 commit into from
Jan 19, 2024
Merged

8/n Read-only mode: Input rendering #962

merged 1 commit into from
Jan 19, 2024

Conversation

Ankush-lastmile
Copy link
Member

@Ankush-lastmile Ankush-lastmile commented Jan 18, 2024

8/n Read-only mode: Input rendering

Attempted to add read-only functionality wherever applicable to input renderings.

Testplan

image1 image2
image1 image2
image1 image2
image1 image2

dependencies

built ontop of #961

Ankush-lastmile added a commit that referenced this pull request Jan 18, 2024
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
Ankush-lastmile added a commit that referenced this pull request Jan 19, 2024
[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
@Ankush-lastmile Ankush-lastmile changed the title {wip} 8/n Read-only mode: Input rendering 8/n Read-only mode: Input rendering Jan 19, 2024
switch (schema.type) {
case "string":
return (
<Textarea
value={data ? (data as string) : ""}
onChange={(e) => onChangeData(e.target.value)}
disabled={readOnly}
placeholder="Type a prompt"
Copy link
Member Author

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?

Copy link
Contributor

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!

Copy link
Member Author

@Ankush-lastmile Ankush-lastmile Jan 19, 2024

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}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here :p

Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readOnly = False
Screenshot 2024-01-19 at 10 28 40 AM

readOnly = True
Screenshot 2024-01-19 at 10 28 54 AM

placeHolder no longer needed since spoiler will render input which will be an undefined/empty string

return (
<Textarea
value={input as string}
onChange={(e) => onChangeInput(e.target.value)}
disabled={readOnly}
Copy link
Contributor

@rholinshead rholinshead Jan 19, 2024

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated
readOnly = False
Screenshot 2024-01-19 at 10 16 06 AM

readOnly = True
Screenshot 2024-01-19 at 10 17 10 AM

@@ -38,7 +40,7 @@ function EditableAttachmentRenderer({
onRemoveAttachment={onRemoveAttachment}
onEditAttachment={() => setShowUploader(true)}
/>
) : (
) : !readOnly && (
<AttachmentUploader
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Member Author

@Ankush-lastmile Ankush-lastmile Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops sorry forgot to include this in the testplan.

Screenshot 2024-01-19 at 10 23 47 AM

vs

disabled doesn't change how its rendered but it disables the dropzone.
Screenshot 2024-01-19 at 10 22 55 AM

updated to dropzone, Thought it wouldn't be nice to show the dropzone,

Copy link
Contributor

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

Copy link
Member Author

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}
Copy link
Contributor

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

Copy link
Member Author

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}
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice comment!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@rossdanlm rossdanlm left a 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!

@Ankush-lastmile
Copy link
Member Author

Ankush-lastmile commented Jan 19, 2024

  • Switch negation in JSONEditorToggleButton
  • Spoiler to PromptInputConfigRenderer
  • Spoiler in PromptInputSchemaRenderer
  • Spoiler in PromptInputSchemaRenderer.tsx
  • disabled dropzone on readOnly

@Ankush-lastmile
Copy link
Member Author

  • remove readOnly on attachment renderer

@Ankush-lastmile
Copy link
Member Author

Accepting to unblock but pls land with Ryan and my comments!

Addressed all comments, Shipping this diff. Will fix forward if anything else might have been missed

@Ankush-lastmile Ankush-lastmile merged commit 2dbcf0a into main Jan 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants