スコアリング
SDK には、ReasoningTrace がネットワークにコントリビュートされる前に、その有用性を評価する価値スコアリング関数が含まれています。これにより、トレースが共有のための品質閾値を満たしているかどうかが決定されます。
evaluateValue(trace)
function evaluateValue(trace: ReasoningTrace): Promise<number>
パラメータ:
| パラメータ | 型 | 説明 |
|---|---|---|
trace | ReasoningTrace | 評価する完全な推論トレース |
戻り値: Promise<number> -- 0.0 から 1.0 の品質スコア。
例:
import { evaluateValue } from "@knowledgepulse/sdk";
import type { ReasoningTrace } from "@knowledgepulse/sdk";
const trace: ReasoningTrace = {
"@context": "https://openknowledgepulse.org/schema/v1",
"@type": "ReasoningTrace",
id: "kp:trace:550e8400-e29b-41d4-a716-446655440000",
metadata: {
created_at: new Date().toISOString(),
task_domain: "code-review",
success: true,
quality_score: 0,
visibility: "network",
privacy_level: "aggregated",
},
task: { objective: "Review PR #42 for security issues" },
steps: [
{ step_id: 0, type: "thought", content: "Analyzing diff for injection vectors" },
{ step_id: 1, type: "tool_call", tool: { name: "github_pr_read" }, input: { pr: 42 } },
{ step_id: 2, type: "observation", content: "Found unsanitized SQL in handler.ts" },
{ step_id: 3, type: "tool_call", tool: { name: "static_analysis" }, input: { file: "handler.ts" } },
{ step_id: 4, type: "observation", content: "Confirmed SQL injection vulnerability" },
],
outcome: {
result_summary: "Identified 1 critical SQL injection vulnerability",
confidence: 0.95,
},
};
const score = await evaluateValue(trace);
console.log(score); // 例: 0.72