invoke_agent スパンを生成し、その
ターンのトレースのルートとして機能します。常に ROOT_CONTEXT の下で開始されるため、
別の OTel でインストルメントされた
ライブラリから誤って親を継承することはありません。
weave.startTurn() (または conversation.startTurn()) で作成され、
end() で終了します。非同期チェーンでアクティブにできる Turn は 1 つだけです。
子要素 (LLM、Tool、SubAgent) は、startLLM、startTool、
startSubagent メソッドを介して接続されます。
例
階層
-
SpanBase↳Turn
目次
プロパティ
メソッド
プロパティ
agentName
Readonly agentName: string
定義元
model
Readonly model: string
定義元
メソッド
addEvent
name, attributes?, startTime?): this
スパンに名前付きイベントを追加します。コンテキストの圧縮、
ツールループの検出、ガードレールの作動など、スパンではない時点を示すのに便利です。警告を出し、
end() の後に呼び出しても何も行いません。OTel の Span.addEvent に対応しています。
パラメーター
| 名 | タイプ |
|---|---|
name | string |
attributes? | Attributes |
startTime? | TimeInput |
戻り値
this
例
継承元
定義元
end
opts?): void
Turn スパン を終了します。冪等です。失敗としてマークするには、error を渡します。終了時刻を過去にさかのぼって設定するには、endTime を渡します。
パラメーター
| 名 | タイプ |
|---|---|
opts? | SpanEndOptions |
戻り値
void
定義元
setAttribute
key, value): this
パラメーター
| 名 | タイプ |
|---|---|
key | string |
value | AttributeValue |
戻り値
this
定義元
setAttributes
attributes): this
スパン に複数の属性を一度に設定します。end() の後は警告を出し、何も行いません。OTel の Span.setAttributes (および Python SDK の set_attributes) と同様の動作です。
パラメーター
| 名 | タイプ |
|---|---|
attributes | Attributes |
戻り値
this
例
継承元
定義元
startLLM
opts): LLM
この Turn 配下で子 LLM スパン を開始します。
パラメーター
| 名 | タイプ |
|---|---|
opts | LLMInit |
戻り値
LLM
定義元
startSubagent
opts): SubAgent
この Turn の配下に、子 SubAgent のスパンを開始します。
パラメーター
| 名 | タイプ |
|---|---|
opts | SubAgentInit |
戻り値
SubAgent
定義元
startTool
opts): Tool
この Turn 配下で子 Tool の スパン を開始します。
パラメーター
| 名 | タイプ |
|---|---|
opts | ToolInit |
戻り値
Tool
定義元
create
opts?): Turn
パラメーター
| 名 | タイプ |
|---|---|
opts | TurnInit & { conversationId?: string } |
戻り値
Turn