fix: custom models
This commit is contained in:
parent
edd2c4f6e9
commit
617149d731
@ -51,7 +51,7 @@ const EditChannel = () => {
|
|||||||
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
setInputs((inputs) => ({ ...inputs, [name]: value }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadChannel = async () => {
|
const loadChannel = async (modelOptions) => {
|
||||||
let res = await API.get(`/api/channel/${channelId}`);
|
let res = await API.get(`/api/channel/${channelId}`);
|
||||||
const { success, message, data } = res.data;
|
const { success, message, data } = res.data;
|
||||||
if (success) {
|
if (success) {
|
||||||
@ -60,13 +60,13 @@ const EditChannel = () => {
|
|||||||
} else {
|
} else {
|
||||||
data.models = data.models.split(',');
|
data.models = data.models.split(',');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
let localModelOptions = [...data.models];
|
let localModelOptions = [...modelOptions];
|
||||||
data.models.forEach((model) => {
|
data.models.forEach((model) => {
|
||||||
if (!localModelOptions.find((option) => option.key === model)) {
|
if (!localModelOptions.find((option) => option.key === model)) {
|
||||||
localModelOptions.push({
|
localModelOptions.push({
|
||||||
key: model,
|
key: model,
|
||||||
text: model,
|
text: model,
|
||||||
value: model
|
value: model,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -95,19 +95,23 @@ const EditChannel = () => {
|
|||||||
const fetchModels = async () => {
|
const fetchModels = async () => {
|
||||||
try {
|
try {
|
||||||
let res = await API.get(`/api/channel/models`);
|
let res = await API.get(`/api/channel/models`);
|
||||||
setModelOptions(
|
|
||||||
res.data.data.map((model) => ({
|
|
||||||
key: model.id,
|
|
||||||
text: model.id,
|
|
||||||
value: model.id,
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
setFullModels(res.data.data.map((model) => model.id));
|
setFullModels(res.data.data.map((model) => model.id));
|
||||||
setBasicModels(
|
setBasicModels(
|
||||||
res.data.data
|
res.data.data
|
||||||
.filter((model) => !model.id.startsWith('gpt-4'))
|
.filter((model) => !model.id.startsWith('gpt-4'))
|
||||||
.map((model) => model.id),
|
.map((model) => model.id),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const allModels = res.data.data.map((model) => ({
|
||||||
|
key: model.id,
|
||||||
|
text: model.id,
|
||||||
|
value: model.id,
|
||||||
|
}));
|
||||||
|
|
||||||
|
setModelOptions(allModels);
|
||||||
|
|
||||||
|
return allModels;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showError(error.message);
|
showError(error.message);
|
||||||
}
|
}
|
||||||
@ -128,12 +132,12 @@ const EditChannel = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(async () => {
|
||||||
|
const models = await fetchModels();
|
||||||
|
await fetchGroups();
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
loadChannel().then();
|
await loadChannel(models);
|
||||||
}
|
}
|
||||||
fetchModels().then();
|
|
||||||
fetchGroups().then();
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user