Skip to content

Commit

Permalink
chore: hardcode list of sensitive model provider fields
Browse files Browse the repository at this point in the history
Determines which fields should be displayed as passwords when configuring a model provider

Signed-off-by: Craig Jellick <[email protected]>
  • Loading branch information
ryanhopperlowe authored and cjellick committed Dec 9, 2024
1 parent fdb8473 commit dc34358
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 19 deletions.
47 changes: 28 additions & 19 deletions ui/admin/app/components/model-providers/ModelProviderForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { ControlledInput } from "~/components/form/controlledInputs";
import {
ModelProviderConfigurationLinks,
ModelProviderRequiredTooltips,
ModelProviderSensitiveFields,
} from "~/components/model-providers/constants";
import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert";
import { Button } from "~/components/ui/button";
Expand Down Expand Up @@ -211,26 +212,34 @@ export function ModelProviderForm({
className="flex flex-col gap-4"
>
{requiredConfigParamFields.fields.map(
(field, i) => (
<div
key={field.id}
className="flex gap-2 items-center justify-center"
>
<ControlledInput
(field, i) => {
const type = ModelProviderSensitiveFields[
field.name
]
? "password"
: "text";

return (
<div
key={field.id}
label={renderLabelWithTooltip(
field.label
)}
control={form.control}
name={`requiredConfigParams.${i}.value`}
type="password"
classNames={{
wrapper:
"flex-auto bg-background",
}}
/>
</div>
)
className="flex gap-2 items-center justify-center"
>
<ControlledInput
key={field.id}
label={renderLabelWithTooltip(
field.label
)}
control={form.control}
name={`requiredConfigParams.${i}.value`}
type={type}
classNames={{
wrapper:
"flex-auto bg-background",
}}
/>
</div>
);
}
)}
</form>
</Form>
Expand Down
20 changes: 20 additions & 0 deletions ui/admin/app/components/model-providers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,23 @@ export const ModelProviderRequiredTooltips: {
"Container that holds related Azure resources. Can typically be found in Azure Portal > Resource Groups > [OpenAI Resource Group] > Overview",
},
};

export const ModelProviderSensitiveFields: Record<string, boolean | undefined> =
{
// OpenAI
OTTO8_OPENAI_MODEL_PROVIDER_API_KEY: true,

// Azure OpenAI
OTTO8_AZURE_OPENAI_MODEL_PROVIDER_ENDPOINT: false,
OTTO8_AZURE_OPENAI_MODEL_PROVIDER_CLIENT_ID: false,
OTTO8_AZURE_OPENAI_MODEL_PROVIDER_CLIENT_SECRET: true,
OTTO8_AZURE_OPENAI_MODEL_PROVIDER_TENANT_ID: false,
OTTO8_AZURE_OPENAI_MODEL_PROVIDER_SUBSCRIPTION_ID: false,
OTTO8_AZURE_OPENAI_MODEL_PROVIDER_RESOURCE_GROUP: false,

// Anthropic
OTTO8_ANTHROPIC_MODEL_PROVIDER_API_KEY: true,

// Voyage
OTTO8_VOYAGE_MODEL_PROVIDER_API_KEY: true,
};

0 comments on commit dc34358

Please sign in to comment.