<script setup lang="ts">
import {Form} from '@/components/Form'
import {ref} from 'vue'
import {FormSchema} from "@/types/form";
import {getSchemas} from "@/views/ai/model/embedding/composables/schemas";

const visible = ref(false)
const formData = ref({})
const formRef = ref()
const schemas = ref([])
const close = () => {
  visible.value = false
  formRef.value.clearForm()
}
const show = async (data: object) => {
  visible.value = true
  await nextTick()
  formRef.value.setValues(data)
  schemas.value =  (getSchemas(data.provider) as FormSchema[]).splice(1);
  formRef.value.setSchema(schemas.value)
  // models.value = getModels(data.provider, LLMProviders)
}
defineExpose({
  show,
  close
})
</script>

<template>
  <el-dialog v-model="visible" draggable title="编辑" width="800px" @close="close">
    <Form ref="formRef" :model="formData" :schema="schemas" />
    <template #footer>
      <el-button type="primary">确认</el-button>
      <el-button @click="close">取消</el-button>
    </template>
  </el-dialog>
</template>

<style scoped lang="scss">

</style>
