LangfuseTraceExporter class
Streams trial events to Langfuse via /api/public/ingestion.
映射方式(一个 trial = 一棵 langfuse trace):
| dart_agent_core | Langfuse |
|---|---|
| Trial | trace-create:traceId = <runName>:<taskId>:<trialIndex> |
| LLM call | generation-create:observationId = uuid,parent = trace |
| Tool call | span-create:observationId = uuid,parent = trace |
| Score | score-create:traceId 关联到 trial 的 trace,dataType=NUMERIC |
| run-level aggregate | trace 上挂一个 run-summary trace + score |
配置从 LangfuseConfig.fromEnv 或显式构造,支持云端 / 自托管:
final exporter = LangfuseTraceExporter(LangfuseConfig.fromEnv());
final runner = EvalRunner(
environment: env,
harnessFactory: harness,
exporters: [JsonlTraceExporter(file), exporter],
...
);
所有 HTTP 都跑在后台 queue 里。即使 langfuse server 临时挂了或网络 抖动,也不会拖慢 eval run(最多丢几条 event)。
- Implemented types
Constructors
- LangfuseTraceExporter(LangfuseConfig config, {LangfuseClient? client})
Properties
- config → LangfuseConfig
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → Future< void> -
Flush + release resources. Called once at the end of the run.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onLLMCall(
{required Trial trial, required List< LLMMessage> requestMessages, required ModelConfig modelConfig, required ModelMessage? response, required Duration duration, Object? error}) → Future<void> -
Called for each LLM call.
responseis null on errors.override -
onRunEnd(
{required String runName, required String suiteName, required Map< String, double> aggregateScores}) → Future<void> -
Called when a dataset run completes. Implementations may use this
hook to record run-level aggregate scores (pass@k, F1 …).
override
-
onToolCall(
{required Trial trial, required ToolCallRecord record}) → Future< void> -
Called for each tool call.
override
-
onTrialEnd(
{required Trial trial, required Transcript transcript, required Outcome outcome, required List< Score> scores}) → Future<void> -
Called when trial finishes with the final transcript, outcome, and
scores. Implementations should attach all scores here.
override
-
onTrialStart(
Trial trial, EvalTask task) → Future< void> -
Called when a trial starts.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited