From dc343582d8fca52bc07be0691ae8067bc176d0ac Mon Sep 17 00:00:00 2001 From: Ryan Hopper-Lowe Date: Sun, 8 Dec 2024 00:45:53 -0600 Subject: [PATCH] chore: hardcode list of sensitive model provider fields Determines which fields should be displayed as passwords when configuring a model provider Signed-off-by: Craig Jellick --- .../model-providers/ModelProviderForm.tsx | 47 +++++++++++-------- .../components/model-providers/constants.ts | 20 ++++++++ 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/ui/admin/app/components/model-providers/ModelProviderForm.tsx b/ui/admin/app/components/model-providers/ModelProviderForm.tsx index cdbb6559..fffcc716 100644 --- a/ui/admin/app/components/model-providers/ModelProviderForm.tsx +++ b/ui/admin/app/components/model-providers/ModelProviderForm.tsx @@ -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"; @@ -211,26 +212,34 @@ export function ModelProviderForm({ className="flex flex-col gap-4" > {requiredConfigParamFields.fields.map( - (field, i) => ( -
- { + const type = ModelProviderSensitiveFields[ + field.name + ] + ? "password" + : "text"; + + return ( +
-
- ) + className="flex gap-2 items-center justify-center" + > + +
+ ); + } )} diff --git a/ui/admin/app/components/model-providers/constants.ts b/ui/admin/app/components/model-providers/constants.ts index ee402be4..74839cc6 100644 --- a/ui/admin/app/components/model-providers/constants.ts +++ b/ui/admin/app/components/model-providers/constants.ts @@ -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 = + { + // 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, + };