MCPcopy Create free account
hub / github.com/CaviraOSS/OpenReason / learningExamples

Function learningExamples

examples/code/learning-example.ts:25–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23};
24
25async function learningExamples() {
26 const traces: TraceSnapshot[] = [];
27 const prompts = [
28 "2 + 2",
29 "explain gravity",
30 "should ai have rights?",
31 "capital of france",
32 "compare capitalism vs socialism"
33 ];
34
35 for (const query of prompts) {
36 const result = await openreason.reason(query);
37 traces.push({ query, mode: result.mode, confidence: result.confidence, latency: result.latency });
38 console.log(`query: ${query}`);
39 console.log(` mode: ${result.mode}`);
40 console.log(` confidence: ${result.confidence.toFixed(2)}`);
41 console.log(` latency: ${result.latency}ms`);
42 }
43
44 const avgLatency = traces.reduce((sum, t) => sum + t.latency, 0) / traces.length;
45 const avgConfidence = traces.reduce((sum, t) => sum + t.confidence, 0) / traces.length;
46
47 console.log("\naverage stats", { avgLatency, avgConfidence });
48
49 const evolution = get_evolution_stats();
50 console.log("\nprompt evolution telemetry", evolution);
51}
52
53learningExamples().catch(console.error);

Callers 1

Calls 1

get_evolution_statsFunction · 0.85

Tested by

no test coverage detected