Skip to content

Commit d0c4980

Browse files
authored
agent scorer (#17)
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][DIGIMON-XXXX] Your PR title ...'. 2. Be sure to keep the PR description updated to reflect all changes. 3. Please write your PR title to summarize what this PR proposes. 4. If possible, provide a concise example to reproduce the issue for a faster review. --> ### What changes were proposed in this pull request? <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below. 1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers. 2. If you fix some SQL features, you can provide some references of other DBMSes. 3. If there is design documentation, please add the link. 4. If there is a discussion in the mailing list, please add the link. --> ### Why are the changes needed? <!-- Please clarify why the changes are needed. For instance, 1. If you propose a new API, clarify the use case for a new API. 2. If you fix a bug, you can clarify why it is a bug. --> ### Does this PR introduce _any_ user-facing change? <!-- Note that it means *any* user-facing change including all aspects such as the documentation fix. If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible. If possible, please also clarify if this is a user-facing change compared to the released Digimon Engine versions or within the unreleased branches such as master. If no, write 'No'. --> ### How was this patch tested? <!-- If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. -->
1 parent dd74e3a commit d0c4980

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

core/types.ts

+18
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,21 @@ export interface ArtifactUploadResponse {
2626
url: string | null;
2727
error: string | null;
2828
}
29+
30+
export interface ScoreMetrics {
31+
[key: string]: number;
32+
communicationClarity?: number;
33+
empathyLevel?: number;
34+
responseAppropriateness?: number;
35+
contextualAwareness?: number;
36+
resourceManagement?: number;
37+
decisionMaking?: number;
38+
riskAssessment?: number;
39+
marketAwareness?: number;
40+
}
41+
42+
export interface SkillScore {
43+
score: number;
44+
metrics: ScoreMetrics;
45+
timestamp: Date;
46+
}

core/utils/agentScorer.ts

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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

Comments
 (0)