Added error field for training file with UI message
This commit is contained in:
parent
f74337f60f
commit
a6ed273a13
6 changed files with 15 additions and 8 deletions
|
|
@ -28,6 +28,7 @@ class Migration(migrations.Migration):
|
||||||
('file_size', models.IntegerField()),
|
('file_size', models.IntegerField()),
|
||||||
('file_type', models.CharField(max_length=50)),
|
('file_type', models.CharField(max_length=50)),
|
||||||
('description', models.TextField(blank=True, default='')),
|
('description', models.TextField(blank=True, default='')),
|
||||||
|
('error_message', models.TextField(blank=True, default='')),
|
||||||
('status', models.CharField(choices=[('ingesting', 'Ingesting'), ('chunked', 'Chunked'), ('embedded', 'Embedded'), ('failed', 'Failed')], default='ingesting', max_length=20)),
|
('status', models.CharField(choices=[('ingesting', 'Ingesting'), ('chunked', 'Chunked'), ('embedded', 'Embedded'), ('failed', 'Failed')], default='ingesting', max_length=20)),
|
||||||
('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='training_files', to='accounts.organization')),
|
('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='training_files', to='accounts.organization')),
|
||||||
('role', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='training_files', to='accounts.role')),
|
('role', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='training_files', to='accounts.role')),
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ class TrainingFile(IdentifierMixin, TimeStampMixin, Model):
|
||||||
file_type = CharField(max_length=50)
|
file_type = CharField(max_length=50)
|
||||||
|
|
||||||
description = TextField(blank=True, default='')
|
description = TextField(blank=True, default='')
|
||||||
|
error_message = TextField(blank=True, default='')
|
||||||
status = CharField(max_length=20, choices=STATUS_CHOICES, default='ingesting')
|
status = CharField(max_length=20, choices=STATUS_CHOICES, default='ingesting')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ class TrainingFileSerializer(ModelSerializer):
|
||||||
fields = [
|
fields = [
|
||||||
'id', 'uuid', 'organization', 'role', 'scope', 'uploaded_by', 'file', 'file_url',
|
'id', 'uuid', 'organization', 'role', 'scope', 'uploaded_by', 'file', 'file_url',
|
||||||
'file_name', 'file_size', 'file_type', 'description',
|
'file_name', 'file_size', 'file_type', 'description',
|
||||||
'status', 'created_at', 'updated_at'
|
'error_message', 'status', 'created_at', 'updated_at'
|
||||||
]
|
]
|
||||||
read_only_fields = [
|
read_only_fields = [
|
||||||
'id', 'uuid', 'uploaded_by', 'file_size', 'file_type',
|
'id', 'uuid', 'uploaded_by', 'file_size', 'file_type',
|
||||||
'status', 'created_at', 'updated_at',
|
'error_message', 'status', 'created_at', 'updated_at',
|
||||||
'organization', 'role', 'scope'
|
'organization', 'role', 'scope'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ def ingest_training_file_task(self, file_uuid):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
file_obj.status = 'failed'
|
file_obj.status = 'failed'
|
||||||
file_obj.description = str(e)
|
file_obj.error_message = str(e)
|
||||||
file_obj.save()
|
file_obj.save()
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ export interface TrainingFile {
|
||||||
file_size: number
|
file_size: number
|
||||||
file_type: string
|
file_type: string
|
||||||
description: string
|
description: string
|
||||||
|
error_message: string
|
||||||
is_processed: boolean
|
is_processed: boolean
|
||||||
status: 'ingesting' | 'chunked' | 'embedded' | 'failed'
|
status: 'ingesting' | 'chunked' | 'embedded' | 'failed'
|
||||||
file_url: string
|
file_url: string
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import {
|
||||||
Upload,
|
Upload,
|
||||||
Steps,
|
Steps,
|
||||||
Table,
|
Table,
|
||||||
|
Tooltip,
|
||||||
} from 'ant-design-vue'
|
} from 'ant-design-vue'
|
||||||
import { apiClient, isAxiosError, API } from '../router/api'
|
import { apiClient, isAxiosError, API } from '../router/api'
|
||||||
import { useUserStore } from '../stores/userStore'
|
import { useUserStore } from '../stores/userStore'
|
||||||
|
|
@ -324,17 +325,20 @@ const trainingFileColumns = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Status',
|
title: 'Status',
|
||||||
dataIndex: 'status',
|
|
||||||
key: 'status',
|
key: 'status',
|
||||||
customRender: ({ value }: { value: string }) => {
|
customRender: ({ record }: { record: TrainingFile }) => {
|
||||||
const statusMap: Record<string, { color: string; label: string }> = {
|
const statusMap: Record<string, { color: string; label: string }> = {
|
||||||
ingesting: { color: 'processing', label: 'Ingesting' },
|
ingesting: { color: 'processing', label: 'Ingesting' },
|
||||||
chunked: { color: 'blue', label: 'Chunked' },
|
chunked: { color: 'blue', label: 'Chunked' },
|
||||||
embedded: { color: 'success', label: 'Embedded' },
|
embedded: { color: 'success', label: 'Embedded' },
|
||||||
failed: { color: 'error', label: 'Failed' },
|
failed: { color: 'error', label: 'Failed' },
|
||||||
}
|
}
|
||||||
const status = statusMap[value] || { color: 'default', label: value }
|
const status = statusMap[record.status] || { color: 'default', label: record.status }
|
||||||
return h(Tag, { color: status.color }, () => status.label)
|
const tag = h(Tag, { color: status.color }, () => status.label)
|
||||||
|
if (record.status === 'failed' && record.error_message) {
|
||||||
|
return h(Tooltip, { title: record.error_message }, () => tag)
|
||||||
|
}
|
||||||
|
return tag
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue