@@ -1631,7 +1631,73 @@ def test_multiple_providers(
16311631 request_headers = {"X-Stainless-Raw-Response" : "true" },
16321632 )
16331633
1634- if span_streaming or stream_gen_ai_spans :
1634+ if span_streaming :
1635+ items = capture_items ("span" )
1636+
1637+ with mock .patch .object (
1638+ openai_client .completions ._client ._client ,
1639+ "send" ,
1640+ return_value = openai_model_response ,
1641+ ), start_transaction (name = "test gpt-3.5-turbo" ):
1642+ litellm .completion (
1643+ model = "gpt-3.5-turbo" ,
1644+ messages = messages ,
1645+ client = openai_client ,
1646+ )
1647+
1648+ litellm_utils .executor .shutdown (wait = True )
1649+
1650+ _reset_litellm_executor ()
1651+
1652+ anthropic_client = HTTPHandler ()
1653+ anthropic_model_response = get_model_response (
1654+ nonstreaming_anthropic_model_response ,
1655+ serialize_pydantic = True ,
1656+ request_headers = {"X-Stainless-Raw-Response" : "true" },
1657+ )
1658+
1659+ with mock .patch .object (
1660+ anthropic_client ,
1661+ "post" ,
1662+ return_value = anthropic_model_response ,
1663+ ), start_transaction (name = "test claude-3-opus-20240229" ):
1664+ litellm .completion (
1665+ model = "claude-3-opus-20240229" ,
1666+ messages = messages ,
1667+ client = anthropic_client ,
1668+ api_key = "test-key" ,
1669+ )
1670+
1671+ litellm_utils .executor .shutdown (wait = True )
1672+
1673+ _reset_litellm_executor ()
1674+
1675+ gemini_client = HTTPHandler ()
1676+ gemini_model_response = get_model_response (
1677+ nonstreaming_google_genai_model_response ,
1678+ serialize_pydantic = True ,
1679+ )
1680+
1681+ with mock .patch .object (
1682+ gemini_client ,
1683+ "post" ,
1684+ return_value = gemini_model_response ,
1685+ ), start_transaction (name = "test gemini/gemini-pro" ):
1686+ litellm .completion (
1687+ model = "gemini/gemini-pro" ,
1688+ messages = messages ,
1689+ client = gemini_client ,
1690+ api_key = "test-key" ,
1691+ )
1692+
1693+ litellm_utils .executor .shutdown (wait = True )
1694+
1695+ sentry_sdk .flush ()
1696+ spans = [item .payload for item in items ]
1697+ for span in spans :
1698+ # The provider should be detected by litellm.get_llm_provider
1699+ assert SPANDATA .GEN_AI_SYSTEM in span ["attributes" ]
1700+ elif stream_gen_ai_spans :
16351701 items = capture_items ("transaction" )
16361702
16371703 with mock .patch .object (
0 commit comments