← 全部示例
// 生产控制
Online evaluation sampling — asynchronous scoring with a durable local FileEvalStore.
Sample live runs for asynchronous scoring in a durable FileEvalStore with explicit shutdown.
01 运行
OMA API
OpenMultiAgentLLMAdapter在仓库的克隆里运行这个文件:
npx tsx packages/core/examples/patterns/eval-online-sampling.ts
展开完整同步源码 · 59 行
完整示例,从固定的 Framework commit 同步。
/*** Online evaluation sampling — asynchronous scoring with a durable local FileEvalStore.** Run:* npx tsx packages/core/examples/patterns/eval-online-sampling.ts** This fixture uses a local adapter. Set OMA_EVAL_STORE_PATH to choose the NDJSON file.*/import { OpenMultiAgent, type LLMAdapter } from '../../src/index.js'import { costBudgetScorer } from '../../src/eval/index.js'import { FileEvalStore } from '../../src/eval/file.js'const adapter: LLMAdapter = {name: 'fixture-online',async chat(_messages, options) {return {id: 'fixture-online-response',content: [{ type: 'text', text: 'Evaluation runs after this response settles.' }],model: options.model,stop_reason: 'end_turn',usage: { input_tokens: 12, output_tokens: 7 },}},async *stream() {},}const path = process.env['OMA_EVAL_STORE_PATH'] ?? './eval-results/online-eval.ndjson'const store = await FileEvalStore.open(path)const orchestrator = new OpenMultiAgent({evaluation: {scorers: [costBudgetScorer({ maxTokens: 100 })],sample: 1,maxConcurrent: 1,maxQueueLength: 10,budget: { maxEvaluationsPerMinute: 10 },store,},})try {const result = await orchestrator.runAgent({name: 'online-fixture',model: 'fixture-model-v1',adapter,}, 'Explain when online evaluation runs.')const flush = await orchestrator.evaluation.forceFlush({ timeoutMs: 5_000 })await store.flush()console.log(JSON.stringify({businessOutput: result.output,evaluation: flush,stats: orchestrator.evaluation.getStats(),store: path,}, null, 2))} finally {await orchestrator.evaluation.shutdown({ timeoutMs: 5_000 })await store.flush()await store.close()}
// 企业服务
要把它用到生产环境?
open-multi-agent 采用 MIT 许可、可自行免费运行。当你需要在期限内交付、集成,或获得支持时,元定义科技(YuanASI)提供商业交付与支持。