From 601f9c09ef03090fbeb98d95ce00ac07b660b435 Mon Sep 17 00:00:00 2001 From: godo Date: Tue, 26 Nov 2024 11:31:08 +0800 Subject: [PATCH] change ai --- frontend/src/components/ai/DownAddbox.vue | 66 ++++++----- .../src/components/ai/DownLabeleditor.vue | 84 +++++--------- frontend/src/components/ai/DownModelInfo.vue | 4 +- frontend/src/components/ai/aimodel.vue | 25 ++-- frontend/src/components/ai/aisetting.vue | 16 ++- .../src/components/localchat/ChatDomain.vue | 4 +- frontend/src/components/localchat/ChatNav.vue | 15 +-- frontend/src/hook/useAi.ts | 1 + frontend/src/i18n/lang/en.json | 1 + frontend/src/i18n/lang/zh.json | 14 +-- frontend/src/stores/labels/bgereranker.ts | 25 ++++ frontend/src/stores/labels/index.ts | 2 + frontend/src/stores/labels/qwen.ts | 96 ++++++++++++++++ frontend/src/stores/localchat.ts | 5 - frontend/src/stores/model.ts | 17 ++- frontend/src/stores/modelconfig.ts | 34 +++--- frontend/src/system/config.ts | 26 ++++- godo/model/api/gitee.go | 23 ++++ godo/model/api/openai.go | 30 +++++ godo/model/convert.go | 42 ------- godo/model/down.go | 2 +- godo/model/libs.go | 40 +++---- godo/model/{op.go => ollama.go} | 108 ++++++------------ godo/model/server.go | 61 ++++++++++ godo/sys/setting.go | 20 +++- 25 files changed, 466 insertions(+), 295 deletions(-) create mode 100644 frontend/src/stores/labels/bgereranker.ts create mode 100644 godo/model/api/gitee.go create mode 100644 godo/model/api/openai.go delete mode 100644 godo/model/convert.go rename godo/model/{op.go => ollama.go} (84%) diff --git a/frontend/src/components/ai/DownAddbox.vue b/frontend/src/components/ai/DownAddbox.vue index 2220ded..73225ba 100644 --- a/frontend/src/components/ai/DownAddbox.vue +++ b/frontend/src/components/ai/DownAddbox.vue @@ -6,10 +6,10 @@ import { t } from "@/i18n/index"; const modelStore = useModelStore(); const formInit = { - model: "", labelId: "", ip: "", info: { + model: "", url: "", from: "ollama", file_name: "", @@ -86,7 +86,7 @@ async function getLocalModel() { } function setLocalInfo() { let modelData: any = localModels.value.find((item: any) => { - return item.model === formData.value.model; + return item.model === formData.value.info.model; }); if (!modelData) { notifyError(t('model.invalidModel')); @@ -116,42 +116,46 @@ async function download() { return; } - if (saveData.from == "ollama") { - if (saveData.model == "") { + if (saveData.info.from == "ollama") { + if (saveData.info.model == "") { notifyError(t('model.labelNameEmpty')); return; } - if (saveData.model.indexOf(":") === -1) { - saveData.model = saveData.model + ":latest"; + if (saveData.info.model.indexOf(":") === -1) { + saveData.info.model = saveData.info.model + ":latest"; } + if (saveData.info.url == "") { + saveData.info.url = [] + } + saveData.info.context_length = 1024 } - if (saveData.from == "local") { - if (!saveData.url || saveData.url.length == 0) { + if (saveData.info.from == "local") { + if (!saveData.info.url || saveData.info.url.length == 0) { notifyError(t('model.invalidModel')); return; } } - if (saveData.from == "network") { - if (isNaN(saveData.context_length) || saveData.context_length < 1) { + if (saveData.info.from == "network") { + if (isNaN(saveData.context_length) || saveData.info.context_length < 1) { notifyError(t('model.invalidContextLength')); return; } - saveData.context_length = saveData.context_length * 1; + saveData.info.context_length = saveData.info.context_length * 1; - if (saveData.url == "") { + if (saveData.info.url == "") { notifyError(t('model.invalidModelUrl')); return; } - if (saveData.url != "" && typeof saveData.url === "string") { - saveData.url = saveData.url.split("\n"); + if (saveData.info.url != "" && typeof saveData.url === "string") { + saveData.info.url = saveData.info.url.split("\n"); } else { - saveData.url = []; + saveData.info.url = []; } if (saveData.engine == "ollama") { - saveData.type = 'llm' - saveData.params = { + saveData.type = 'local' + saveData.info.params = { top_p: 0.95, stream: true, num_keep: 5, @@ -160,18 +164,18 @@ async function download() { temperature: 0.7, }; - if (saveData.parameters != "" && typeof saveData.parameters === "string") { - saveData.parameters = saveData.parameters.split("\n"); + if (saveData.info.parameters != "" && typeof saveData.info.parameters === "string") { + saveData.info.parameters = saveData.info.parameters.split("\n"); } else { - saveData.parameters = []; + saveData.info.parameters = []; } - saveData.info = { - quant: saveData.quant, - context_length: saveData.context_length, - template: saveData.template, - parameters: saveData.parameters, - pb: saveData.pb.toUpperCase(), - }; + // saveData.info = { + // quant: saveData.quant, + // context_length: saveData.context_length, + // template: saveData.template, + // parameters: saveData.parameters, + // pb: saveData.pb.toUpperCase(), + // }; const lowerName = saveData.info.pb.replace("B", "") * 1; if (lowerName < 3) { saveData.info.cpu = "8GB"; @@ -184,8 +188,8 @@ async function download() { saveData.info.cpu = "32GB"; saveData.info.gpu = "12GB"; } - if (saveData.model.indexOf(":") === -1) { - saveData.model = saveData.model + ":latest"; + if (saveData.info.model.indexOf(":") === -1) { + saveData.info.model = saveData.info.model + ":latest"; } } } @@ -211,7 +215,7 @@ async function download() { - @@ -221,7 +225,7 @@ async function download() { @blur="getLocalModel"> - + diff --git a/frontend/src/components/ai/DownLabeleditor.vue b/frontend/src/components/ai/DownLabeleditor.vue index 6e59a35..5da7a07 100644 --- a/frontend/src/components/ai/DownLabeleditor.vue +++ b/frontend/src/components/ai/DownLabeleditor.vue @@ -1,55 +1,55 @@