Skip to content

Commit

Permalink
Merge pull request #1391 from Agenta-AI/issue-1232/-make-inputs-unmod…
Browse files Browse the repository at this point in the history
…ifyable-in-human-evaluation-view

Make inputs unmodifyable in human evaluation view
  • Loading branch information
aakrem authored Mar 4, 2024
2 parents facb1c8 + 5913f95 commit 83f02f9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
38 changes: 28 additions & 10 deletions agenta-web/src/components/Playground/ParamsForm/ParamsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {GenericObject, Parameter} from "@/lib/Types"
import {renameVariables} from "@/lib/helpers/utils"
import {Form, FormInstance, Image, Input} from "antd"
import {createUseStyles} from "react-jss"
import {JSSTheme} from "@/lib/Types"

const useStyles = createUseStyles({
const useStyles = createUseStyles((theme: JSSTheme) => ({
form: {
width: "100%",
"& .ant-form-item": {
Expand All @@ -26,7 +27,15 @@ const useStyles = createUseStyles({
objectFit: "cover",
borderRadius: 6,
},
})
paramValueContainer: {
border: `1px solid ${theme.colorBorder}`,
width: "100%",
borderRadius: theme.borderRadius,
padding: theme.paddingSM,
maxHeight: 300,
overflowY: "scroll",
},
}))

const ASPECT_RATIO = 1.55

Expand All @@ -38,6 +47,7 @@ interface Props {
useChatDefaultValue?: boolean
form?: FormInstance<GenericObject>
imageSize?: "small" | "large"
isPlaygroundComponent?: boolean
}

const ParamsForm: React.FC<Props> = ({
Expand All @@ -48,6 +58,7 @@ const ParamsForm: React.FC<Props> = ({
useChatDefaultValue,
form,
imageSize = "small",
isPlaygroundComponent = false,
}) => {
const classes = useStyles()
const imgHeight = imageSize === "small" ? 90 : 120
Expand Down Expand Up @@ -92,16 +103,23 @@ const ParamsForm: React.FC<Props> = ({
height={imgHeight}
className={classes.cover}
fallback="/assets/fallback.png"
alt={param.name}
/>
)}
<Input.TextArea
data-cy={`testview-input-parameters-${index}`}
key={index}
value={param.value}
placeholder={`${renameVariables(param.name)} (${type})`}
onChange={(e) => onParamChange?.(param.name, e.target.value)}
autoSize={{minRows: 2, maxRows: 8}}
/>
{isPlaygroundComponent ? (
<Input.TextArea
data-cy={`testview-input-parameters-${index}`}
key={index}
value={param.value}
placeholder={`${renameVariables(param.name)} (${type})`}
onChange={(e) =>
onParamChange?.(param.name, e.target.value)
}
autoSize={{minRows: 2, maxRows: 8}}
/>
) : (
<div className={classes.paramValueContainer}>{param.value}</div>
)}
</div>
</Form.Item>
)
Expand Down
1 change: 1 addition & 0 deletions agenta-web/src/components/Playground/Views/TestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const BoxComponent: React.FC<BoxComponentProps> = ({
onParamChange={onInputParamChange}
form={form}
imageSize="large"
isPlaygroundComponent={true}
/>
</Row>
{additionalData?.cost || additionalData?.latency ? (
Expand Down

0 comments on commit 83f02f9

Please sign in to comment.