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
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 {
knowledgeIds: [],
},
commModelConfig: {
largeModel: 'ERNIE-4.0-8K',
largeModel: '文心4.0 (8K)',
topP: 0.0,
communicationTurn: 0,
},
......
<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 { FormInst, InputInst, SelectOption, UploadFileInfo } from 'naive-ui'
import { useThrottleFn } from '@vueuse/core'
......@@ -15,6 +15,7 @@ import {
fetchCreateFeaturedQuestions,
fetchCreatePreamble,
fetchGetDebugApplicationInfo,
fetchGetLargeModelInfo,
fetchGetLargeModelList,
fetchSaveAgentApplication,
} from '@/apis/agent-application'
......@@ -51,6 +52,10 @@ const questionSettingOptions = [
let modalListOptions = reactive<SelectOption[]>([])
let modalListRenderLabel: (option: SelectOption) => VNodeChild
const currentLargeModelIcon = ref('') // 当前大模型icon
const commConfigExpandedNames = ref<string[]>(['continuousQuestion'])
const isInitGetAgentAppDetail = ref(false)
......@@ -115,6 +120,8 @@ onMounted(async () => {
isInitGetAgentAppDetail.value = false
}
await handleGetLargeModelList()
await handleGetLargeModelInfo()
})
onUnmounted(() => {
......@@ -149,9 +156,10 @@ async function handleGetAgentApplicationDetail(agentId: string) {
}
}
// 获取大模型列表
async function handleGetLargeModelList() {
modalListOptions = []
const res = await fetchGetLargeModelList<{ owner: string; models: string[] }[]>()
const res = await fetchGetLargeModelList<{ owner: string; models: string[]; icon: string }[]>()
res.data.forEach((item) => {
modalListOptions.push({
......@@ -162,9 +170,44 @@ async function handleGetLargeModelList() {
label: model,
value: model,
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() {
<div
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]">
{{ personalAppConfig.commModelConfig.largeModel }}
</span>
......@@ -412,6 +455,8 @@ function handleStopGenerate() {
v-model:value="personalAppConfig.commModelConfig.largeModel"
class="model-select"
:options="modalListOptions"
:render-label="modalListRenderLabel"
@update:value="handleUpdateLargeModel"
/>
<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