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

Update test_completion.py #2193

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -528,6 +528,39 @@ async def test_async_anthropic_message_create(exporter, reader):
assert found_choice_metric is True
assert found_duration_metric is True
assert found_exception_metric is True

# Place the new tests here
@pytest.mark.vcr
def test_capture_system_message(exporter):
client = Anthropic()
system_message = "This is a test system message."

# Simulate capturing a system message
client.capture_system_message(system_message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you ran this? there's no method like this on Anthropic


spans = exporter.get_finished_spans()
assert len(spans) > 0
anthropic_span = spans[0]

# Check if the system message is recorded in span attributes
assert "system_message" in anthropic_span.attributes
assert anthropic_span.attributes["system_message"] == system_message

@pytest.mark.vcr
def test_edge_case_empty_message(exporter):
client = Anthropic()
system_message = ""

# Simulate capturing an empty system message
client.capture_system_message(system_message)

spans = exporter.get_finished_spans()
assert len(spans) > 0
anthropic_span = spans[0]

# Check if the empty message is handled correctly
assert "system_message" in anthropic_span.attributes
assert anthropic_span.attributes["system_message"] == system_message


@pytest.mark.vcr
Expand Down
Loading