mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
feat: model建文件
This commit is contained in:
parent
9cb0a4f27c
commit
2023f64953
|
|
@ -1,6 +1,17 @@
|
|||
import { Result } from '@/request/Result'
|
||||
import { get, post, del, put } from '@/request/index'
|
||||
import type { modelRequest } from '@/api/type/model'
|
||||
const prefix = '/model'
|
||||
const prefix_provider = '/provider'
|
||||
|
||||
export default {}
|
||||
/**
|
||||
* 获得模型列表
|
||||
* @params 参数 name, model_type, model_name
|
||||
*/
|
||||
const getModel: (data?: modelRequest) => Promise<Result<any>> = (data) => {
|
||||
return get(`${prefix}`, data)
|
||||
}
|
||||
|
||||
export default {
|
||||
getModel
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
interface modelRequest {
|
||||
name: string
|
||||
model_type: string
|
||||
model_name: string
|
||||
}
|
||||
export type { modelRequest }
|
||||
|
|
@ -4,11 +4,13 @@ export { store }
|
|||
import useUserStore from './modules/user'
|
||||
import useDatasetStore from './modules/dataset'
|
||||
import useParagraphStore from './modules/paragraph'
|
||||
import useModelStore from './modules/model'
|
||||
|
||||
const useStore = () => ({
|
||||
user: useUserStore(),
|
||||
dataset: useDatasetStore(),
|
||||
paragraph: useParagraphStore(),
|
||||
model: useModelStore(),
|
||||
})
|
||||
|
||||
export default useStore
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
import { defineStore } from 'pinia'
|
||||
import modelApi from '@/api/model'
|
||||
import type { modelRequest } from '@/api/type/model'
|
||||
const useModelStore = defineStore({
|
||||
id: 'model',
|
||||
state: () => ({}),
|
||||
actions: {
|
||||
async asyncGetModel(data?: modelRequest) {
|
||||
return new Promise((resolve, reject) => {
|
||||
modelApi
|
||||
.getModel(data)
|
||||
.then((res) => {
|
||||
resolve(res)
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default useModelStore
|
||||
|
|
@ -35,7 +35,11 @@
|
|||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="选择模型" prop="model_id">
|
||||
<el-select v-model="applicationForm.model_id" placeholder="请选择模型" style="width: 100%;">
|
||||
<el-select
|
||||
v-model="applicationForm.model_id"
|
||||
placeholder="请选择模型"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option label="Zone one" value="shanghai" />
|
||||
<el-option label="Zone two" value="beijing" />
|
||||
</el-select>
|
||||
|
|
@ -114,10 +118,12 @@
|
|||
</LayoutContainer>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { reactive, ref, watch, onMounted } from 'vue'
|
||||
import AiDialog from '@/components/ai-dialog/index.vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type { ApplicationFormType } from '@/api/application'
|
||||
import type { ApplicationFormType } from '@/api/type/application'
|
||||
import useStore from '@/stores'
|
||||
const { model } = useStore()
|
||||
|
||||
const applicationFormRef = ref<FormInstance>()
|
||||
|
||||
|
|
@ -147,6 +153,20 @@ const rules = reactive<FormRules<ApplicationFormType>>({
|
|||
watch(exampleList.value, () => {
|
||||
applicationForm.example = exampleList.value.filter((v) => v)
|
||||
})
|
||||
|
||||
function getModel() {
|
||||
loading.value = true
|
||||
model.asyncGetModel()
|
||||
.then((res) => {
|
||||
loading.value = false
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
getModel()
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.create-application {
|
||||
|
|
|
|||
Loading…
Reference in New Issue