Skip to content

Commit

Permalink
Merge pull request #3436 from quantified-uncertainty/ai-touchups
Browse files Browse the repository at this point in the history
Improved AI sidebar, form fields when invalid
  • Loading branch information
OAGr authored Nov 13, 2024
2 parents f48748b + ac326ab commit f4b8611
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 10 additions & 6 deletions packages/hub/src/app/ai/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";

import _ from "lodash";
import {
forwardRef,
useEffect,
Expand Down Expand Up @@ -96,21 +97,23 @@ Outputs:

const handleSubmit = form.handleSubmit(
async ({ prompt, squiggleCode, model, numericSteps, styleGuideSteps }) => {
const numericStepsNumber = _.toNumber(numericSteps) || 0;
const styleGuideStepsNumber = _.toNumber(styleGuideSteps) || 0;
const requestBody: AiRequestBody =
mode === "create"
? {
kind: "create",
prompt,
model: model as LlmId,
numericSteps,
styleGuideSteps,
numericSteps: numericStepsNumber,
styleGuideSteps: styleGuideStepsNumber,
}
: {
kind: "edit",
squiggleCode,
model: model as LlmId,
numericSteps,
styleGuideSteps,
numericSteps: numericStepsNumber,
styleGuideSteps: styleGuideStepsNumber,
};

submitWorkflow(requestBody);
Expand Down Expand Up @@ -163,8 +166,9 @@ Outputs:
name="squiggleCode"
label="Squiggle Code"
placeholder="Enter your Squiggle code here"
rows={12}
minRows={12}
rows={8}
minRows={6}
maxRows={20}
/>
</StyledTab.Panel>
</StyledTab.Panels>
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/src/forms/fields/TextAreaFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export function TextAreaFormField<
placeholder,
rows,
minRows,
maxRows,
...fieldProps
}: CommonStringFieldProps<TValues, TName> &
Pick<StyledTextAreaProps, "placeholder" | "rows" | "minRows">) {
Pick<StyledTextAreaProps, "placeholder" | "rows" | "minRows" | "maxRows">) {
return (
<FormField {...fieldProps}>
{(inputProps) => (
Expand All @@ -28,6 +29,7 @@ export function TextAreaFormField<
placeholder={placeholder}
rows={rows}
minRows={minRows}
maxRows={maxRows}
/>
)}
</FormField>
Expand Down

0 comments on commit f4b8611

Please sign in to comment.