import {ProviderEnum} from "@/views/ai/model/image/composables/consts";

export default function () {

  const editRef= ref()
  const formData = ref({
    provider: ProviderEnum.OPENAI,
  });
  const tableData = ref([])

   const baseColumns = [
    {
     label: '模型别名',
     field: 'name',
    },
    {
     label: '模型版本',
     field: 'model',
    },
  ];

   const openaiColumns = [
    ...baseColumns,
    {
     label: 'Api Key',
     field: 'apiKey',
    },
  ];

   const azureOpenaiColumns = [
    ...baseColumns,
    {
     label: 'Api Key',
     field: 'apiKey',
    },
    {
     label: 'Endpoint',
     field: 'endpoint',
    },
    {
     label: 'Deployment Name',
     field: 'azureDeploymentName',
    },
  ];

   const zhipuColumns = [...baseColumns];
  function getColumns(provider: string) {
    console.log(provider);
    switch (provider) {
      case ProviderEnum.OPENAI: {
        return openaiColumns;
      }
      case ProviderEnum.AZURE_OPENAI: {
        return azureOpenaiColumns;
      }
      case ProviderEnum.ZHIPU: {
        return zhipuColumns;
      }
    }
    return [];
  }
  const columns = computed(() => {
    nextTick();
    return getColumns(formData.value.provider)
  });
  const open = () => {
    editRef.value.show({provider: formData.value.provider});
  }
  return {
    columns,
    tableData,
    formData,
    editRef,
    open
  }
}
