microsoft.opentelemetry.a365.core.inference_scope module
- class microsoft.opentelemetry.a365.core.inference_scope.InferenceScope(request, details, agent_details, user_details=None, span_details=None)[source]
Bases:
OpenTelemetryScopeProvides OpenTelemetry tracing scope for generative AI inference operations.
- static start(request, details, agent_details, user_details=None, span_details=None)[source]
Creates and starts a new scope for inference tracing.
- Parameters:
request (
Request) – Request details for the inferencedetails (
InferenceCallDetails) – The details of the inference callagent_details (
AgentDetails) – The details of the agent making the calluser_details (
UserDetails|None) – Optional human user detailsspan_details (
SpanDetails|None) – Optional span configuration (parent context, timing)
- Return type:
- Returns:
A new InferenceScope instance
- record_input_messages(messages)[source]
Records the input messages for telemetry tracking.
Accepts plain strings (auto-wrapped as OTEL ChatMessage with role
user) or a versionedInputMessageswrapper.- Parameters:
messages (
Union[str,list[str],InputMessages]) – List of input message strings or an InputMessages wrapper- Return type:
- record_output_messages(messages)[source]
Records the output messages for telemetry tracking.
Accepts plain strings (auto-wrapped as OTEL OutputMessage with role
assistant) or a versionedOutputMessageswrapper.- Parameters:
messages (
Union[str,list[str],OutputMessages]) – List of output message strings or an OutputMessages wrapper- Return type:
- record_input_tokens(input_tokens)[source]
Records the number of input tokens for telemetry tracking.
- record_output_tokens(output_tokens)[source]
Records the number of output tokens for telemetry tracking.