Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

use prepareModelAddRequest

Ishaan Jaff33c85825def3
diff --git a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx
index 0fa08e48af3..4a19653a6ab 100644
--- a/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx
+++ b/ui/litellm-dashboard/src/components/add_model/handle_add_model_submit.tsx
@@ -3,11 +3,10 @@ import { provider_map, Providers } from "../provider_info_helpers";
import { modelCreateCall, Model } from "../networking";
-export const handleAddModelSubmit = async (
+export const prepareModelAddRequest = async (
formValues: Record<string, any>,
accessToken: string,
form: any,
- callback?: ()=>void
) => {
try {
console.log("handling submit for formValues:", formValues);
@@ -135,20 +134,45 @@ export const handleAddModelSubmit = async (
litellmParamsObj[key] = value;
}
}
-
- const new_model: Model = {
- model_name: modelName,
- litellm_params: litellmParamsObj,
- model_info: modelInfoObj,
- };
-
- const response: any = await modelCreateCall(accessToken, new_model);
- console.log(`response for model create call: ${response["data"]}`);
+
+ return { litellmParamsObj, modelInfoObj, modelName };
}
+ } catch (error) {
+ message.error("Failed to create model: " + error, 10);
+ }
+ };
- callback && callback()
+export const handleAddModelSubmit = async (
+ accessToken: string,
+ form: any,
+ callback?: () => void,
+ ) => {
+ try {
+ const formValues = form.getFieldsValue();
+ const result = await prepareModelAddRequest(formValues, accessToken, form);
+
+ if (!result) {
+ return; // Exit if preparation failed
+ }
+
+ const { litellmParamsObj, modelInfoObj, modelName } = result;
+
+ const new_model: Model = {
+ model_name: modelName,
+ litellm_params: litellmParamsObj,
+ model_info: modelInfoObj,
+ };
+
+ const response: any = await modelCreateCall(accessToken, new_model);
+ console.log(`response for model create call: ${response["data"]}`);
+
+ callback && callback();
form.resetFields();
+
+ message.success("Model added successfully");
} catch (error) {
- message.error("Failed to create model: " + error, 10);
+ message.error("Failed to add model: " + error, 10);
}
- };
\ No newline at end of file
+ };
+
+