Skip to content

Commit

Permalink
use OpenInferenceSpanKindValues
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerHYang committed Jan 9, 2024
1 parent dbe7bc3 commit 4cd42cd
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
_io_value_and_type,
)
from openinference.instrumentation.openai._with_span import _WithSpan
from openinference.semconv.trace import SpanAttributes
from openinference.semconv.trace import SpanAttributes, OpenInferenceSpanKindValues
from opentelemetry import context as context_api
from opentelemetry import trace as trace_api
from opentelemetry.context import _SUPPRESS_INSTRUMENTATION_KEY
Expand All @@ -54,10 +54,6 @@
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

_LLM_SPAN_KIND = "LLM"
_EMBEDDING_SPAN_KIND = "EMBEDDING"


class _WithTracer(ABC):
__slots__ = (
"_tracer",
Expand All @@ -79,7 +75,7 @@ def _start_as_current_span(
cast_to: type,
request_options: Mapping[str, Any],
) -> Iterator[_WithSpan]:
span_kind = _EMBEDDING_SPAN_KIND if cast_to is CreateEmbeddingResponse else _LLM_SPAN_KIND
span_kind = OpenInferenceSpanKindValues.EMBEDDING if cast_to is CreateEmbeddingResponse else OpenInferenceSpanKindValues.LLM
attributes: Dict[str, AttributeValue] = {SpanAttributes.OPENINFERENCE_SPAN_KIND: span_kind}
try:
attributes.update(_as_input_attributes(_io_value_and_type(request_options)))
Expand Down

0 comments on commit 4cd42cd

Please sign in to comment.