Skip to content

Commit 05589e8

Browse files
fix(litellm): Classify embeddings correctly
1 parent f99a17b commit 05589e8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sentry_sdk/integrations/litellm.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
except ImportError:
1919
raise DidNotEnable("LiteLLM not installed")
2020

21+
_CALL_TYPE_TO_OPERATION = {
22+
"embedding": "embeddings",
23+
"completion": "chat",
24+
}
25+
2126

2227
def _get_metadata_dict(kwargs):
2328
# type: (Dict[str, Any]) -> Dict[str, Any]
@@ -48,8 +53,11 @@ def _input_callback(kwargs):
4853
model = full_model
4954
provider = "unknown"
5055

51-
messages = kwargs.get("messages", [])
52-
operation = "chat" if messages else "embeddings"
56+
call_type = kwargs.get("call_type", None)
57+
if call_type not in _CALL_TYPE_TO_OPERATION:
58+
return
59+
60+
operation = _CALL_TYPE_TO_OPERATION[call_type]
5361

5462
# Start a new span/transaction
5563
span = get_start_span_function()(
@@ -71,6 +79,7 @@ def _input_callback(kwargs):
7179
set_data_normalized(span, SPANDATA.GEN_AI_OPERATION_NAME, operation)
7280

7381
# Record messages if allowed
82+
messages = kwargs.get("messages", [])
7483
if messages and should_send_default_pii() and integration.include_prompts:
7584
set_data_normalized(
7685
span, SPANDATA.GEN_AI_REQUEST_MESSAGES, messages, unpack=False

0 commit comments

Comments
 (0)