2024-07-22 00:00:54 +08:00
|
|
|
|
<template>
|
2024-09-01 21:14:23 +08:00
|
|
|
|
<div class="setting-container layout-container">
|
2024-07-25 20:30:28 +08:00
|
|
|
|
<div class="setting">
|
|
|
|
|
|
<h2>设置</h2>
|
|
|
|
|
|
<h3>模型配置</h3>
|
2024-08-07 17:25:06 +08:00
|
|
|
|
<p>请在 <code>src/.env</code> 文件中配置对应的 APIKEY,可参考 <code>src/.env.template</code></p>
|
2024-07-25 20:30:28 +08:00
|
|
|
|
<div class="section">
|
|
|
|
|
|
<div class="card">
|
|
|
|
|
|
<span class="label">
|
|
|
|
|
|
{{ items?.model_provider.des }}
|
|
|
|
|
|
<a-button small v-if="needRestart.model_provider" @click="sendRestart">
|
|
|
|
|
|
<ReloadOutlined />需要重启
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</span>
|
2024-08-25 20:29:24 +08:00
|
|
|
|
<a-select ref="select" style="width: 200px"
|
2024-07-25 20:30:28 +08:00
|
|
|
|
:value="configStore.config?.model_provider"
|
|
|
|
|
|
@change="handleChange('model_provider', $event)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<a-select-option
|
|
|
|
|
|
v-for="(name, idx) in items?.model_provider.choices" :key="idx"
|
|
|
|
|
|
:value="name">{{ name }}
|
|
|
|
|
|
</a-select-option>
|
|
|
|
|
|
</a-select>
|
|
|
|
|
|
</div>
|
2024-07-31 20:22:05 +08:00
|
|
|
|
<div class="card">
|
|
|
|
|
|
<span class="label">
|
|
|
|
|
|
{{ items?.model_name.des }}
|
|
|
|
|
|
<a-button small v-if="needRestart.model_name" @click="sendRestart">
|
|
|
|
|
|
<ReloadOutlined />需要重启
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</span>
|
2024-08-25 20:29:24 +08:00
|
|
|
|
<a-select ref="select" style="width: 200px"
|
2024-07-31 20:22:05 +08:00
|
|
|
|
:value="configStore.config?.model_name"
|
|
|
|
|
|
@change="handleChange('model_name', $event)"
|
|
|
|
|
|
v-if="configStore.config?.model_names && configStore.config?.model_provider && configStore.config?.model_names[configStore.config?.model_provider]"
|
|
|
|
|
|
>
|
|
|
|
|
|
<a-select-option
|
|
|
|
|
|
v-for="(name, idx) in configStore.config.model_names[configStore.config.model_provider]"
|
|
|
|
|
|
:key="idx"
|
|
|
|
|
|
:value="name">{{ name }}
|
|
|
|
|
|
</a-select-option>
|
|
|
|
|
|
</a-select>
|
|
|
|
|
|
</div>
|
2024-07-25 20:30:28 +08:00
|
|
|
|
<div class="card">
|
|
|
|
|
|
<span class="label">{{ items?.embed_model.des }}
|
|
|
|
|
|
<a-button small v-if="needRestart.embed_model" @click="sendRestart">
|
|
|
|
|
|
<ReloadOutlined />需要重启
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</span>
|
2024-08-25 20:29:24 +08:00
|
|
|
|
<a-select style="width: 200px"
|
2024-07-25 20:30:28 +08:00
|
|
|
|
:value="configStore.config?.embed_model"
|
|
|
|
|
|
@change="handleChange('embed_model', $event)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<a-select-option
|
|
|
|
|
|
v-for="(name, idx) in items?.embed_model.choices" :key="idx"
|
|
|
|
|
|
:value="name">{{ name }}
|
|
|
|
|
|
</a-select-option>
|
|
|
|
|
|
</a-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="card">
|
|
|
|
|
|
<span class="label">{{ items?.reranker.des }}
|
|
|
|
|
|
<a-button small v-if="needRestart.reranker" @click="sendRestart">
|
|
|
|
|
|
<ReloadOutlined />需要重启
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</span>
|
2024-08-25 20:29:24 +08:00
|
|
|
|
<a-select style="width: 200px"
|
2024-07-25 20:30:28 +08:00
|
|
|
|
:value="configStore.config?.reranker"
|
|
|
|
|
|
@change="handleChange('reranker', $event)"
|
2024-07-29 01:00:02 +08:00
|
|
|
|
:disabled="!configStore.config.enable_reranker"
|
2024-07-25 20:30:28 +08:00
|
|
|
|
>
|
|
|
|
|
|
<a-select-option
|
|
|
|
|
|
v-for="(name, idx) in items?.reranker.choices" :key="idx"
|
|
|
|
|
|
:value="name">{{ name }}
|
|
|
|
|
|
</a-select-option>
|
|
|
|
|
|
</a-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<h3>功能配置</h3>
|
|
|
|
|
|
<div class="section">
|
|
|
|
|
|
<div class="card">
|
2024-07-31 20:22:05 +08:00
|
|
|
|
<span class="label">{{ items?.enable_knowledge_base.des }}
|
|
|
|
|
|
<a-button small v-if="needRestart.enable_knowledge_base" @click="sendRestart">
|
|
|
|
|
|
<ReloadOutlined />需要重启
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</span>
|
2024-07-25 20:30:28 +08:00
|
|
|
|
<a-switch
|
|
|
|
|
|
:checked="configStore.config.enable_knowledge_base"
|
|
|
|
|
|
@change="handleChange('enable_knowledge_base', !configStore.config.enable_knowledge_base)"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2024-09-03 16:37:59 +08:00
|
|
|
|
<div class="card">
|
2024-07-25 20:30:28 +08:00
|
|
|
|
<span class="label">{{ items?.enable_knowledge_graph.des }}</span>
|
|
|
|
|
|
<a-switch
|
|
|
|
|
|
:checked="configStore.config.enable_knowledge_graph"
|
|
|
|
|
|
@change="handleChange('enable_knowledge_graph', !configStore.config.enable_knowledge_graph)"
|
|
|
|
|
|
/>
|
2024-09-03 16:37:59 +08:00
|
|
|
|
</div>
|
2024-07-25 20:30:28 +08:00
|
|
|
|
<div class="card">
|
|
|
|
|
|
<span class="label">{{ items?.enable_search_engine.des }}</span>
|
|
|
|
|
|
<a-switch
|
|
|
|
|
|
:checked="configStore.config.enable_search_engine"
|
|
|
|
|
|
@change="handleChange('enable_search_engine', !configStore.config.enable_search_engine)"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="card">
|
2024-07-29 01:00:02 +08:00
|
|
|
|
<span class="label">{{ items?.enable_reranker.des }}
|
|
|
|
|
|
<a-button small v-if="needRestart.enable_reranker" @click="sendRestart">
|
|
|
|
|
|
<ReloadOutlined />需要重启
|
|
|
|
|
|
</a-button>
|
|
|
|
|
|
</span>
|
2024-07-25 20:30:28 +08:00
|
|
|
|
<a-switch
|
2024-07-29 01:00:02 +08:00
|
|
|
|
:checked="configStore.config.enable_reranker"
|
|
|
|
|
|
@change="handleChange('enable_reranker', !configStore.config.enable_reranker)"
|
2024-07-25 20:30:28 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2024-07-22 00:00:54 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
import { message } from 'ant-design-vue';
|
2024-07-25 20:30:28 +08:00
|
|
|
|
import { computed, reactive, ref } from 'vue'
|
2024-07-27 14:32:57 +08:00
|
|
|
|
import { useConfigStore } from '@/stores/config';
|
2024-07-25 20:30:28 +08:00
|
|
|
|
import { ReloadOutlined } from '@ant-design/icons-vue';
|
2024-07-22 00:00:54 +08:00
|
|
|
|
|
|
|
|
|
|
const configStore = useConfigStore()
|
2024-07-25 20:30:28 +08:00
|
|
|
|
const needRestart = reactive({
|
|
|
|
|
|
model_provider: false,
|
|
|
|
|
|
embed_model: false,
|
|
|
|
|
|
reranker: false,
|
|
|
|
|
|
})
|
|
|
|
|
|
const items = computed(() => configStore.config._config_items)
|
2024-07-22 00:00:54 +08:00
|
|
|
|
const state = reactive({
|
|
|
|
|
|
loading: false,
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2024-07-25 20:30:28 +08:00
|
|
|
|
const handleChange = (key, e) => {
|
2024-09-03 16:37:59 +08:00
|
|
|
|
if (key == 'enable_knowledge_graph' && e && !configStore.config.enable_knowledge_base) {
|
|
|
|
|
|
message.error('请先启用知识库功能')
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2024-07-25 20:30:28 +08:00
|
|
|
|
console.log('Change', key, e)
|
|
|
|
|
|
needRestart[key] = true
|
|
|
|
|
|
configStore.setConfigValue(key, e)
|
|
|
|
|
|
}
|
2024-07-22 00:00:54 +08:00
|
|
|
|
const sendRestart = () => {
|
|
|
|
|
|
console.log('Restarting...')
|
2024-07-27 14:32:57 +08:00
|
|
|
|
message.loading({ content: '重新加载模型中', key: "restart", duration: 0 });
|
2024-07-22 00:00:54 +08:00
|
|
|
|
fetch('/api/restart', {
|
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
console.log('Restarted')
|
2024-07-27 14:32:57 +08:00
|
|
|
|
message.success({ content: '重新加载完成!', key: "restart", duration: 2 });
|
2024-07-22 00:00:54 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
window.location.reload()
|
2024-07-31 20:22:05 +08:00
|
|
|
|
}, 200)
|
2024-07-22 00:00:54 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
2024-07-25 20:30:28 +08:00
|
|
|
|
<style lang="less" scoped>
|
2024-07-22 00:00:54 +08:00
|
|
|
|
|
2024-07-25 20:30:28 +08:00
|
|
|
|
.setting {
|
|
|
|
|
|
max-width: 800px;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
|
|
|
|
|
|
h3 {
|
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.section {
|
|
|
|
|
|
margin-top: 20px;
|
2024-07-27 14:32:57 +08:00
|
|
|
|
background-color: var(--main-light-4);
|
2024-07-25 20:30:28 +08:00
|
|
|
|
padding: 20px;
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
gap: 16px;
|
|
|
|
|
|
// box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
2024-07-26 14:13:05 +08:00
|
|
|
|
border: 1px solid var(--main-light-3);
|
2024-07-25 20:30:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.card {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
|
|
.label {
|
|
|
|
|
|
margin-right: 20px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-22 00:00:54 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-25 20:30:28 +08:00
|
|
|
|
|
|
|
|
|
|
</style>
|