1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
| from django.contrib import admin
|
| from .models import ModelInterface, ModelRun, ThirdPartyModelVersion
|
|
| @admin.register(ModelInterface)
| class ModelInterfaceAdmin(admin.ModelAdmin):
| list_display = (
| 'title',
| 'skill_name',
| 'organization',
| 'created_by',
| 'created_at',
| 'updated_at',
| )
| list_filter = ('skill_name', 'organization')
| search_fields = ('title', 'description')
| readonly_fields = ('created_at', 'updated_at')
| filter_horizontal = ('associated_projects',)
| fieldsets = (
| ('Model Details', {'fields': ('title', 'description', 'skill_name')}),
| ('Organization', {'fields': ('organization', 'created_by')}),
| (
| 'Configuration',
| {'fields': ('input_fields', 'output_classes', 'associated_projects')},
| ),
| ('Timestamps', {'fields': ('created_at', 'updated_at')}),
| )
|
|
| @admin.register(ThirdPartyModelVersion)
| class ThirdPartyModelVersionAdmin(admin.ModelAdmin):
| list_display = (
| 'title',
| 'parent_model',
| 'provider',
| 'provider_model_id',
| 'organization',
| 'created_at',
| )
| list_filter = ('provider', 'organization')
| search_fields = ('title', 'provider_model_id', 'prompt')
| readonly_fields = ('created_at', 'updated_at')
| fieldsets = (
| ('Version Details', {'fields': ('title', 'parent_model', 'prompt')}),
| (
| 'Provider Details',
| {'fields': ('provider', 'provider_model_id', 'model_provider_connection')},
| ),
| ('Organization', {'fields': ('organization', 'created_by')}),
| ('Timestamps', {'fields': ('created_at', 'updated_at')}),
| )
|
|
| @admin.register(ModelRun)
| class ModelRunAdmin(admin.ModelAdmin):
| list_display = (
| 'id',
| 'model_version',
| 'project',
| 'status',
| 'created_by',
| 'created_at',
| 'completed_at',
| )
| list_filter = ('status', 'project_subset')
| search_fields = ('job_id',)
| readonly_fields = (
| 'created_at',
| 'triggered_at',
| 'predictions_updated_at',
| 'completed_at',
| 'total_predictions',
| 'total_correct_predictions',
| 'total_tasks',
| )
| fieldsets = (
| (
| 'Run Details',
| {
| 'fields': (
| 'model_version',
| 'project',
| 'project_subset',
| 'status',
| 'job_id',
| )
| },
| ),
| ('Organization', {'fields': ('organization', 'created_by')}),
| (
| 'Statistics',
| {
| 'fields': (
| 'total_predictions',
| 'total_correct_predictions',
| 'total_tasks',
| )
| },
| ),
| (
| 'Timestamps',
| {
| 'fields': (
| 'created_at',
| 'triggered_at',
| 'predictions_updated_at',
| 'completed_at',
| )
| },
| ),
| )
|
| actions = ['delete_model_run_predictions']
|
| def delete_model_run_predictions(self, request, queryset):
| for model_run in queryset:
| model_run.delete_predictions()
| self.message_user(request, f'Deleted predictions for {queryset.count()} model runs.')
|
| delete_model_run_predictions.short_description = 'Delete predictions for selected model runs'
|
|