mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-16 05:53:42 +08:00
thay doi alibaba module mac dinh - chebichat
This commit is contained in:
@@ -64,8 +64,8 @@ export const DEFAULT_CONFIG = {
|
||||
models: DEFAULT_MODELS as any as LLMModel[],
|
||||
|
||||
modelConfig: {
|
||||
model: "gpt-4o-mini" as ModelType,
|
||||
providerName: "OpenAI" as ServiceProvider,
|
||||
model: "qwen-turbo" as ModelType,
|
||||
providerName: "Alibaba" as ServiceProvider,
|
||||
temperature: 0.5,
|
||||
top_p: 1,
|
||||
max_tokens: 4000,
|
||||
|
||||
@@ -65,32 +65,40 @@ export const useMaskStore = createPersistStore(
|
||||
|
||||
return masks[id];
|
||||
},
|
||||
// Hàm cập nhật một mask dựa trên id và một hàm updater
|
||||
updateMask(id: string, updater: (mask: Mask) => void) {
|
||||
const masks = get().masks;
|
||||
const mask = masks[id];
|
||||
if (!mask) return;
|
||||
const updateMask = { ...mask };
|
||||
updater(updateMask);
|
||||
masks[id] = updateMask;
|
||||
set(() => ({ masks }));
|
||||
get().markUpdate();
|
||||
const masks = get().masks; // Lấy danh sách các mask hiện tại
|
||||
const mask = masks[id]; // Lấy mask theo id
|
||||
if (!mask) return; // Nếu không tìm thấy thì thoát
|
||||
const updateMask = { ...mask }; // Tạo bản sao mask để cập nhật
|
||||
updater(updateMask); // Gọi hàm updater để chỉnh sửa mask
|
||||
masks[id] = updateMask; // Gán lại mask đã cập nhật vào danh sách
|
||||
set(() => ({ masks })); // Cập nhật lại state
|
||||
get().markUpdate(); // Đánh dấu đã cập nhật
|
||||
},
|
||||
// Hàm xóa một mask theo id
|
||||
delete(id: string) {
|
||||
const masks = get().masks;
|
||||
delete masks[id];
|
||||
set(() => ({ masks }));
|
||||
get().markUpdate();
|
||||
const masks = get().masks; // Lấy danh sách các mask hiện tại
|
||||
delete masks[id]; // Xóa mask theo id
|
||||
set(() => ({ masks })); // Cập nhật lại state
|
||||
get().markUpdate(); // Đánh dấu đã cập nhật
|
||||
},
|
||||
|
||||
// Hàm lấy một mask theo id (nếu không truyền id sẽ lấy id mặc định)
|
||||
get(id?: string) {
|
||||
return get().masks[id ?? 1145141919810];
|
||||
},
|
||||
|
||||
// Hàm lấy tất cả các mask (bao gồm cả mask người dùng và mask mặc định)
|
||||
getAll() {
|
||||
// Lấy danh sách mask của người dùng, sắp xếp theo thời gian tạo mới nhất
|
||||
const userMasks = Object.values(get().masks).sort(
|
||||
(a, b) => b.createdAt - a.createdAt,
|
||||
);
|
||||
const config = useAppConfig.getState();
|
||||
if (config.hideBuiltinMasks) return userMasks;
|
||||
const config = useAppConfig.getState(); // Lấy config hiện tại
|
||||
if (config.hideBuiltinMasks) return userMasks; // Nếu ẩn mask mặc định thì chỉ trả về mask người dùng
|
||||
|
||||
// Tạo danh sách mask mặc định (BUILTIN_MASKS) với cấu hình model hiện tại
|
||||
const buildinMasks = BUILTIN_MASKS.map(
|
||||
(m) =>
|
||||
({
|
||||
@@ -101,6 +109,7 @@ export const useMaskStore = createPersistStore(
|
||||
},
|
||||
}) as Mask,
|
||||
);
|
||||
// Trả về danh sách mask người dùng + mask mặc định
|
||||
return userMasks.concat(buildinMasks);
|
||||
},
|
||||
search(text: string) {
|
||||
|
||||
@@ -236,36 +236,38 @@ export const usePluginStore = createPersistStore(
|
||||
return;
|
||||
}
|
||||
|
||||
fetch("./plugins.json")
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
Promise.all(
|
||||
res.map((item: any) =>
|
||||
// skip get schema
|
||||
state.get(item.id)
|
||||
? item
|
||||
: fetch(item.schema)
|
||||
.then((res) => res.text())
|
||||
.then((content) => ({
|
||||
...item,
|
||||
content,
|
||||
}))
|
||||
.catch((e) => item),
|
||||
),
|
||||
).then((builtinPlugins: any) => {
|
||||
builtinPlugins
|
||||
.filter((item: any) => item?.content)
|
||||
.forEach((item: any) => {
|
||||
const plugin = state.create(item);
|
||||
state.updatePlugin(plugin.id, (plugin) => {
|
||||
const tool = FunctionToolService.add(plugin, true);
|
||||
plugin.title = tool.api.definition.info.title;
|
||||
plugin.version = tool.api.definition.info.version;
|
||||
plugin.builtin = true;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
// fetch("./plugins.json")
|
||||
// .then((res) => res.json())
|
||||
// .then((res) => {
|
||||
// Promise.all(
|
||||
// res.map((item: any) =>
|
||||
// // skip get schema
|
||||
// state.get(item.id)
|
||||
// ? item
|
||||
// : fetch(item.schema)
|
||||
// .then((res) => res.text())
|
||||
// .then((content) => ({
|
||||
// ...item,
|
||||
// content,
|
||||
// }))
|
||||
// .catch((e) => item),
|
||||
// ),
|
||||
// ).then((builtinPlugins: any) => {
|
||||
|
||||
// // builtinPlugins
|
||||
// // .filter((item: any) => item?.content)
|
||||
// // .forEach((item: any) => {
|
||||
// // const plugin = state.create(item);
|
||||
// // state.updatePlugin(plugin.id, (plugin) => {
|
||||
// // const tool = FunctionToolService.add(plugin, true);
|
||||
// // plugin.title = tool.api.definition.info.title;
|
||||
// // plugin.version = tool.api.definition.info.version;
|
||||
// // plugin.builtin = true;
|
||||
// // });
|
||||
// // });
|
||||
// });
|
||||
|
||||
// });
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user