From 79c54256a042a350a3d2a7a9ea23c85e1e2200a3 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 29 Jan 2025 17:54:20 -0800 Subject: [PATCH] (UI) Allow using a model / credentials for pass through routes (#8099) * test_add_vertex_pass_through_deployment * VertexPassThroughRouter * fix use_in_pass_through * VertexPassThroughRouter * fix vertex_credentials * allow using _initialize_deployment_for_pass_through * test_add_vertex_pass_through_deployment * _set_default_vertex_config * fix verbose_proxy_logger * fix use_in_pass_through * fix _get_token_and_url * test_get_vertex_location_from_url * test_get_vertex_credentials_none * run pt unit testing again * fix add_vertex_credentials * test_adding_deployments.py * rename file * revert to og add model flow * move placement * ui somewhat working wildcard * separate out code for slecting model name * fix ConditionalPublicModelName * ui fix confitional render public model name * fix litellm model name page * fix advanced settings page page * ui fix litellm model name flow * adding pas through models ui * fix passing litellm params * ui fix advanced settings * ui fix order of provider info --- .../add_model/advanced_settings.tsx | 123 +++ .../conditional_public_model_name.tsx | 53 ++ .../add_model/litellm_model_name.tsx | 107 +++ .../src/components/model_dashboard.tsx | 793 +++++------------- .../src/components/provider_info_helpers.tsx | 2 +- 5 files changed, 511 insertions(+), 567 deletions(-) create mode 100644 ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx create mode 100644 ui/litellm-dashboard/src/components/add_model/conditional_public_model_name.tsx create mode 100644 ui/litellm-dashboard/src/components/add_model/litellm_model_name.tsx diff --git a/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx b/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx new file mode 100644 index 00000000000..f92b146b484 --- /dev/null +++ b/ui/litellm-dashboard/src/components/add_model/advanced_settings.tsx @@ -0,0 +1,123 @@ +import React from "react"; +import { Form, Switch } from "antd"; +import { Text, Button, Accordion, AccordionHeader, AccordionBody } from "@tremor/react"; +import { Row, Col, Typography, Card } from "antd"; +import TextArea from "antd/es/input/TextArea"; +const { Link } = Typography; + +interface AdvancedSettingsProps { + showAdvancedSettings: boolean; + setShowAdvancedSettings: (show: boolean) => void; +} + +const AdvancedSettings: React.FC = ({ + showAdvancedSettings, + setShowAdvancedSettings, +}) => { + const [form] = Form.useForm(); + + const handlePassThroughChange = (checked: boolean) => { + const currentParams = form.getFieldValue('litellm_extra_params'); + try { + let paramsObj = currentParams ? JSON.parse(currentParams) : {}; + if (checked) { + paramsObj.use_in_pass_through = true; + } else { + delete paramsObj.use_in_pass_through; + } + // Only set the field value if there are remaining parameters + if (Object.keys(paramsObj).length > 0) { + form.setFieldValue('litellm_extra_params', JSON.stringify(paramsObj, null, 2)); + } else { + form.setFieldValue('litellm_extra_params', ''); + } + } catch (error) { + // If JSON parsing fails, only create new object if checked is true + if (checked) { + form.setFieldValue('litellm_extra_params', JSON.stringify({ use_in_pass_through: true }, null, 2)); + } else { + form.setFieldValue('litellm_extra_params', ''); + } + } + }; + + return ( + <> + + + + + Advanced Settings + + +
+ + Allow using these credentials in pass through routes.{" "} + + Learn more + + + } + > + + + +