|
| 1 | +import { Agent } from "../agent/base_agent"; |
| 2 | +import { ScoreMetrics, SkillScore } from "../types"; |
| 3 | + |
| 4 | +export class AgentScorer { |
| 5 | + /** |
| 6 | + * Scores an agent's social skills based on various metrics |
| 7 | + * @param agent The agent to evaluate |
| 8 | + * @returns A score between 0-100 |
| 9 | + */ |
| 10 | + public static scoreSocialSkills(agent: Agent): SkillScore { |
| 11 | + const metrics: ScoreMetrics = { |
| 12 | + communicationClarity: this.evaluateCommunicationClarity(agent), |
| 13 | + empathyLevel: this.evaluateEmpathy(agent), |
| 14 | + responseAppropriateness: this.evaluateResponseAppropriateness(agent), |
| 15 | + contextualAwareness: this.evaluateContextAwareness(agent), |
| 16 | + }; |
| 17 | + |
| 18 | + const weightedScore = this.calculateWeightedScore(metrics); |
| 19 | + |
| 20 | + return { |
| 21 | + score: weightedScore, |
| 22 | + metrics, |
| 23 | + timestamp: new Date(), |
| 24 | + }; |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Scores an agent's financial skills based on various metrics |
| 29 | + * @param agent The agent to evaluate |
| 30 | + * @returns A score between 0-100 |
| 31 | + */ |
| 32 | + public static scoreFinancialSkills(agent: Agent): SkillScore { |
| 33 | + const metrics: ScoreMetrics = { |
| 34 | + resourceManagement: this.evaluateResourceManagement(agent), |
| 35 | + decisionMaking: this.evaluateFinancialDecisions(agent), |
| 36 | + riskAssessment: this.evaluateRiskAssessment(agent), |
| 37 | + marketAwareness: this.evaluateMarketAwareness(agent), |
| 38 | + }; |
| 39 | + |
| 40 | + const weightedScore = this.calculateWeightedScore(metrics); |
| 41 | + |
| 42 | + return { |
| 43 | + score: weightedScore, |
| 44 | + metrics, |
| 45 | + timestamp: new Date(), |
| 46 | + }; |
| 47 | + } |
| 48 | + |
| 49 | + private static calculateWeightedScore(metrics: ScoreMetrics): number { |
| 50 | + const weights = { |
| 51 | + communicationClarity: 0.25, |
| 52 | + empathyLevel: 0.25, |
| 53 | + responseAppropriateness: 0.25, |
| 54 | + contextualAwareness: 0.25, |
| 55 | + resourceManagement: 0.25, |
| 56 | + decisionMaking: 0.25, |
| 57 | + riskAssessment: 0.25, |
| 58 | + marketAwareness: 0.25, |
| 59 | + }; |
| 60 | + |
| 61 | + const totalScore = Object.entries(metrics).reduce((sum, [key, value]) => { |
| 62 | + return sum + value * weights[key as keyof typeof weights]; |
| 63 | + }, 0); |
| 64 | + |
| 65 | + return Math.min(Math.round(totalScore * 100), 100); |
| 66 | + } |
| 67 | + |
| 68 | + private static evaluateCommunicationClarity(agent: Agent): number { |
| 69 | + // Evaluate based on message clarity, grammar, and structure |
| 70 | + console.log("Evaluating communication clarity", agent); |
| 71 | + return 0.8; // Placeholder implementation |
| 72 | + } |
| 73 | + |
| 74 | + private static evaluateEmpathy(agent: Agent): number { |
| 75 | + // Evaluate emotional intelligence and response appropriateness |
| 76 | + console.log("Evaluating empathy", agent); |
| 77 | + return 0.7; // Placeholder implementation |
| 78 | + } |
| 79 | + |
| 80 | + private static evaluateResponseAppropriateness(agent: Agent): number { |
| 81 | + // Evaluate if responses match the context and tone |
| 82 | + console.log("Evaluating response appropriateness", agent); |
| 83 | + return 0.9; // Placeholder implementation |
| 84 | + } |
| 85 | + |
| 86 | + private static evaluateContextAwareness(agent: Agent): number { |
| 87 | + // Evaluate understanding of conversation context |
| 88 | + console.log("Evaluating context awareness", agent); |
| 89 | + return 0.85; // Placeholder implementation |
| 90 | + } |
| 91 | + |
| 92 | + private static evaluateResourceManagement(agent: Agent): number { |
| 93 | + // Evaluate how well the agent manages resources |
| 94 | + console.log("Evaluating resource management", agent); |
| 95 | + return 0.75; // Placeholder implementation |
| 96 | + } |
| 97 | + |
| 98 | + private static evaluateFinancialDecisions(agent: Agent): number { |
| 99 | + // Evaluate quality of financial decision making |
| 100 | + console.log("Evaluating financial decisions", agent); |
| 101 | + return 0.8; // Placeholder implementation |
| 102 | + } |
| 103 | + |
| 104 | + private static evaluateRiskAssessment(agent: Agent): number { |
| 105 | + // Evaluate risk assessment capabilities |
| 106 | + console.log("Evaluating risk assessment", agent); |
| 107 | + return 0.7; // Placeholder implementation |
| 108 | + } |
| 109 | + |
| 110 | + private static evaluateMarketAwareness(agent: Agent): number { |
| 111 | + // Evaluate understanding of market conditions |
| 112 | + console.log("Evaluating market awareness", agent); |
| 113 | + return 0.85; // Placeholder implementation |
| 114 | + } |
| 115 | +} |
0 commit comments