← 全部示例
// 生产控制

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 APIOpenMultiAgentLLMAdapter
生产控制59 行

在仓库的克隆里运行这个文件:

terminal
npx tsx packages/core/examples/patterns/eval-online-sampling.ts
展开完整同步源码 · 59 行

完整示例,从固定的 Framework commit 同步。

patterns/eval-online-sampling.ts
/**
* 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()
}
在 GitHub 查看 / 编辑
// 企业服务

要把它用到生产环境?

open-multi-agent 采用 MIT 许可、可自行免费运行。当你需要在期限内交付、集成,或获得支持时,元定义科技(YuanASI)提供商业交付与支持。

// 直接联系

把 Open Multi-Agent 用进真实业务

联系框架作者本人,帮你梳理 AI 落地目标、让 AI 真正与业务结合

可提供的工程服务
S-01

AI Agent 定制开发

业务梳理、Agent 设计、Prompt 评估、生产部署、私有化与持续支持。

S-02

多智能体系统集成

多 Agent 架构编排、RAG、CRM / ERP / API 对接、性能与稳定性调优。

S-03

企业 AI 咨询

AI 场景评估、技术选型、POC、ROI 估算与落地路线规划。