跳至主要內容

DeepEvalExporter

將 Tracing 資料傳送至 Confident AI,以進行評估及可觀測性分析。此匯出器由建基於 DeepEval SDK 的 @mastra/deepeval 匯出。

設定及用法請參閱 Confident AI 匯出器

建構函式
建構函式 的直接連結

new DeepEvalExporter(config?: DeepEvalExporterConfig)

DeepEvalExporterConfig
deepevalexporterconfig 的直接連結

interface DeepEvalExporterConfig extends BaseExporterConfig {
apiKey?: string
environment?: string
name?: string
tags?: string[]
metadata?: Record<string, any>
threadId?: string
userId?: string
testCaseId?: string
turnId?: string
metricCollection?: string
traceMetricCollection?: string
llmMetricCollection?: string
agentMetricCollection?: string
toolMetricCollectionMap?: Record<string, string>
prompt?: Prompt
debug?: boolean
traceCaptureSink?: (trace: Trace) => void
}

擴充 BaseExporterConfig,當中包括:

  • logger?: IMastraLogger - Logger 執行個體
  • logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error' - 日誌層級(預設:INFO)

apiKey?:

string
Confident AI API 金鑰。如未設定,則使用 CONFIDENT_API_KEY 環境變數。找不到金鑰時,匯出器會自行停用。

environment?:

string
Trace 環境。若未設定,會先使用 CONFIDENT_TRACE_ENVIRONMENT,然後使用 'development'。

name?:

string
套用至每個 Trace 的名稱。預設為 Mastra serviceName。

tags?:

string[]
套用至每個 Trace 的標籤。

metadata?:

Record<string, any>
套用至每個 Trace 的中繼資料。

threadId?:

string
套用至每個 Trace 的 thread ID。根 span 中繼資料內的 threadId 會按每個請求覆寫此值。

userId?:

string
套用至每個 Trace 的 user ID。根 span 中繼資料內的 userId 會按每個請求覆寫此值。

testCaseId?:

string
套用至每個 Trace 的測試個案 ID。根 span 中繼資料內的 testCaseId 會按每個請求覆寫此值。

turnId?:

string
套用至每個 Trace 的 turn ID。根 span 中繼資料內的 turnId 會按每個請求覆寫此值。

metricCollection?:

string
Trace 層級的指標集合。

traceMetricCollection?:

string
Trace 層級的指標集合。優先於 metricCollection。

llmMetricCollection?:

string
套用至 LLM span 的指標集合。

agentMetricCollection?:

string
套用至 Agent span 的指標集合。

toolMetricCollectionMap?:

Record<string, string>
按 Tool 名稱套用的指標集合。

prompt?:

Prompt
附加至 LLM span、由 Confident AI 管理的 prompt 連結。

debug?:

boolean
在控制台記錄匯出器設定及匯出錯誤。

traceCaptureSink?:

(trace: Trace) => void
在本機接收已完成的 Trace,而非將其發佈至 Confident AI。用於離線評估。

logLevel?:

'debug' | 'info' | 'warn' | 'error'
Logger 層級(預設:'info')

方法
方法 的直接連結

exportTracingEvent
exporttracingevent 的直接連結

async exportTracingEvent(event: TracingEvent): Promise<void>

將 tracing 事件匯出至 Confident AI。從 Mastra span 串流建立 Trace 樹狀結構,並在根 span 結束時發佈 Trace。

flush
flush 的直接連結

async flush(): Promise<void>

等待所有進行中的 Trace 發佈作業完成,而不關閉匯出器。

shutdown
shutdown 的直接連結

async shutdown(): Promise<void>

完成所有仍開啟的 Trace,並刷新待處理的發佈作業。

用法
用法 的直接連結

零設定(使用環境變數)
零設定(使用環境變數) 的直接連結

import { DeepEvalExporter } from '@mastra/deepeval'

// Reads from CONFIDENT_API_KEY, CONFIDENT_TRACE_ENVIRONMENT
const exporter = new DeepEvalExporter()

明確設定
明確設定 的直接連結

import { DeepEvalExporter } from '@mastra/deepeval'

const exporter = new DeepEvalExporter({
apiKey: process.env.CONFIDENT_API_KEY,
environment: 'production',
})

Span 類型對應
Span 類型對應 的直接連結

Mastra span 類型Confident AI span 類型
AGENT_RUN, WORKFLOW_RUNAGENT
MODEL_GENERATIONLLM
TOOL_CALL, MCP_TOOL_CALL, PROVIDER_TOOL_CALL, CLIENT_TOOL_CALLTOOL
RAG_EMBEDDING, RAG_VECTOR_OPERATIONRETRIEVER
所有其他已匯出的 span 類型CUSTOM

事件 span(例如 MODEL_CHUNK)會被捨棄。