From 36d8061b4dfb3ef230bcf865ac04c7d395ae3739 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Tue, 12 Nov 2024 23:14:25 -0800 Subject: [PATCH] refac: evaluations --- src/lib/components/admin/Evaluations.svelte | 727 ++---------------- .../admin/Evaluations/Feedbacks.svelte | 283 +++++++ .../admin/Evaluations/Leaderboard.svelte | 410 ++++++++++ 3 files changed, 766 insertions(+), 654 deletions(-) create mode 100644 src/lib/components/admin/Evaluations/Feedbacks.svelte create mode 100644 src/lib/components/admin/Evaluations/Leaderboard.svelte diff --git a/src/lib/components/admin/Evaluations.svelte b/src/lib/components/admin/Evaluations.svelte index 088b157da..1fdd50df2 100644 --- a/src/lib/components/admin/Evaluations.svelte +++ b/src/lib/components/admin/Evaluations.svelte @@ -1,677 +1,96 @@ - {#if loaded} -
-
-
- {$i18n.t('Leaderboard')} -
- -
- - {rankedModels.length} +
+
- -
- -
-
- -
- { - loadEmbeddingModel(); - }} - /> -
-
-
-
- -
- {#if loadingLeaderboard} -
-
- -
-
- {/if} - {#if (rankedModels ?? []).length === 0} -
- {$i18n.t('No models found')} -
- {:else} - - - - - - - - - - - - {#each rankedModels as model, modelIdx (model.id)} - - - - - - - - - - {/each} - -
- {$i18n.t('RK')} - - {$i18n.t('Model')} - - {$i18n.t('Rating')} - - {$i18n.t('Won')} - - {$i18n.t('Lost')} -
-
- {model?.rating !== '-' ? modelIdx + 1 : '-'} -
-
-
-
- {model.name} -
- -
- {model.name} -
-
-
- {model.rating} - -
- {#if model.stats.won === '-'} - - - {:else} - - {model.stats.won} - {/if} -
-
-
- {#if model.stats.lost === '-'} - - - {:else} - - {model.stats.lost} - {/if} -
-
- {/if} -
- -
-
-
- ⓘ {$i18n.t( - 'The evaluation leaderboard is based on the Elo rating system and is updated in real-time.' - )} -
- {$i18n.t( - 'The leaderboard is currently in beta, and we may adjust the rating calculations as we refine the algorithm.' - )} -
-
- -
- -
-
- {$i18n.t('Feedback History')} - -
- - {feedbacks.length} -
- -
-
- - - -
-
-
+ + +
+
{$i18n.t('Leaderboard')}
+ -
- {#if (feedbacks ?? []).length === 0} -
- {$i18n.t('No feedbacks found')} -
- {:else} - { + selectedTab = 'feedbacks'; + }} > - - - - - - - - - - - - - - - {#each paginatedFeedbacks as feedback (feedback.id)} - - - - - - - - - - - {/each} - -
- {$i18n.t('User')} - - {$i18n.t('Models')} - - {$i18n.t('Result')} - - {$i18n.t('Updated At')} -
-
- -
- {feedback?.user?.name} -
-
-
-
-
-
- {#if feedback.data?.sibling_model_ids} -
- {feedback.data?.model_id} -
- - -
- {#if feedback.data.sibling_model_ids.length > 2} - - {feedback.data.sibling_model_ids.slice(0, 2).join(', ')}, {$i18n.t( - 'and {{COUNT}} more', - { COUNT: feedback.data.sibling_model_ids.length - 2 } - )} - {:else} - {feedback.data.sibling_model_ids.join(', ')} - {/if} -
-
- {:else} -
- {feedback.data?.model_id} -
- {/if} -
-
-
-
- {#if feedback.data.rating.toString() === '1'} - - {:else if feedback.data.rating.toString() === '0'} - - {:else if feedback.data.rating.toString() === '-1'} - - {/if} -
-
- {dayjs(feedback.updated_at * 1000).fromNow()} - - { - deleteFeedbackHandler(feedback.id); - }} - > - - -
- {/if} -
- - {#if feedbacks.length > 0} -
-
- {$i18n.t('Help us create the best community leaderboard by sharing your feedback history!')} -
- -
- - - -
+ + +
+
{$i18n.t('Feedbacks')}
+
- {/if} - {#if feedbacks.length > 10} - - {/if} - -
+
+ {#if selectedTab === 'leaderboard'} + + {:else if selectedTab === 'feedbacks'} + + {/if} +
+
{/if} diff --git a/src/lib/components/admin/Evaluations/Feedbacks.svelte b/src/lib/components/admin/Evaluations/Feedbacks.svelte new file mode 100644 index 000000000..d1caf769b --- /dev/null +++ b/src/lib/components/admin/Evaluations/Feedbacks.svelte @@ -0,0 +1,283 @@ + + +
+
+ {$i18n.t('Feedback History')} + +
+ + {feedbacks.length} +
+ +
+
+ + + +
+
+
+ +
+ {#if (feedbacks ?? []).length === 0} +
+ {$i18n.t('No feedbacks found')} +
+ {:else} + + + + + + + + + + + + + + + + {#each paginatedFeedbacks as feedback (feedback.id)} + + + + + + + + + + + {/each} + +
+ {$i18n.t('User')} + + {$i18n.t('Models')} + + {$i18n.t('Result')} + + {$i18n.t('Updated At')} +
+
+ +
+ {feedback?.user?.name} +
+
+
+
+
+
+ {#if feedback.data?.sibling_model_ids} +
+ {feedback.data?.model_id} +
+ + +
+ {#if feedback.data.sibling_model_ids.length > 2} + + {feedback.data.sibling_model_ids.slice(0, 2).join(', ')}, {$i18n.t( + 'and {{COUNT}} more', + { COUNT: feedback.data.sibling_model_ids.length - 2 } + )} + {:else} + {feedback.data.sibling_model_ids.join(', ')} + {/if} +
+
+ {:else} +
+ {feedback.data?.model_id} +
+ {/if} +
+
+
+
+ {#if feedback.data.rating.toString() === '1'} + + {:else if feedback.data.rating.toString() === '0'} + + {:else if feedback.data.rating.toString() === '-1'} + + {/if} +
+
+ {dayjs(feedback.updated_at * 1000).fromNow()} + + { + deleteFeedbackHandler(feedback.id); + }} + > + + +
+ {/if} +
+ +{#if feedbacks.length > 0} +
+
+ {$i18n.t('Help us create the best community leaderboard by sharing your feedback history!')} +
+ +
+ + + +
+
+{/if} + +{#if feedbacks.length > 10} + +{/if} diff --git a/src/lib/components/admin/Evaluations/Leaderboard.svelte b/src/lib/components/admin/Evaluations/Leaderboard.svelte new file mode 100644 index 000000000..59f6df916 --- /dev/null +++ b/src/lib/components/admin/Evaluations/Leaderboard.svelte @@ -0,0 +1,410 @@ + + +
+
+
+ {$i18n.t('Leaderboard')} +
+ +
+ + {rankedModels.length} +
+ +
+ +
+
+ +
+ { + loadEmbeddingModel(); + }} + /> +
+
+
+
+ +
+ {#if loadingLeaderboard} +
+
+ +
+
+ {/if} + {#if (rankedModels ?? []).length === 0} +
+ {$i18n.t('No models found')} +
+ {:else} + + + + + + + + + + + + {#each rankedModels as model, modelIdx (model.id)} + + + + + + + + + + {/each} + +
+ {$i18n.t('RK')} + + {$i18n.t('Model')} + + {$i18n.t('Rating')} + + {$i18n.t('Won')} + + {$i18n.t('Lost')} +
+
+ {model?.rating !== '-' ? modelIdx + 1 : '-'} +
+
+
+
+ {model.name} +
+ +
+ {model.name} +
+
+
+ {model.rating} + +
+ {#if model.stats.won === '-'} + - + {:else} + + {model.stats.won} + {/if} +
+
+
+ {#if model.stats.lost === '-'} + - + {:else} + + {model.stats.lost} + {/if} +
+
+ {/if} +
+ +
+
+
+ ⓘ {$i18n.t( + 'The evaluation leaderboard is based on the Elo rating system and is updated in real-time.' + )} +
+ {$i18n.t( + 'The leaderboard is currently in beta, and we may adjust the rating calculations as we refine the algorithm.' + )} +
+