nat.data_models.span#
Attributes#
Classes#
Create a collection of name/value pairs. |
|
Create a collection of name/value pairs. |
|
Create a collection of name/value pairs. |
|
Create a collection of name/value pairs. |
|
Functions#
|
Convert an event type to a span kind. |
Module Contents#
- logger#
- _SPAN_PREFIX#
- class SpanKind(*args, **kwds)#
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- LLM = 'LLM'#
- TOOL = 'TOOL'#
- WORKFLOW = 'WORKFLOW'#
- TASK = 'TASK'#
- FUNCTION = 'FUNCTION'#
- CUSTOM = 'CUSTOM'#
- SPAN = 'SPAN'#
- EMBEDDER = 'EMBEDDER'#
- RETRIEVER = 'RETRIEVER'#
- AGENT = 'AGENT'#
- RERANKER = 'RERANKER'#
- GUARDRAIL = 'GUARDRAIL'#
- EVALUATOR = 'EVALUATOR'#
- UNKNOWN = 'UNKNOWN'#
- EVENT_TYPE_TO_SPAN_KIND_MAP#
- event_type_to_span_kind(event_type: str) SpanKind #
Convert an event type to a span kind.
- Args:
event_type (str): The event type to convert.
- Returns:
SpanKind: The span kind.
- class SpanAttributes(*args, **kwds)#
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- NAT_SPAN_KIND = 'Uninferable.span.kind'#
- INPUT_VALUE = 'input.value'#
- INPUT_MIME_TYPE = 'input.mime_type'#
- LLM_TOKEN_COUNT_PROMPT = 'llm.token_count.prompt'#
- LLM_TOKEN_COUNT_COMPLETION = 'llm.token_count.completion'#
- LLM_TOKEN_COUNT_TOTAL = 'llm.token_count.total'#
- OUTPUT_VALUE = 'output.value'#
- OUTPUT_MIME_TYPE = 'output.mime_type'#
- NAT_USAGE_NUM_LLM_CALLS = 'Uninferable.usage.num_llm_calls'#
- NAT_USAGE_SECONDS_BETWEEN_CALLS = 'Uninferable.usage.seconds_between_calls'#
- NAT_USAGE_TOKEN_COUNT_PROMPT = 'Uninferable.usage.token_count.prompt'#
- NAT_USAGE_TOKEN_COUNT_COMPLETION = 'Uninferable.usage.token_count.completion'#
- NAT_USAGE_TOKEN_COUNT_TOTAL = 'Uninferable.usage.token_count.total'#
- NAT_EVENT_TYPE = 'Uninferable.event_type'#
- class MimeTypes(*args, **kwds)#
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- TEXT = 'text/plain'#
- JSON = 'application/json'#
- class SpanStatusCode(*args, **kwds)#
Bases:
enum.Enum
Create a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- OK = 'OK'#
- ERROR = 'ERROR'#
- UNSET = 'UNSET'#
- class SpanEvent(/, **data: Any)#
Bases:
pydantic.BaseModel
- class SpanStatus(/, **data: Any)#
Bases:
pydantic.BaseModel
- code: SpanStatusCode = None#
- class SpanContext(/, **data: Any)#
Bases:
pydantic.BaseModel
- class Span(/, **data: Any)#
Bases:
pydantic.BaseModel
- context: SpanContext | None = None#
- status: SpanStatus = None#
- classmethod set_default_context(v: SpanContext | None) SpanContext #
Set the default context if the context is not provided.
- Args:
v (SpanContext | None): The context to set.
- Returns:
SpanContext: The context.
- set_attribute(key: str, value: Any) None #
Set the attribute of the span.
- Args:
key (str): The key of the attribute. value (Any): The value of the attribute.