mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
fix(model_info_view.tsx): migrate to patch model updates
Enables changing model name easily
This commit is contained in:
parent
7d93fe6538
commit
9b223941f5
2 changed files with 47 additions and 2 deletions
|
@ -15,7 +15,7 @@ import {
|
||||||
} from "@tremor/react";
|
} from "@tremor/react";
|
||||||
import NumericalInput from "./shared/numerical_input";
|
import NumericalInput from "./shared/numerical_input";
|
||||||
import { ArrowLeftIcon, TrashIcon, KeyIcon } from "@heroicons/react/outline";
|
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 { Button, Form, Input, InputNumber, message, Select, Modal } from "antd";
|
||||||
import EditModelModal from "./edit_model/edit_model_modal";
|
import EditModelModal from "./edit_model/edit_model_modal";
|
||||||
import { handleEditModelSubmit } from "./edit_model/edit_model_modal";
|
import { handleEditModelSubmit } from "./edit_model/edit_model_modal";
|
||||||
|
@ -119,6 +119,8 @@ export default function ModelInfoView({
|
||||||
if (!accessToken) return;
|
if (!accessToken) return;
|
||||||
setIsSaving(true);
|
setIsSaving(true);
|
||||||
|
|
||||||
|
console.log("values.model_name, ", values.model_name);
|
||||||
|
|
||||||
let updatedLitellmParams = {
|
let updatedLitellmParams = {
|
||||||
...localModelData.litellm_params,
|
...localModelData.litellm_params,
|
||||||
model: values.litellm_model_name,
|
model: values.litellm_model_name,
|
||||||
|
@ -149,7 +151,7 @@ export default function ModelInfoView({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
await modelUpdateCall(accessToken, updateData);
|
await modelPatchUpdateCall(accessToken, updateData, modelId);
|
||||||
|
|
||||||
const updatedModelData = {
|
const updatedModelData = {
|
||||||
...localModelData,
|
...localModelData,
|
||||||
|
|
|
@ -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 (
|
export const modelUpdateCall = async (
|
||||||
accessToken: string,
|
accessToken: string,
|
||||||
formValues: Record<string, any> // Assuming formValues is an object
|
formValues: Record<string, any> // Assuming formValues is an object
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue