Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test: mock fireworks ai test - unstable api

Krrish Dholakia049915c14bce
diff --git a/tests/llm_translation/test_fireworks_ai_translation.py b/tests/llm_translation/test_fireworks_ai_translation.py
index 5e1a1c05120..9e78270c922 100644
--- a/tests/llm_translation/test_fireworks_ai_translation.py
+++ b/tests/llm_translation/test_fireworks_ai_translation.py
@@ -93,6 +93,57 @@ class TestFireworksAIChatCompletion(BaseLLMChatTest):
"""
pass
+ @pytest.mark.parametrize(
+ "response_format",
+ [
+ {"type": "json_object"},
+ {"type": "text"},
+ ],
+ )
+ @pytest.mark.flaky(retries=6, delay=1)
+ def test_json_response_format(self, response_format):
+ """
+ Test that the JSON response format is supported by the LLM API
+ """
+ from litellm.utils import supports_response_schema
+ from openai import OpenAI
+ from unittest.mock import patch
+
+ client = OpenAI()
+
+ base_completion_call_args = self.get_base_completion_call_args()
+ litellm.set_verbose = True
+
+ messages = [
+ {
+ "role": "system",
+ "content": "Your output should be a JSON object with no additional properties. ",
+ },
+ {
+ "role": "user",
+ "content": "Respond with this in json. city=San Francisco, state=CA, weather=sunny, temp=60",
+ },
+ ]
+
+ with patch.object(
+ client.chat.completions.with_raw_response, "create"
+ ) as mock_post:
+ response = self.completion_function(
+ **base_completion_call_args,
+ messages=messages,
+ response_format=response_format,
+ client=client,
+ )
+
+ mock_post.assert_called_once()
+ if response_format["type"] == "json_object":
+ assert (
+ mock_post.call_args.kwargs["response_format"]["type"]
+ == "json_object"
+ )
+ else:
+ assert mock_post.call_args.kwargs["response_format"]["type"] == "text"
+
class TestFireworksAIAudioTranscription(BaseLLMAudioTranscriptionTest):
def get_base_audio_transcription_call_args(self) -> dict: