-
Notifications
You must be signed in to change notification settings - Fork 301
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: Show invocation param errors within form #5559
feat: Show invocation param errors within form #5559
Conversation
@@ -1,22 +1,19 @@ | |||
import React, { useCallback } from "react"; | |||
import { graphql, useLazyLoadQuery } from "react-relay"; | |||
import React, { useCallback, useLayoutEffect, useMemo } from "react"; |
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.
Large but relevant diff
@@ -46,7 +61,7 @@ const InvocationParameterFormField = ({ | |||
<Slider | |||
label={field.label} | |||
isRequired={field.required} | |||
value={value} | |||
defaultValue={value} |
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.
why no controller around the slider?
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 am just using controller to map errors to inputs, sliders can't have errors so I didn't see the point
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.
sounds good, if it's low lift i might add it but yeah not necessary
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 isn't a possible error a slider can have since the value range is always constrained. I'm not sure what we could add to it
const existingParameter = instanceInvocationParameters.find((p) => | ||
areInvocationParamsEqual(p, field) | ||
); | ||
const value = existingParameter | ||
? getInvocationParameterValue(field, existingParameter) | ||
: undefined; | ||
return { | ||
[field.invocationName!]: value ?? null, | ||
}; |
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.
does this get defaults values from the server? I was working in this before i left and was running into issues here. It looks like we won't get the default no matter what 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.
the default will be merged into the store whenever model/provider is chosen. The only time you will lose the default value is if you manually edit/delete it
Couple of issues i noticed
Screen.Recording.2024-12-02.at.11.35.16.AM.mov
Screen.Recording.2024-12-02.at.11.37.10.AM.mov |
This involved a decently large refactor of InvocationParametersFormFields: - Remove redundant gql query, just load definitions from store after they are populated via ModelSupportedParametersFetcher - Update onChange to use referentially stable callbacks only, computations occur in store instead of inside of useCallback now - Memoize invocation parameter value mapping - Introduce react hook form, mirroring values and validating them - Wrap all form inputs in react hook form controllers, adding validation and passing through error messages - Fix controlled/uncontrolled warning in AzureOpenAiModelConfigFormField
Form values stay in-tact when model changes, unless that model has different parameter fields
4c54856
to
5641a64
Compare
This involved a decently large refactor of InvocationParametersFormFields:
Resolves #5540
Resolves #5546