-
Notifications
You must be signed in to change notification settings - Fork 202
feat: add reliability score #673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
20f8b64
38c0f12
440dd52
5043e3a
8cddfb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // src/components/TrustBadge.jsx | ||
| import React from 'react'; | ||
|
|
||
| const TrustBadge = ({ score, badge }) => { | ||
| const getBadgeColor = (badge) => { | ||
| switch (badge) { | ||
| case 'High': return 'bg-green-100 text-green-700 border-green-200'; | ||
| case 'Medium': return 'bg-yellow-100 text-yellow-700 border-yellow-200'; | ||
| default: return 'bg-red-100 text-red-700 border-red-200'; | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className={`px-2 py-0.5 rounded-full border text-[10px] font-semibold ${getBadgeColor(badge)}`}> | ||
| {badge} Trust • {score}/100 | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default TrustBadge; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| export const calculateReliabilityScore = (agent) => { | ||||||||||||||||||||||||||||||||||||||||||
| // 1. Agar agent object hi nahi mila | ||||||||||||||||||||||||||||||||||||||||||
| if (!agent) return { score: 0, badge: 'Low' }; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // 2. Data extraction (agar properties nahi hain toh 0 lo) | ||||||||||||||||||||||||||||||||||||||||||
| const usage = agent.usageCount || 0; | ||||||||||||||||||||||||||||||||||||||||||
| const rating = agent.rating || 0; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // 3. Scoring Logic: | ||||||||||||||||||||||||||||||||||||||||||
| // Agar real data hai toh use karo, agar nahi hai toh random score do (UI testing ke liye) | ||||||||||||||||||||||||||||||||||||||||||
| let score = 0; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| if (usage > 0 || rating > 0) { | ||||||||||||||||||||||||||||||||||||||||||
| score = (rating * 15) + (Math.min(usage, 500) / 10); | ||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||
| // Fallback: Random score between 40 and 95 taaki dashboard bhara hua lage | ||||||||||||||||||||||||||||||||||||||||||
| score = Math.floor(Math.random() * (95 - 40 + 1) + 40); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Random fallback fabricates a "Trust Score" — undermines the feature's purpose. When Consider returning an explicit "Unrated"/"Not enough data" state instead of a fabricated number. ♻️ Proposed fix let score = 0;
-
if (usage > 0 || rating > 0) {
score = (rating * 15) + (Math.min(usage, 500) / 10);
} else {
- // Fallback: Random score between 40 and 95 taaki dashboard bhara hua lage
- score = Math.floor(Math.random() * (95 - 40 + 1) + 40);
+ // No usage/rating data available; surface this explicitly rather than fabricating a score.
+ return { score: null, badge: 'Unrated' };
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| const finalScore = Math.min(Math.max(Math.round(score), 0), 100); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| // 4. Badge Logic | ||||||||||||||||||||||||||||||||||||||||||
| let badge = 'Low'; | ||||||||||||||||||||||||||||||||||||||||||
| if (finalScore >= 80) badge = 'High'; | ||||||||||||||||||||||||||||||||||||||||||
| else if (finalScore >= 50) badge = 'Medium'; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| return { score: finalScore, badge }; | ||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Missing dark-mode color variants.
Colors (
bg-green-100 text-green-700, etc.) are light-theme only. Per the PR screenshots, the app is dark-themed throughout (AgentCard.jsxconsistently pairs classes withdark:variants, e.g.dark:bg-surface-input dark:text-text-muted). Without dark variants, the light pastel backgrounds will look out of place / have poor contrast against the dark card background.♻️ Proposed fix
const getBadgeColor = (badge) => { switch (badge) { - case 'High': return 'bg-green-100 text-green-700 border-green-200'; - case 'Medium': return 'bg-yellow-100 text-yellow-700 border-yellow-200'; - default: return 'bg-red-100 text-red-700 border-red-200'; + case 'High': return 'bg-green-100 text-green-700 border-green-200 dark:bg-green-500/10 dark:text-green-400 dark:border-green-500/20'; + case 'Medium': return 'bg-yellow-100 text-yellow-700 border-yellow-200 dark:bg-yellow-500/10 dark:text-yellow-400 dark:border-yellow-500/20'; + default: return 'bg-red-100 text-red-700 border-red-200 dark:bg-red-500/10 dark:text-red-400 dark:border-red-500/20'; } };📝 Committable suggestion
🤖 Prompt for AI Agents