fix(model_info_view.tsx): migrate to patch model updates

Enables changing model name easily
This commit is contained in:
Krrish Dholakia 2025-04-23 15:36:38 -07:00
parent 7d93fe6538
commit 9b223941f5
2 changed files with 47 additions and 2 deletions

View file

@ -15,7 +15,7 @@ import {
} from "@tremor/react";
import NumericalInput from "./shared/numerical_input";
import { ArrowLeftIcon, TrashIcon, KeyIcon } from "@heroicons/react/outline";
import { modelDeleteCall, modelUpdateCall, CredentialItem, credentialGetCall, credentialCreateCall, modelInfoCall, modelInfoV1Call } from "./networking";
import { modelDeleteCall, modelUpdateCall, CredentialItem, credentialGetCall, credentialCreateCall, modelInfoCall, modelInfoV1Call, modelPatchUpdateCall } from "./networking";
import { Button, Form, Input, InputNumber, message, Select, Modal } from "antd";
import EditModelModal from "./edit_model/edit_model_modal";
import { handleEditModelSubmit } from "./edit_model/edit_model_modal";
@ -118,6 +118,8 @@ export default function ModelInfoView({
try {
if (!accessToken) return;
setIsSaving(true);
console.log("values.model_name, ", values.model_name);
let updatedLitellmParams = {
...localModelData.litellm_params,
@ -149,7 +151,7 @@ export default function ModelInfoView({
}
};
await modelUpdateCall(accessToken, updateData);
await modelPatchUpdateCall(accessToken, updateData, modelId);
const updatedModelData = {
...localModelData,

View file

@ -3149,6 +3149,49 @@ export const teamUpdateCall = async (
}
};
/**
* Patch update a model
*
* @param accessToken
* @param formValues
* @returns
*/
export const modelPatchUpdateCall = async (
accessToken: string,
formValues: Record<string, any>, // Assuming formValues is an object
modelId: string
) => {
try {
console.log("Form Values in modelUpateCall:", formValues); // Log the form values before making the API call
const url = proxyBaseUrl ? `${proxyBaseUrl}/model/${modelId}/update` : `/model/${modelId}/update`;
const response = await fetch(url, {
method: "PATCH",
headers: {
[globalLitellmHeaderName]: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
...formValues, // Include formValues in the request body
}),
});
if (!response.ok) {
const errorData = await response.text();
handleError(errorData);
console.error("Error update from the server:", errorData);
throw new Error("Network response was not ok");
}
const data = await response.json();
console.log("Update model Response:", data);
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
console.error("Failed to update model:", error);
throw error;
}
};
export const modelUpdateCall = async (
accessToken: string,
formValues: Record<string, any> // Assuming formValues is an object