Skip to content

Commit

Permalink
Fix tests and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-sentry committed Apr 3, 2024
1 parent 8084a18 commit 7e7b91d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/langchain.py
Expand Up @@ -364,7 +364,7 @@ def on_tool_end(self, output, *, run_id, **kwargs):
if not span_data:
return

Check warning on line 365 in sentry_sdk/integrations/langchain.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/integrations/langchain.py#L365

Added line #L365 was not covered by tests
if should_send_default_pii() and self.include_prompts:
set_data_normalized(span_data.span, SPANDATA.AI_RESPONSES, [output])
set_data_normalized(span_data.span, SPANDATA.AI_RESPONSES, output)
span_data.span.__exit__(None, None, None)
del self.span_map[run_id]

Check warning on line 369 in sentry_sdk/integrations/langchain.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/integrations/langchain.py#L367-L369

Added lines #L367 - L369 were not covered by tests

Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/openai.py
Expand Up @@ -78,9 +78,9 @@ def _calculate_chat_completion_usage(
messages, response, span, streaming_message_responses=None
):
# type: (Iterable[ChatCompletionMessageParam], Any, Span, Optional[List[str]]) -> None
completion_tokens = 0
prompt_tokens = 0
total_tokens = 0
completion_tokens = 0 # type: Optional[int]
prompt_tokens = 0 # type: Optional[int]
total_tokens = 0 # type: Optional[int]

Check warning on line 83 in sentry_sdk/integrations/openai.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/integrations/openai.py#L81-L83

Added lines #L81 - L83 were not covered by tests
if hasattr(response, "usage"):
if hasattr(response.usage, "completion_tokens") and isinstance(
response.usage.completion_tokens, int
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/langchain/test_langchain.py
Expand Up @@ -149,9 +149,9 @@ def test_langchain_agent(
"You are very powerful"
in chat_spans[0]["data"]["ai.input_messages"][0]["content"]
)
assert "5" in chat_spans[0]["data"]["ai.responses"][0]
assert "5" in chat_spans[0]["data"]["ai.responses"]
assert "word" in tool_exec_span["data"]["ai.input_messages"]
assert "5" in tool_exec_span["data"]["ai.responses"][0]
assert 5 == int(tool_exec_span["data"]["ai.responses"])
assert (
"You are very powerful"
in chat_spans[1]["data"]["ai.input_messages"][0]["content"]
Expand Down

0 comments on commit 7e7b91d

Please sign in to comment.