Commit 141244e9 authored by nick zheng's avatar nick zheng

feat: 应用创建大模型增加icon

parent d0896c02
...@@ -129,3 +129,11 @@ export function fetchCreateAgentTitleAndDesc<T>(payload: { input: string }, cont ...@@ -129,3 +129,11 @@ export function fetchCreateAgentTitleAndDesc<T>(payload: { input: string }, cont
signal: controller.signal, signal: controller.signal,
}) })
} }
/**
* * @param { modelName: 模型名称 }
* @returns 搜索模型信息
*/
export function fetchGetLargeModelInfo<T>(modelName: string) {
return request.post<T>(`/agentApplicationInfoRest/getLargeModelInfo.json?query=${modelName}`)
}
...@@ -22,7 +22,7 @@ export function defaultPersonalAppConfigState(): PersonalAppConfigState { ...@@ -22,7 +22,7 @@ export function defaultPersonalAppConfigState(): PersonalAppConfigState {
knowledgeIds: [], knowledgeIds: [],
}, },
commModelConfig: { commModelConfig: {
largeModel: 'ERNIE-4.0-8K', largeModel: '文心4.0 (8K)',
topP: 0.0, topP: 0.0,
communicationTurn: 0, communicationTurn: 0,
}, },
......
<script setup lang="ts"> <script setup lang="ts">
import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue' import { computed, h, nextTick, onMounted, onUnmounted, reactive, ref, VNodeChild, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { FormInst, InputInst, SelectOption, UploadFileInfo } from 'naive-ui' import { FormInst, InputInst, SelectOption, UploadFileInfo } from 'naive-ui'
import { useThrottleFn } from '@vueuse/core' import { useThrottleFn } from '@vueuse/core'
...@@ -15,6 +15,7 @@ import { ...@@ -15,6 +15,7 @@ import {
fetchCreateFeaturedQuestions, fetchCreateFeaturedQuestions,
fetchCreatePreamble, fetchCreatePreamble,
fetchGetDebugApplicationInfo, fetchGetDebugApplicationInfo,
fetchGetLargeModelInfo,
fetchGetLargeModelList, fetchGetLargeModelList,
fetchSaveAgentApplication, fetchSaveAgentApplication,
} from '@/apis/agent-application' } from '@/apis/agent-application'
...@@ -51,6 +52,10 @@ const questionSettingOptions = [ ...@@ -51,6 +52,10 @@ const questionSettingOptions = [
let modalListOptions = reactive<SelectOption[]>([]) let modalListOptions = reactive<SelectOption[]>([])
let modalListRenderLabel: (option: SelectOption) => VNodeChild
const currentLargeModelIcon = ref('') // 当前大模型icon
const commConfigExpandedNames = ref<string[]>(['continuousQuestion']) const commConfigExpandedNames = ref<string[]>(['continuousQuestion'])
const isInitGetAgentAppDetail = ref(false) const isInitGetAgentAppDetail = ref(false)
...@@ -115,6 +120,8 @@ onMounted(async () => { ...@@ -115,6 +120,8 @@ onMounted(async () => {
isInitGetAgentAppDetail.value = false isInitGetAgentAppDetail.value = false
} }
await handleGetLargeModelList() await handleGetLargeModelList()
await handleGetLargeModelInfo()
}) })
onUnmounted(() => { onUnmounted(() => {
...@@ -149,9 +156,10 @@ async function handleGetAgentApplicationDetail(agentId: string) { ...@@ -149,9 +156,10 @@ async function handleGetAgentApplicationDetail(agentId: string) {
} }
} }
// 获取大模型列表
async function handleGetLargeModelList() { async function handleGetLargeModelList() {
modalListOptions = [] modalListOptions = []
const res = await fetchGetLargeModelList<{ owner: string; models: string[] }[]>() const res = await fetchGetLargeModelList<{ owner: string; models: string[]; icon: string }[]>()
res.data.forEach((item) => { res.data.forEach((item) => {
modalListOptions.push({ modalListOptions.push({
...@@ -162,9 +170,44 @@ async function handleGetLargeModelList() { ...@@ -162,9 +170,44 @@ async function handleGetLargeModelList() {
label: model, label: model,
value: model, value: model,
style: { fontSize: '12px' }, style: { fontSize: '12px' },
icon: item.icon,
})), })),
}) })
}) })
modalListRenderLabel = (option: SelectOption): VNodeChild => {
if (option.type === 'group') return `${option.label}`
return [
h('div', { class: 'flex items-center' }, [
h('div', {
style: {
width: '16px',
height: '16px',
marginRight: '6px',
flexShrink: 0,
background: `url(${option.icon})`,
backgroundSize: '100% 100%',
},
}),
h('span', {}, { default: () => option.label as string }),
]),
]
}
}
// 获取大模型信息
async function handleGetLargeModelInfo() {
const res = await fetchGetLargeModelInfo<{ icon: string }>(personalAppConfig.value.commModelConfig.largeModel)
if (res.code === 0) {
currentLargeModelIcon.value = res.data.icon
}
}
// 更换大模型
function handleUpdateLargeModel(_value: string, option: SelectOption) {
currentLargeModelIcon.value = option.icon as string
} }
// 保存应用配置 // 保存应用配置
...@@ -397,7 +440,7 @@ function handleStopGenerate() { ...@@ -397,7 +440,7 @@ function handleStopGenerate() {
<div <div
class="hover:border-theme-color flex cursor-pointer items-center justify-between rounded-md border border-[#d4d6d9] px-3 py-[7px]" class="hover:border-theme-color flex cursor-pointer items-center justify-between rounded-md border border-[#d4d6d9] px-3 py-[7px]"
> >
<img src="@/assets/images/lingjing-icon.png" class="mr-1 h-4 w-4" /> <img :src="currentLargeModelIcon || '@/assets/images/lingjing-icon.png'" class="mr-1 h-4 w-4" />
<span class="line-clamp-1 max-w-[100px] text-xs text-[#5c5f66]"> <span class="line-clamp-1 max-w-[100px] text-xs text-[#5c5f66]">
{{ personalAppConfig.commModelConfig.largeModel }} {{ personalAppConfig.commModelConfig.largeModel }}
</span> </span>
...@@ -412,6 +455,8 @@ function handleStopGenerate() { ...@@ -412,6 +455,8 @@ function handleStopGenerate() {
v-model:value="personalAppConfig.commModelConfig.largeModel" v-model:value="personalAppConfig.commModelConfig.largeModel"
class="model-select" class="model-select"
:options="modalListOptions" :options="modalListOptions"
:render-label="modalListRenderLabel"
@update:value="handleUpdateLargeModel"
/> />
<div class="mt-4 text-xs"> <div class="mt-4 text-xs">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment