|
|
@@ -0,0 +1,444 @@
|
|
|
+<template>
|
|
|
+ <div class="model-body">
|
|
|
+ <div class="body-item">
|
|
|
+ <div class="item-title">
|
|
|
+ <div class="title">{{ $t('management.addedModel') }}</div>
|
|
|
+ <div class="icon" @click="changeStatusAdd">
|
|
|
+ <template v-if="added_show_status"> {{ $t('management.upBtn') }} <icon-up /> </template>
|
|
|
+ <template v-if="!added_show_status"> {{ $t('management.downBtn') }} <icon-down /> </template>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <transition name="expand-collapse" @before-enter="beforeEnter" @enter="enter" @leave="leave">
|
|
|
+ <div v-if="added_show_status">
|
|
|
+ <ModelList
|
|
|
+ v-for="(item, idx) in dify_added_data"
|
|
|
+ :key="idx"
|
|
|
+ :model_item="item"
|
|
|
+ :model_name="item.label.en_US"
|
|
|
+ @showMore="showMoreModel"
|
|
|
+ @updateAddModelDify="updateModelList"
|
|
|
+ @toAddModel="toAddModel"
|
|
|
+ >{{ (key, index) }}</ModelList
|
|
|
+ >
|
|
|
+ <a-empty v-if="!dify_added_data.length" class="empty-list"></a-empty>
|
|
|
+ </div>
|
|
|
+ </transition>
|
|
|
+ </div>
|
|
|
+ <div class="body-item">
|
|
|
+ <div class="item-title">
|
|
|
+ <div class="title">{{ $t('management.unaddModel') }}</div>
|
|
|
+ <div class="icon" @click="changeStatusUnAdd">
|
|
|
+ <template v-if="unadd_show_status"> {{ $t('management.upBtn') }} <icon-up /> </template>
|
|
|
+ <template v-if="!unadd_show_status"> {{ $t('management.downBtn') }} <icon-down /> </template>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <transition name="expand-collapse" @before-enter="beforeEnter" @enter="enter" @leave="leave">
|
|
|
+ <div v-if="unadd_show_status" class="card-list">
|
|
|
+ <CardItem
|
|
|
+ v-for="item in dify_unadded_data"
|
|
|
+ :key="item.id"
|
|
|
+ :name="item.label.en_US"
|
|
|
+ :img_src="item.img_src"
|
|
|
+ is_model
|
|
|
+ >
|
|
|
+ <template #labels>
|
|
|
+ <div class="labels">{{ item.supported_model_types.join(',') }}</div>
|
|
|
+ </template>
|
|
|
+ <template #description>
|
|
|
+ <div class="desc">{{ item.description && item.description.zh_Hans }}</div>
|
|
|
+ </template>
|
|
|
+ <template #bottom>
|
|
|
+ <a-button @click="handleAddModel(item)">
|
|
|
+ <template #icon> <icon-plus /> </template>{{ $t('management.addModelBtn') }}</a-button
|
|
|
+ ></template
|
|
|
+ >
|
|
|
+ </CardItem>
|
|
|
+ </div>
|
|
|
+ </transition>
|
|
|
+ <a-empty v-if="!dify_unadded_data.length" class="empty-list"></a-empty>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <ModalAdd_1
|
|
|
+ v-if="show_Xinference_model"
|
|
|
+ :show_modal="show_Xinference_model"
|
|
|
+ :model_data="Xinference_data"
|
|
|
+ @difyClose="closeXinference"
|
|
|
+ @updateModelList="updateModelList"
|
|
|
+ ></ModalAdd_1>
|
|
|
+ <ModalAdd_2
|
|
|
+ v-if="show_Openai_model"
|
|
|
+ :show_modal="show_Openai_model"
|
|
|
+ :model_data="Openai_data"
|
|
|
+ @difyClose="closeOpenAi"
|
|
|
+ @updateModelList="updateModelList"
|
|
|
+ ></ModalAdd_2>
|
|
|
+ <ModalAdd_3
|
|
|
+ v-if="show_Openai_api_compatible"
|
|
|
+ :show_modal="show_Openai_api_compatible"
|
|
|
+ :model_data="Openai_api_compatible_data"
|
|
|
+ @difyClose="closeOpenAiComatible"
|
|
|
+ @updateModelList="updateModelList"
|
|
|
+ ></ModalAdd_3>
|
|
|
+ <ModalAdd_4
|
|
|
+ v-if="show_Huggingface"
|
|
|
+ :show_modal="show_Huggingface"
|
|
|
+ :model_data="Huggingface_data"
|
|
|
+ @difyClose="closeHuggingface"
|
|
|
+ @updateModelList="updateModelList"
|
|
|
+ ></ModalAdd_4>
|
|
|
+ <ModalAdd_5
|
|
|
+ v-if="show_Ollama"
|
|
|
+ :show_modal="show_Ollama"
|
|
|
+ :model_data="Ollama_data"
|
|
|
+ @difyClose="closeOllama"
|
|
|
+ @updateModelList="updateModelList"
|
|
|
+ ></ModalAdd_5>
|
|
|
+ <ModalAdd_6
|
|
|
+ v-if="show_deepseek"
|
|
|
+ :show_modal="show_deepseek"
|
|
|
+ :model_data="Deepseek_data"
|
|
|
+ @difyClose="closeDeepseek"
|
|
|
+ @updateModelList="updateModelList"
|
|
|
+ ></ModalAdd_6>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { ref, onMounted } from 'vue';
|
|
|
+import ModelList from './ModelList.vue';
|
|
|
+import CardItem from '../../common/CardItem.vue';
|
|
|
+import { useCollapse } from '../use-collapse';
|
|
|
+import { getAddedModelsRG, getUnaddedModelsDIFY, getAddModelChild } from '../../../apis/rgflow-dify';
|
|
|
+import ModalAdd_1 from './ModalAdd_1.vue';
|
|
|
+import ModalAdd_2 from './ModalAdd_2.vue';
|
|
|
+import ModalAdd_3 from './ModalAdd_3.vue';
|
|
|
+import ModalAdd_4 from './ModalAdd_4.vue';
|
|
|
+import ModalAdd_5 from './ModalAdd_5.vue';
|
|
|
+import ModalAdd_6 from './ModalAdd_6.vue';
|
|
|
+
|
|
|
+const { beforeEnter, enter, leave } = useCollapse(1000);
|
|
|
+
|
|
|
+const added_data = ref([
|
|
|
+ // {
|
|
|
+ // id: '1',
|
|
|
+ // name: 'OpenAl-APl-Compatible',
|
|
|
+ // desc: 'LLM,TEXT EMBEDDING,SPEECH2TEXT,MODERATION ',
|
|
|
+ // img_src: 'modelFrame1',
|
|
|
+ // show_more: false,
|
|
|
+ // models: [
|
|
|
+ // {
|
|
|
+ // id: '1-1',
|
|
|
+ // name: 'qwen-2.5-72b-instruct OpenAl-APl'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // id: '1-2',
|
|
|
+ // name: 'qwen-2.5-72b-instruct-gptq-int4 OpenAI-API'
|
|
|
+ // }
|
|
|
+ // ]
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // id: '2',
|
|
|
+ // name: 'Tongyi-Qianwen',
|
|
|
+ // desc: 'LLM,TEXT EMBEDDING,SPEECH2TEXT,MODERATION',
|
|
|
+ // img_src: 'modelFrame2',
|
|
|
+ // show_more: false,
|
|
|
+ // models: [
|
|
|
+ // {
|
|
|
+ // id: '2-1',
|
|
|
+ // name: 'qwen-plus'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // id: '2-2',
|
|
|
+ // name: 'qwen-turbo'
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // id: '2-3',
|
|
|
+ // name: 'qwen-vl-plus'
|
|
|
+ // }
|
|
|
+ // ]
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // id: '3',
|
|
|
+ // name: 'Xinference',
|
|
|
+ // desc: 'LLM,TEXT EMBEDDING,SPEECH2TEXT,MODERATION,TEXT RE-RANK',
|
|
|
+ // img_src: 'modelFrame3',
|
|
|
+ // show_more: false,
|
|
|
+ // models: [
|
|
|
+ // {
|
|
|
+ // id: '3-1',
|
|
|
+ // name: 'basic-bge-large-zh-v1.5'
|
|
|
+ // }
|
|
|
+ // ]
|
|
|
+ // }
|
|
|
+]);
|
|
|
+const un_added_data = ref([
|
|
|
+ {
|
|
|
+ id: '1',
|
|
|
+ name: 'OpenAl',
|
|
|
+ keyword: 'LLM,TEXT',
|
|
|
+ desc: 'EMBEDDING,SPEECH2TEXT,MODERATION',
|
|
|
+ img_src: 'modelFrame4'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: '2',
|
|
|
+ name: 'Moonshot',
|
|
|
+ keyword: 'LLM,TEXT EMBEDDING',
|
|
|
+ desc: '',
|
|
|
+ img_src: 'modelFrame5'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: '3',
|
|
|
+ name: 'ZHIPU-AI',
|
|
|
+ keyword: 'LLM,TEXT',
|
|
|
+ desc: 'EMBEDDING,SPEECH2TEXT,MODERATION',
|
|
|
+ img_src: 'modelFrame6'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: '4',
|
|
|
+ name: 'BaiChuan',
|
|
|
+ keyword: 'LLM,TEXT EMBEDDING',
|
|
|
+ desc: '',
|
|
|
+ img_src: 'modelFrame7'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: '5',
|
|
|
+ name: 'DeepSeek',
|
|
|
+ keyword: 'LLM',
|
|
|
+ desc: '',
|
|
|
+ img_src: 'modelFrame8'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: '6',
|
|
|
+ name: 'Mistral',
|
|
|
+ keyword: 'LLM,TEXT EMBEDDING',
|
|
|
+ desc: '',
|
|
|
+ img_src: 'modelFrame9'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: '7',
|
|
|
+ name: 'StepFun',
|
|
|
+ keyword: 'LLM',
|
|
|
+ desc: '',
|
|
|
+ img_src: 'modelFrame10'
|
|
|
+ }
|
|
|
+]);
|
|
|
+const dify_added_data = ref({});
|
|
|
+const dify_unadded_data = ref([]);
|
|
|
+const dify_all_data = ref([]);
|
|
|
+// 展开收起状态
|
|
|
+const added_show_status = ref(true);
|
|
|
+const unadd_show_status = ref(true);
|
|
|
+
|
|
|
+const show_Xinference_model = ref(false);
|
|
|
+const Xinference_data = ref({});
|
|
|
+
|
|
|
+const show_Openai_api_compatible = ref(false);
|
|
|
+const Openai_api_compatible_data = ref({});
|
|
|
+
|
|
|
+const show_Openai_model = ref(false);
|
|
|
+const Openai_data = ref({});
|
|
|
+
|
|
|
+const show_Huggingface = ref(false);
|
|
|
+const Huggingface_data = ref({});
|
|
|
+
|
|
|
+const show_Ollama = ref(false);
|
|
|
+const Ollama_data = ref({});
|
|
|
+
|
|
|
+const show_deepseek = ref(false);
|
|
|
+const Deepseek_data = ref({});
|
|
|
+
|
|
|
+const changeStatusAdd = () => {
|
|
|
+ added_show_status.value = !added_show_status.value;
|
|
|
+};
|
|
|
+const changeStatusUnAdd = () => {
|
|
|
+ unadd_show_status.value = !unadd_show_status.value;
|
|
|
+};
|
|
|
+
|
|
|
+const showMoreModel = async (item) => {
|
|
|
+ if (item.showMore) {
|
|
|
+ dify_added_data.value.forEach((it) => {
|
|
|
+ if (it.provider === item.provider) {
|
|
|
+ it.showMore = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const res = await getAddModelChildFun(item.provider);
|
|
|
+ if (res.data) {
|
|
|
+ dify_added_data.value.forEach((it) => {
|
|
|
+ if (it.provider === item.provider) {
|
|
|
+ it.showMore = true;
|
|
|
+ it.llm = res.data;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // dify_added_data.value[item.name].showMore = !dify_added_data.value[item.name].showMore;
|
|
|
+};
|
|
|
+
|
|
|
+const getAddModelChildFun = async (provide) => {
|
|
|
+ try {
|
|
|
+ const res = await getAddModelChild(provide);
|
|
|
+ return res;
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+};
|
|
|
+const getAddedModelsRGFun = async () => {
|
|
|
+ try {
|
|
|
+ const res = await getAddedModelsRG();
|
|
|
+ if (res.code / 1 === 0) {
|
|
|
+ for (const key in res.data) {
|
|
|
+ res.data[key].showMore = false;
|
|
|
+ res.data[key].name = key;
|
|
|
+ }
|
|
|
+ // Object.values(res.data).forEach((item) => {
|
|
|
+ // item.showMore = true;
|
|
|
+ // item.name =
|
|
|
+ // });
|
|
|
+ dify_added_data.value = { ...res.data };
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+};
|
|
|
+const getUnaddedModelsDIFYFun = async () => {
|
|
|
+ try {
|
|
|
+ const res = await getUnaddedModelsDIFY();
|
|
|
+ if (res.data) {
|
|
|
+ dify_all_data.value = res.data;
|
|
|
+ dify_unadded_data.value = res.data
|
|
|
+ .filter((item) => {
|
|
|
+ return ['openai', 'ollama', 'deepseek', 'openai_api_compatible', 'xinference', 'huggingface_hub'].includes(
|
|
|
+ item.provider
|
|
|
+ );
|
|
|
+ })
|
|
|
+ .filter((item) => item.custom_configuration.status === 'no-configure');
|
|
|
+ dify_added_data.value = res.data
|
|
|
+ .filter((item) => {
|
|
|
+ return ['openai', 'ollama', 'deepseek', 'openai_api_compatible', 'xinference', 'huggingface_hub'].includes(
|
|
|
+ item.provider
|
|
|
+ );
|
|
|
+ })
|
|
|
+ .filter((item) => item.custom_configuration.status === 'active')
|
|
|
+ .map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ showMore: false
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+};
|
|
|
+const updateModelList = async () => {
|
|
|
+ await getUnaddedModelsDIFYFun();
|
|
|
+};
|
|
|
+const toAddModel = (name) => {
|
|
|
+ const item = dify_all_data.value.find((it) => it.label.en_US === name);
|
|
|
+ handleAddModel(item);
|
|
|
+};
|
|
|
+const handleAddModel = async (item) => {
|
|
|
+ if (['xinference'].includes(item.provider)) {
|
|
|
+ show_Xinference_model.value = true;
|
|
|
+ Xinference_data.value = item;
|
|
|
+ }
|
|
|
+ if (['openai_api_compatible'].includes(item.provider)) {
|
|
|
+ show_Openai_api_compatible.value = true;
|
|
|
+ Openai_api_compatible_data.value = item;
|
|
|
+ }
|
|
|
+ if (['openai'].includes(item.provider)) {
|
|
|
+ show_Openai_model.value = true;
|
|
|
+ Openai_data.value = item;
|
|
|
+ }
|
|
|
+ if (['huggingface_hub'].includes(item.provider)) {
|
|
|
+ show_Huggingface.value = true;
|
|
|
+ Huggingface_data.value = item;
|
|
|
+ }
|
|
|
+ if (['ollama'].includes(item.provider)) {
|
|
|
+ show_Ollama.value = true;
|
|
|
+ Ollama_data.value = item;
|
|
|
+ }
|
|
|
+ if (['deepseek'].includes(item.provider)) {
|
|
|
+ show_deepseek.value = true;
|
|
|
+ Deepseek_data.value = item;
|
|
|
+ }
|
|
|
+
|
|
|
+ // if (['OpenAI-API-Compatible', 'HuggingFace', 'Xinference', 'Ollama'].includes(item.name)) {
|
|
|
+ // show_Xinference_model.value = true;
|
|
|
+ // Xinference_data.value = item;
|
|
|
+ // }
|
|
|
+ // if (['OpenAI', 'DeepSeek'].includes(item.name)) {
|
|
|
+ // console.log(item);
|
|
|
+ // show_Openai_model.value = true;
|
|
|
+ // Openai_data.value = item;
|
|
|
+ // }
|
|
|
+};
|
|
|
+const closeXinference = () => {
|
|
|
+ show_Xinference_model.value = false;
|
|
|
+ Xinference_data.value = {};
|
|
|
+};
|
|
|
+const closeOpenAi = () => {
|
|
|
+ show_Openai_model.value = false;
|
|
|
+ Openai_data.value = {};
|
|
|
+};
|
|
|
+const closeOpenAiComatible = () => {
|
|
|
+ show_Openai_api_compatible.value = false;
|
|
|
+ Openai_api_compatible_data.value = {};
|
|
|
+};
|
|
|
+const closeHuggingface = () => {
|
|
|
+ show_Huggingface.value = false;
|
|
|
+ Huggingface_data.value = {};
|
|
|
+};
|
|
|
+const closeOllama = () => {
|
|
|
+ show_Ollama.value = false;
|
|
|
+ Ollama_data.value = {};
|
|
|
+};
|
|
|
+const closeDeepseek = () => {
|
|
|
+ show_deepseek.value = false;
|
|
|
+ Deepseek_data.value = {};
|
|
|
+};
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getUnaddedModelsDIFYFun();
|
|
|
+});
|
|
|
+</script>
|
|
|
+<style scoped lang="css">
|
|
|
+.model-body {
|
|
|
+ height: calc(100% - 80px);
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+.model-body::-webkit-scrollbar {
|
|
|
+ display: none;
|
|
|
+}
|
|
|
+.body-item {
|
|
|
+ margin-bottom: 50px;
|
|
|
+}
|
|
|
+.empty-list {
|
|
|
+ background-color: var(--color-bg-2);
|
|
|
+}
|
|
|
+
|
|
|
+.item-title {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ justify-content: space-between;
|
|
|
+ margin-bottom: 20px;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
+.title {
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: bold;
|
|
|
+ color: var(--color-text-1);
|
|
|
+}
|
|
|
+.card-list {
|
|
|
+ display: grid;
|
|
|
+ grid-template-columns: repeat(5, 1fr);
|
|
|
+ gap: 20px;
|
|
|
+ transition: all 0.3s ease;
|
|
|
+ .labels {
|
|
|
+ color: var(--color-text-3);
|
|
|
+ }
|
|
|
+ .desc {
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|