Skip to content

Commit f407e6b

Browse files
fix tests
1 parent 05589e8 commit f407e6b

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

sentry_sdk/integrations/litellm.py

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

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

2722
def _get_metadata_dict(kwargs):
2823
# type: (Dict[str, Any]) -> Dict[str, Any]
@@ -54,10 +49,10 @@ def _input_callback(kwargs):
5449
provider = "unknown"
5550

5651
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]
52+
if call_type == "embedding":
53+
operation = "embeddings"
54+
else:
55+
operation = "chat"
6156

6257
# Start a new span/transaction
6358
span = get_start_span_function()(

tests/integrations/litellm/test_litellm.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,15 @@ def test_embeddings_create(sentry_init, capture_events):
208208
)
209209
events = capture_events()
210210

211+
messages = [{"role": "user", "content": "Some text to test embeddings"}]
211212
mock_response = MockEmbeddingResponse()
212213

213214
with start_transaction(name="litellm test"):
214-
# For embeddings, messages would be empty
215215
kwargs = {
216216
"model": "text-embedding-ada-002",
217217
"input": "Hello!",
218-
"messages": [], # Empty for embeddings
218+
"messages": messages,
219+
"call_type": "embeddings",
219220
}
220221

221222
_input_callback(kwargs)

0 commit comments

Comments
 (0)