mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
(feat) enter key description on ui
This commit is contained in:
parent
bcd36865d9
commit
644c55d41c
1 changed files with 16 additions and 0 deletions
|
@ -14,15 +14,31 @@ export const keyCreateCall = async (
|
||||||
try {
|
try {
|
||||||
console.log("Form Values in keyCreateCall:", formValues); // Log the form values before making the API call
|
console.log("Form Values in keyCreateCall:", formValues); // Log the form values before making the API call
|
||||||
|
|
||||||
|
// check if formValues.description is not undefined, make it a string and add it to formValues.metadata
|
||||||
|
if (formValues.description) {
|
||||||
|
// add to formValues.metadata
|
||||||
|
if (!formValues.metadata) {
|
||||||
|
formValues.metadata = {}
|
||||||
|
}
|
||||||
|
// value needs to be in "", valid JSON
|
||||||
|
formValues.metadata.description = formValues.description;
|
||||||
|
// remove descrption from formValues
|
||||||
|
delete formValues.description;
|
||||||
|
formValues.metadata = JSON.stringify(formValues.metadata);
|
||||||
|
}
|
||||||
// if formValues.metadata is not undefined, make it a valid dict
|
// if formValues.metadata is not undefined, make it a valid dict
|
||||||
if (formValues.metadata) {
|
if (formValues.metadata) {
|
||||||
|
console.log("formValues.metadata:", formValues.metadata);
|
||||||
// if there's an exception JSON.parse, show it in the message
|
// if there's an exception JSON.parse, show it in the message
|
||||||
try {
|
try {
|
||||||
formValues.metadata = JSON.parse(formValues.metadata);
|
formValues.metadata = JSON.parse(formValues.metadata);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error("Failed to parse metadata: " + error);
|
message.error("Failed to parse metadata: " + error);
|
||||||
|
throw new Error("Failed to parse metadata: " + error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("Form Values after check:", formValues);
|
||||||
const url = proxyBaseUrl ? `${proxyBaseUrl}/key/generate` : `/key/generate`;
|
const url = proxyBaseUrl ? `${proxyBaseUrl}/key/generate` : `/key/generate`;
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue