Fix/speech to text button (#947)
This commit is contained in:
@@ -9,9 +9,10 @@ import StepTwo from './step-two'
|
||||
import StepThree from './step-three'
|
||||
import { DataSourceType } from '@/models/datasets'
|
||||
import type { DataSet, FileItem, createDocumentResponse } from '@/models/datasets'
|
||||
import { fetchDataSource, fetchTenantInfo } from '@/service/common'
|
||||
import { fetchDataSource } from '@/service/common'
|
||||
import { fetchDataDetail } from '@/service/datasets'
|
||||
import type { DataSourceNotionPage } from '@/models/common'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
|
||||
import AccountSetting from '@/app/components/header/account-setting'
|
||||
|
||||
@@ -23,7 +24,6 @@ type DatasetUpdateFormProps = {
|
||||
|
||||
const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
|
||||
const { t } = useTranslation()
|
||||
const [hasSetAPIKEY, setHasSetAPIKEY] = useState(true)
|
||||
const [isShowSetAPIKey, { setTrue: showSetAPIKey, setFalse: hideSetAPIkey }] = useBoolean()
|
||||
const [hasConnection, setHasConnection] = useState(true)
|
||||
const [isShowDataSourceSetting, { setTrue: showDataSourceSetting, setFalse: hideDataSourceSetting }] = useBoolean()
|
||||
@@ -33,6 +33,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
|
||||
const [fileList, setFiles] = useState<FileItem[]>([])
|
||||
const [result, setResult] = useState<createDocumentResponse | undefined>()
|
||||
const [hasError, setHasError] = useState(false)
|
||||
const { embeddingsDefaultModel } = useProviderContext()
|
||||
|
||||
const [notionPages, setNotionPages] = useState<Page[]>([])
|
||||
const updateNotionPages = (value: Page[]) => {
|
||||
@@ -77,11 +78,6 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
|
||||
setStep(step + delta)
|
||||
}, [step, setStep])
|
||||
|
||||
const checkAPIKey = async () => {
|
||||
const data = await fetchTenantInfo({ url: '/info' })
|
||||
const hasSetKey = data.providers.some(({ is_valid }) => is_valid)
|
||||
setHasSetAPIKEY(hasSetKey)
|
||||
}
|
||||
const checkNotionConnection = async () => {
|
||||
const { data } = await fetchDataSource({ url: '/data-source/integrates' })
|
||||
const hasConnection = data.filter(item => item.provider === 'notion') || []
|
||||
@@ -89,7 +85,6 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
checkAPIKey()
|
||||
checkNotionConnection()
|
||||
}, [])
|
||||
|
||||
@@ -132,7 +127,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
|
||||
onStepChange={nextStep}
|
||||
/>}
|
||||
{(step === 2 && (!datasetId || (datasetId && !!detail))) && <StepTwo
|
||||
hasSetAPIKEY={hasSetAPIKEY}
|
||||
hasSetAPIKEY={!!embeddingsDefaultModel}
|
||||
onSetting={showSetAPIKey}
|
||||
indexingType={detail?.indexing_technique || ''}
|
||||
datasetId={datasetId}
|
||||
@@ -151,7 +146,6 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
|
||||
/>}
|
||||
</div>
|
||||
{isShowSetAPIKey && <AccountSetting activeTab="provider" onCancel={async () => {
|
||||
await checkAPIKey()
|
||||
hideSetAPIkey()
|
||||
}} />}
|
||||
{isShowDataSourceSetting && <AccountSetting activeTab="data-source" onCancel={hideDataSourceSetting}/>}
|
||||
|
||||
Reference in New Issue
Block a user