set_span_attributes

API reference for set_span_attributes

set_span_attributes

set_span_attributes()

Set custom attributes on a Model or AgentTool that can be accessed by logging hooks.

This function stores key-value pairs as attributes on the object, making them accessible to hooks during model invocation events. Attributes are automatically scoped to async or sync contexts.

Parameters

Parameter
Type
Required
Default
Description

obj

Model | AgentTool

None

The object to set the attribute on (Model or AgentTool instance)

Example

set_span_attributes

set_span_attributes()

Set custom attributes on a Model or AgentTool that can be accessed by logging hooks.

This function stores key-value pairs as attributes on the object, making them accessible to hooks during model invocation events. Attributes are automatically scoped to async or sync contexts.

Parameters

Parameter
Type
Required
Default
Description

obj

Model | AgentTool

None

The object to set the attribute on (Model or AgentTool instance)

Example

from strands.models.openai import OpenAIModel
from fiddler_strandsagents import set_span_attributes

model = OpenAIModel(api_key="...", model_id="gpt-4")
set_span_attributes(model, model_id="gpt-4", temperature=0.7)

Last updated

Was this helpful?