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

Improve Dev Experience #2347

Merged
merged 8 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions web/src/app/admin/assistants/AssistantEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1184,20 +1184,16 @@ export function AssistantEditor({
/>
</div>

{isPaidEnterpriseFeaturesEnabled &&
userGroups &&
userGroups.length > 0 && (
<IsPublicGroupSelector
formikProps={{
values,
isSubmitting,
setFieldValue,
...formikProps,
}}
objectName="assistant"
enforceGroupSelection={false}
/>
)}
<IsPublicGroupSelector
formikProps={{
values,
isSubmitting,
setFieldValue,
...formikProps,
}}
objectName="assistant"
enforceGroupSelection={false}
/>
</>
)}

Expand Down
71 changes: 10 additions & 61 deletions web/src/app/admin/configuration/llm/CustomLLMProviderUpdateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { PopupSpec } from "@/components/admin/connectors/Popup";
import { usePaidEnterpriseFeaturesEnabled } from "@/components/settings/usePaidEnterpriseFeaturesEnabled";
import * as Yup from "yup";
import isEqual from "lodash/isEqual";
import { IsPublicGroupSelector } from "@/components/IsPublicGroupSelector";

function customConfigProcessing(customConfigsList: [string, string][]) {
const customConfig: { [key: string]: string } = {};
Expand Down Expand Up @@ -209,7 +210,7 @@ export function CustomLLMProviderUpdateForm({
setSubmitting(false);
}}
>
{({ values, setFieldValue }) => {
{(formikProps) => {
return (
<Form className="gap-y-6 mt-8">
<TextFormField
Expand Down Expand Up @@ -285,7 +286,7 @@ export function CustomLLMProviderUpdateForm({
name="custom_config_list"
render={(arrayHelpers: ArrayHelpers<any[]>) => (
<div>
{values.custom_config_list.map((_, index) => {
{formikProps.values.custom_config_list.map((_, index) => {
return (
<div
key={index}
Expand Down Expand Up @@ -371,7 +372,7 @@ export function CustomLLMProviderUpdateForm({
<TextArrayField
name="model_names"
label="Model Names"
values={values}
values={formikProps.values}
subtext={
<>
List the individual models that you want to make available as
Expand Down Expand Up @@ -419,64 +420,12 @@ export function CustomLLMProviderUpdateForm({
/>

{showAdvancedOptions && (
<>
{isPaidEnterpriseFeaturesEnabled && userGroups && (
<>
<BooleanFormField
small
removeIndent
alignTop
name="is_public"
label="Is Public?"
subtext="If set, this LLM Provider will be available to all users. If not, only the specified User Groups will be able to use it."
/>

{userGroups &&
userGroups.length > 0 &&
!values.is_public && (
<div>
<Text>
Select which User Groups should have access to this
LLM Provider.
</Text>
<div className="flex flex-wrap gap-2 mt-2">
{userGroups.map((userGroup) => {
const isSelected = values.groups.includes(
userGroup.id
);
return (
<Bubble
key={userGroup.id}
isSelected={isSelected}
onClick={() => {
if (isSelected) {
setFieldValue(
"groups",
values.groups.filter(
(id) => id !== userGroup.id
)
);
} else {
setFieldValue("groups", [
...values.groups,
userGroup.id,
]);
}
}}
>
<div className="flex">
<GroupsIcon />
<div className="ml-1">{userGroup.name}</div>
</div>
</Bubble>
);
})}
</div>
</div>
)}
</>
)}
</>
<IsPublicGroupSelector
formikProps={formikProps}
objectName="LLM Provider"
publicToWhom="all users"
enforceGroupSelection={true}
/>
)}

<div>
Expand Down
76 changes: 15 additions & 61 deletions web/src/app/admin/configuration/llm/LLMProviderUpdateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { PopupSpec } from "@/components/admin/connectors/Popup";
import { usePaidEnterpriseFeaturesEnabled } from "@/components/settings/usePaidEnterpriseFeaturesEnabled";
import * as Yup from "yup";
import isEqual from "lodash/isEqual";
import { IsPublicGroupSelector } from "@/components/IsPublicGroupSelector";

export function LLMProviderUpdateForm({
llmProviderDescriptor,
Expand Down Expand Up @@ -219,7 +220,7 @@ export function LLMProviderUpdateForm({
setSubmitting(false);
}}
>
{({ values, setFieldValue }) => (
{(formikProps) => (
<Form className="gap-y-4 items-stretch mt-6">
{!hideAdvanced && (
<TextFormField
Expand Down Expand Up @@ -337,7 +338,9 @@ export function LLMProviderUpdateForm({
{llmProviderDescriptor.llm_names.length > 0 && (
<div className="w-full">
<MultiSelectField
selectedInitially={values.display_model_names}
selectedInitially={
formikProps.values.display_model_names
}
name="display_model_names"
label="Display Models"
subtext="Select the models to make available to users. Unselected models will not be available."
Expand All @@ -348,70 +351,21 @@ export function LLMProviderUpdateForm({
})
)}
onChange={(selected) =>
setFieldValue("display_model_names", selected)
formikProps.setFieldValue(
"display_model_names",
selected
)
}
/>
</div>
)}

{isPaidEnterpriseFeaturesEnabled && userGroups && (
<>
<BooleanFormField
small
removeIndent
alignTop
name="is_public"
label="Is Public?"
subtext="If set, this LLM Provider will be available to all users. If not, only the specified User Groups will be able to use it."
/>

{userGroups &&
userGroups.length > 0 &&
!values.is_public && (
<div>
<Text>
Select which User Groups should have access to
this LLM Provider.
</Text>
<div className="flex flex-wrap gap-2 mt-2">
{userGroups.map((userGroup) => {
const isSelected = values.groups.includes(
userGroup.id
);
return (
<Bubble
key={userGroup.id}
isSelected={isSelected}
onClick={() => {
if (isSelected) {
setFieldValue(
"groups",
values.groups.filter(
(id) => id !== userGroup.id
)
);
} else {
setFieldValue("groups", [
...values.groups,
userGroup.id,
]);
}
}}
>
<div className="flex">
<GroupsIcon />
<div className="ml-1">
{userGroup.name}
</div>
</div>
</Bubble>
);
})}
</div>
</div>
)}
</>
)}
<IsPublicGroupSelector
formikProps={formikProps}
objectName="LLM Provider"
publicToWhom="all users"
enforceGroupSelection={true}
/>
</>
)}
</>
Expand Down
Loading
Loading