From bde8f7db0bec736849f1228f9d62bd2e0e31ad2b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 03:53:25 +0000 Subject: [PATCH] chore(internal): update client tests --- tests/test_client.py | 110 ++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 48 deletions(-) diff --git a/tests/test_client.py b/tests/test_client.py index 1615f63b..1dc985ab 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -23,10 +23,12 @@ from groq import Groq, AsyncGroq, APIResponseValidationError from groq._types import Omit +from groq._utils import maybe_transform from groq._models import BaseModel, FinalRequestOptions from groq._constants import RAW_RESPONSE_HEADER from groq._exceptions import GroqError, APIStatusError, APITimeoutError, APIResponseValidationError from groq._base_client import DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, make_request_options +from groq.types.chat.completion_create_params import CompletionCreateParams from .utils import update_env @@ -706,18 +708,21 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> No "/openai/v1/chat/completions", body=cast( object, - dict( - messages=[ - { - "role": "system", - "content": "You are a helpful assistant.", - }, - { - "role": "user", - "content": "Explain the importance of low latency LLMs", - }, - ], - model="llama3-8b-8192", + maybe_transform( + dict( + messages=[ + { + "role": "system", + "content": "You are a helpful assistant.", + }, + { + "role": "user", + "content": "Explain the importance of low latency LLMs", + }, + ], + model="llama3-8b-8192", + ), + CompletionCreateParams, ), ), cast_to=httpx.Response, @@ -736,18 +741,21 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) -> Non "/openai/v1/chat/completions", body=cast( object, - dict( - messages=[ - { - "role": "system", - "content": "You are a helpful assistant.", - }, - { - "role": "user", - "content": "Explain the importance of low latency LLMs", - }, - ], - model="llama3-8b-8192", + maybe_transform( + dict( + messages=[ + { + "role": "system", + "content": "You are a helpful assistant.", + }, + { + "role": "user", + "content": "Explain the importance of low latency LLMs", + }, + ], + model="llama3-8b-8192", + ), + CompletionCreateParams, ), ), cast_to=httpx.Response, @@ -1526,18 +1534,21 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) "/openai/v1/chat/completions", body=cast( object, - dict( - messages=[ - { - "role": "system", - "content": "You are a helpful assistant.", - }, - { - "role": "user", - "content": "Explain the importance of low latency LLMs", - }, - ], - model="llama3-8b-8192", + maybe_transform( + dict( + messages=[ + { + "role": "system", + "content": "You are a helpful assistant.", + }, + { + "role": "user", + "content": "Explain the importance of low latency LLMs", + }, + ], + model="llama3-8b-8192", + ), + CompletionCreateParams, ), ), cast_to=httpx.Response, @@ -1556,18 +1567,21 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter) "/openai/v1/chat/completions", body=cast( object, - dict( - messages=[ - { - "role": "system", - "content": "You are a helpful assistant.", - }, - { - "role": "user", - "content": "Explain the importance of low latency LLMs", - }, - ], - model="llama3-8b-8192", + maybe_transform( + dict( + messages=[ + { + "role": "system", + "content": "You are a helpful assistant.", + }, + { + "role": "user", + "content": "Explain the importance of low latency LLMs", + }, + ], + model="llama3-8b-8192", + ), + CompletionCreateParams, ), ), cast_to=httpx.Response,