Skip to content

Commit eda7fd5

Browse files
merge
2 parents 962fd65 + 425ae27 commit eda7fd5

1 file changed

Lines changed: 18 additions & 40 deletions

File tree

tests/integrations/openai/test_openai.py

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,28 +2035,6 @@ async def test_streaming_chat_completion_async(
20352035
"content": "You are a helpful assistant.",
20362036
}
20372037
]
2038-
2039-
assert (
2040-
"Message demonstrating the absence of truncation."
2041-
in span["attributes"][SPANDATA.GEN_AI_REQUEST_MESSAGES]
2042-
)
2043-
assert "hello" in span["attributes"][SPANDATA.GEN_AI_REQUEST_MESSAGES]
2044-
assert "hello world" in span["attributes"][SPANDATA.GEN_AI_RESPONSE_TEXT]
2045-
2046-
try:
2047-
import tiktoken # type: ignore # noqa # pylint: disable=unused-import
2048-
2049-
if "blocks" in param_id:
2050-
assert span["attributes"]["gen_ai.usage.output_tokens"] == 2
2051-
assert span["attributes"]["gen_ai.usage.input_tokens"] == 15
2052-
assert span["attributes"]["gen_ai.usage.total_tokens"] == 17
2053-
else:
2054-
assert span["attributes"]["gen_ai.usage.output_tokens"] == 2
2055-
assert span["attributes"]["gen_ai.usage.input_tokens"] == 20
2056-
assert span["attributes"]["gen_ai.usage.total_tokens"] == 22
2057-
2058-
except ImportError:
2059-
pass # if tiktoken is not installed, we can't guarantee token usage will be calculated properly
20602038
else:
20612039
assert json.loads(
20622040
span["attributes"][SPANDATA.GEN_AI_SYSTEM_INSTRUCTIONS]
@@ -2071,27 +2049,27 @@ async def test_streaming_chat_completion_async(
20712049
},
20722050
]
20732051

2074-
assert (
2075-
"Message demonstrating the absence of truncation."
2076-
in span["attributes"][SPANDATA.GEN_AI_REQUEST_MESSAGES]
2077-
)
2078-
assert "hello" in span["attributes"][SPANDATA.GEN_AI_REQUEST_MESSAGES]
2079-
assert "hello world" in span["attributes"][SPANDATA.GEN_AI_RESPONSE_TEXT]
2052+
assert (
2053+
"Message demonstrating the absence of truncation."
2054+
in span["attributes"][SPANDATA.GEN_AI_REQUEST_MESSAGES]
2055+
)
2056+
assert "hello" in span["attributes"][SPANDATA.GEN_AI_REQUEST_MESSAGES]
2057+
assert "hello world" in span["attributes"][SPANDATA.GEN_AI_RESPONSE_TEXT]
20802058

2081-
try:
2082-
import tiktoken # type: ignore # noqa # pylint: disable=unused-import
2059+
try:
2060+
import tiktoken # type: ignore # noqa # pylint: disable=unused-import
20832061

2084-
if "blocks" in param_id:
2085-
assert span["attributes"]["gen_ai.usage.output_tokens"] == 2
2086-
assert span["attributes"]["gen_ai.usage.input_tokens"] == 15
2087-
assert span["attributes"]["gen_ai.usage.total_tokens"] == 17
2088-
else:
2089-
assert span["attributes"]["gen_ai.usage.output_tokens"] == 2
2090-
assert span["attributes"]["gen_ai.usage.input_tokens"] == 20
2091-
assert span["attributes"]["gen_ai.usage.total_tokens"] == 22
2062+
if "blocks" in param_id:
2063+
assert span["attributes"]["gen_ai.usage.output_tokens"] == 2
2064+
assert span["attributes"]["gen_ai.usage.input_tokens"] == 15
2065+
assert span["attributes"]["gen_ai.usage.total_tokens"] == 17
2066+
else:
2067+
assert span["attributes"]["gen_ai.usage.output_tokens"] == 2
2068+
assert span["attributes"]["gen_ai.usage.input_tokens"] == 20
2069+
assert span["attributes"]["gen_ai.usage.total_tokens"] == 22
20922070

2093-
except ImportError:
2094-
pass # if tiktoken is not installed, we can't guarantee token usage will be calculated properly
2071+
except ImportError:
2072+
pass # if tiktoken is not installed, we can't guarantee token usage will be calculated properly
20952073
else:
20962074
events = capture_events()
20972075

0 commit comments

Comments
 (0)