瀏覽代碼

refactor(credential-icon, create-from-pipeline, test-run): improve component structure and enhance data handling for online drive files

tags/2.0.0-beta.1
twwu 2 月之前
父節點
當前提交
be045a68ee

+ 11
- 7
web/app/components/datasets/common/credential-icon.tsx 查看文件



if (avatar_url && avatar_url !== 'default') { if (avatar_url && avatar_url !== 'default') {
return ( return (
<img
src={avatar_url}
alt={`${name} logo`}
width={size}
height={size}
className={cn('shrink-0 rounded-md border border-divider-regular object-contain', className)}
/>
<div
className='flex shrink-0 items-center justify-center overflow-hidden rounded-md border border-divider-regular'
style={{ width: `${size}px`, height: `${size}px` }}
>
<img
src={avatar_url}
width={size}
height={size}
className={cn('shrink-0 object-contain', className)}
/>
</div>
) )
} }



+ 7
- 4
web/app/components/datasets/documents/create-from-pipeline/index.tsx 查看文件

} }
if (datasourceType === DatasourceType.onlineDrive) { if (datasourceType === DatasourceType.onlineDrive) {
const { bucket } = dataSourceStore.getState() const { bucket } = dataSourceStore.getState()
const { id } = previewOnlineDriveFileRef.current!
const { id, type } = previewOnlineDriveFileRef.current!
datasourceInfoList.push({ datasourceInfoList.push({
bucket, bucket,
id, id,
type,
credential_id: currentCredentialId, credential_id: currentCredentialId,
}) })
} }
const handleProcess = useCallback(async (data: Record<string, any>) => { const handleProcess = useCallback(async (data: Record<string, any>) => {
if (!datasource) if (!datasource)
return return
const { bucket, currentCredentialId } = dataSourceStore.getState()
const { bucket, currentCredentialId, fileList: onlineDriveFileList } = dataSourceStore.getState()
const datasourceInfoList: Record<string, any>[] = [] const datasourceInfoList: Record<string, any>[] = []
if (datasourceType === DatasourceType.localFile) { if (datasourceType === DatasourceType.localFile) {
fileList.forEach((file) => { fileList.forEach((file) => {
} }
if (datasourceType === DatasourceType.onlineDrive) { if (datasourceType === DatasourceType.onlineDrive) {
if (datasourceType === DatasourceType.onlineDrive) { if (datasourceType === DatasourceType.onlineDrive) {
selectedFileIds.forEach((key) => {
selectedFileIds.forEach((id) => {
const file = onlineDriveFileList.find(file => file.id === id)
datasourceInfoList.push({ datasourceInfoList.push({
bucket, bucket,
key,
id: file?.id,
type: file?.type,
credential_id: currentCredentialId, credential_id: currentCredentialId,
}) })
}) })

+ 4
- 2
web/app/components/rag-pipeline/components/panel/test-run/index.tsx 查看文件

}) })
} }
if (datasourceType === DatasourceType.onlineDrive) { if (datasourceType === DatasourceType.onlineDrive) {
const { bucket } = dataSourceStore.getState()
const { bucket, fileList } = dataSourceStore.getState()
const file = fileList.find(file => file.id === selectedFileIds[0])
datasourceInfoList.push({ datasourceInfoList.push({
bucket, bucket,
id: selectedFileIds[0],
id: file?.id,
type: file?.type,
credential_id: credentialId, credential_id: credentialId,
}) })
} }

Loading…
取消
儲存