MCPcopy Create free account
hub / github.com/astercloud/aster / main

Function main

client-sdks/client-js/examples/eval-usage.ts:8–332  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import { AsterClient } from "@aster/client-js";
7
8async function main() {
9 console.log("=".repeat(70));
10 console.log("AsterClient Eval 功能演示");
11 console.log("=".repeat(70));
12
13 // 初始化客户端
14 const client = new AsterClient({
15 baseUrl: "http://localhost:8080",
16 apiKey: process.env.ASTER_API_KEY,
17 });
18
19 // ========================================================================
20 // 1. 创建测试用例集
21 // ========================================================================
22 console.log("\n📝 1. 创建测试用例集");
23 console.log("-".repeat(70));
24
25 const testCaseSet = await client.evals.createTestCaseSet(
26 "Q&A Test Cases",
27 [
28 {
29 id: "test-1",
30 name: "Basic Greeting",
31 input: "Hello, how are you?",
32 expectedOutput: "I am doing well, thank you for asking!",
33 tags: ["greeting", "simple"],
34 },
35 {
36 id: "test-2",
37 name: "Technical Question",
38 input: "What is the difference between HTTP and HTTPS?",
39 expectedOutput: "HTTPS is the secure version of HTTP. It uses SSL/TLS encryption to protect data in transit.",
40 tags: ["technical", "security"],
41 },
42 {
43 id: "test-3",
44 name: "Complex Query",
45 input: "Explain how machine learning models are trained",
46 expectedOutput: "Machine learning models are trained by feeding them data and adjusting their parameters to minimize prediction errors.",
47 tags: ["ml", "complex"],
48 },
49 ],
50 "A collection of Q&A test cases for agent evaluation",
51 );
52
53 console.log("✅ 测试用例集已创建:", testCaseSet.id);
54 console.log(` 名称: ${testCaseSet.name}`);
55 console.log(` 测试用例数: ${testCaseSet.testCases.length}`);
56
57 // ========================================================================
58 // 2. 快速单次评估
59 // ========================================================================
60 console.log("\n⚡ 2. 快速单次评估");
61 console.log("-".repeat(70));
62
63 // 创建一个测试 Agent
64 const agent = await client.agents.createFromTemplate("assistant", {
65 name: "Test Assistant",

Callers 1

eval-usage.tsFile · 0.70

Calls 15

logMethod · 0.80
createTestCaseSetMethod · 0.80
createFromTemplateMethod · 0.80
quickEvalMethod · 0.80
batchEvalMethod · 0.80
compareAgentsMethod · 0.80
generateReportMethod · 0.80
exportResultMethod · 0.80
listTestCaseSetsMethod · 0.80
updateTestCaseSetMethod · 0.80
deleteTestCaseSetMethod · 0.80

Tested by

no test coverage detected