Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(llama-index): add attribute to span for llm request type in dispatcher wrapper #2141

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def instrument_with_dispatcher(tracer: Tracer):
@dont_throw
def _set_llm_chat_request(event, span) -> None:
model_dict = event.model_dict
span.set_attribute(SpanAttributes.LLM_REQUEST_TYPE, LLMRequestTypeValues.CHAT.value)
span.set_attribute(SpanAttributes.LLM_REQUEST_MODEL, model_dict.get("model"))
span.set_attribute(
SpanAttributes.LLM_REQUEST_TEMPERATURE, model_dict.get("temperature")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def multiply(a: int, b: int) -> int:
assert llm_span_1.parent is not None
assert llm_span_2.parent is not None

assert llm_span_1.attributes[SpanAttributes.LLM_REQUEST_TYPE] == "chat"
assert (
llm_span_1.attributes[SpanAttributes.LLM_REQUEST_MODEL] == "gpt-3.5-turbo-0613"
)
Expand All @@ -93,6 +94,7 @@ def multiply(a: int, b: int) -> int:
assert llm_span_1.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS] == 479
assert llm_span_1.attributes[SpanAttributes.LLM_USAGE_TOTAL_TOKENS] == 522

assert llm_span_2.attributes[SpanAttributes.LLM_REQUEST_TYPE] == "chat"
assert (
llm_span_2.attributes[SpanAttributes.LLM_REQUEST_MODEL] == "gpt-3.5-turbo-0613"
)
Expand Down