feat:
This commit is contained in:
parent
17aa05bad4
commit
cda71da7ce
@ -34,21 +34,27 @@
|
|||||||
show-word-limit
|
show-word-limit
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<div v-html="realatedProvider('model_azure_provider', 'icon')"></div>
|
||||||
|
|
||||||
<el-form-item label="选择模型" prop="model_id">
|
<el-form-item label="选择模型" prop="model_id">
|
||||||
<!-- <el-select
|
<el-select v-model="applicationForm.model_id" placeholder="请选择模型">
|
||||||
v-model="applicationForm.model_id"
|
<el-option-group
|
||||||
placeholder="请选择模型"
|
v-for="(value, label) in modelOptions"
|
||||||
style="width: 100%"
|
:key="value"
|
||||||
>
|
:label="realatedProvider(label, 'name')"
|
||||||
<el-option label="Zone one" value="shanghai" />
|
>
|
||||||
<el-option label="Zone two" value="beijing" />
|
<el-option
|
||||||
</el-select> -->
|
v-for="item in value"
|
||||||
<el-cascader
|
:key="item.id"
|
||||||
v-model="applicationForm.model_id"
|
:label="item.name"
|
||||||
:options="modelOptions"
|
:value="item.id"
|
||||||
:props="modelProps"
|
>
|
||||||
clearable
|
<div v-html="realatedProvider(label, 'icon')" class="model-icon"></div>
|
||||||
/>
|
<span>{{ item.name }}</span>
|
||||||
|
</el-option>
|
||||||
|
</el-option-group>
|
||||||
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="多轮对话">
|
<el-form-item label="多轮对话">
|
||||||
@ -125,8 +131,9 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref, watch, onMounted } from 'vue'
|
import { reactive, ref, watch, onMounted } from 'vue'
|
||||||
|
import { groupBy } from 'lodash'
|
||||||
import AiDialog from '@/components/ai-dialog/index.vue'
|
import AiDialog from '@/components/ai-dialog/index.vue'
|
||||||
import type { FormInstance, FormRules, CascaderProps } from 'element-plus'
|
import type { FormInstance, FormRules } from 'element-plus'
|
||||||
import type { ApplicationFormType } from '@/api/type/application'
|
import type { ApplicationFormType } from '@/api/type/application'
|
||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
const { model } = useStore()
|
const { model } = useStore()
|
||||||
@ -156,57 +163,48 @@ const rules = reactive<FormRules<ApplicationFormType>>({
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
const modelOptions = ref([])
|
const modelOptions = ref([])
|
||||||
|
const providerOptions = ref([])
|
||||||
|
|
||||||
watch(exampleList.value, () => {
|
watch(exampleList.value, () => {
|
||||||
applicationForm.example = exampleList.value.filter((v) => v)
|
applicationForm.example = exampleList.value.filter((v) => v)
|
||||||
})
|
})
|
||||||
|
|
||||||
let id = 0
|
|
||||||
const modelProps: CascaderProps = {
|
|
||||||
lazy: true,
|
|
||||||
async lazyLoad(node, resolve) {
|
|
||||||
console.log(node)
|
|
||||||
const { level } = node
|
|
||||||
if (level === 0) {
|
|
||||||
let res = await getProvider()
|
|
||||||
resolve(res)
|
|
||||||
}
|
|
||||||
// setTimeout(() => {
|
|
||||||
// const nodes = Array.from({ length: level + 1 }).map((item) => ({
|
|
||||||
// value: ++id,
|
|
||||||
// label: `Option - ${id}`,
|
|
||||||
// leaf: level >= 2
|
|
||||||
// }))
|
|
||||||
// resolve(nodes)
|
|
||||||
// }, 1000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getModel() {
|
function getModel() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
model
|
model
|
||||||
.asyncGetModel()
|
.asyncGetModel()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
modelOptions.value = groupBy(res?.data, 'provider')
|
||||||
|
console.log(modelOptions.value)
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProvider() {
|
function getProvider() {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
model
|
model
|
||||||
.asyncGetProvider()
|
.asyncGetProvider()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
modelOptions.value = res?.data
|
providerOptions.value = res?.data
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function realatedProvider(val, attr) {
|
||||||
|
const filterProvider = providerOptions.value.filter((item) => item.provider === val)?.[0]
|
||||||
|
console.log(filterProvider)
|
||||||
|
return filterProvider?.[attr] || ''
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// getProvider()
|
getProvider()
|
||||||
|
getModel()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@ -227,5 +225,11 @@ onMounted(() => {
|
|||||||
.scrollbar-height {
|
.scrollbar-height {
|
||||||
height: calc(var(--app-main-height) - 150px);
|
height: calc(var(--app-main-height) - 150px);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
.model-icon {
|
||||||
|
svg {
|
||||||
|
width: 30px;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -127,7 +127,14 @@ function getList() {
|
|||||||
applicationApi
|
applicationApi
|
||||||
.getApplication(pageConfig)
|
.getApplication(pageConfig)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
applicationList.value = res.data?.records
|
const list = res.data?.records
|
||||||
|
list.map((item) => {
|
||||||
|
applicationList.value.push({
|
||||||
|
value:item.provider,
|
||||||
|
label: item.name
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user