feat: model load balancing (#4926)

This commit is contained in:
Nite Knite
2024-06-05 00:13:29 +08:00
committed by GitHub
parent d1dbbc1e33
commit 37f292ea91
58 changed files with 1896 additions and 304 deletions

View File

@@ -123,7 +123,7 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
onStepChange={nextStep}
/>}
{(step === 2 && (!datasetId || (datasetId && !!detail))) && <StepTwo
hasSetAPIKEY={!!embeddingsDefaultModel}
isAPIKeySet={!!embeddingsDefaultModel}
onSetting={() => setShowAccountSettingModal({ payload: 'provider' })}
indexingType={detail?.indexing_technique}
datasetId={datasetId}

View File

@@ -49,7 +49,7 @@ type ValueOf<T> = T[keyof T]
type StepTwoProps = {
isSetting?: boolean
documentDetail?: FullDocumentDetail
hasSetAPIKEY: boolean
isAPIKeySet: boolean
onSetting: () => void
datasetId?: string
indexingType?: ValueOf<IndexingType>
@@ -75,7 +75,7 @@ enum IndexingType {
const StepTwo = ({
isSetting,
documentDetail,
hasSetAPIKEY,
isAPIKeySet,
onSetting,
datasetId,
indexingType,
@@ -107,7 +107,7 @@ const StepTwo = ({
const hasSetIndexType = !!indexingType
const [indexType, setIndexType] = useState<ValueOf<IndexingType>>(
(indexingType
|| hasSetAPIKEY)
|| isAPIKeySet)
? IndexingType.QUALIFIED
: IndexingType.ECONOMICAL,
)
@@ -480,8 +480,8 @@ const StepTwo = ({
setIndexType(indexingType as IndexingType)
else
setIndexType(hasSetAPIKEY ? IndexingType.QUALIFIED : IndexingType.ECONOMICAL)
}, [hasSetAPIKEY, indexingType, datasetId])
setIndexType(isAPIKeySet ? IndexingType.QUALIFIED : IndexingType.ECONOMICAL)
}, [isAPIKeySet, indexingType, datasetId])
useEffect(() => {
if (segmentationType === SegmentType.AUTO) {
@@ -636,13 +636,13 @@ const StepTwo = ({
className={cn(
s.radioItem,
s.indexItem,
!hasSetAPIKEY && s.disabled,
!isAPIKeySet && s.disabled,
!hasSetIndexType && indexType === IndexingType.QUALIFIED && s.active,
hasSetIndexType && s.disabled,
hasSetIndexType && '!w-full',
)}
onClick={() => {
if (hasSetAPIKEY)
if (isAPIKeySet)
setIndexType(IndexingType.QUALIFIED)
}}
>
@@ -665,7 +665,7 @@ const StepTwo = ({
)
}
</div>
{!hasSetAPIKEY && (
{!isAPIKeySet && (
<div className={s.warningTip}>
<span>{t('datasetCreation.stepTwo.warning')}&nbsp;</span>
<span className={s.click} onClick={onSetting}>{t('datasetCreation.stepTwo.click')}</span>

View File

@@ -68,7 +68,7 @@ const DocumentSettings = ({ datasetId, documentId }: DocumentSettingsProps) => {
{!documentDetail && <Loading type='app' />}
{dataset && documentDetail && (
<StepTwo
hasSetAPIKEY={!!embeddingsDefaultModel}
isAPIKeySet={!!embeddingsDefaultModel}
onSetting={showSetAPIKey}
datasetId={datasetId}
dataSourceType={documentDetail.data_source_type}