TogetherAIConfig.get_supported_openai_params called get_model_info(), whose first line calls litellm.get_supported_openai_params() — which for together_ai routes straight back into this method. The recursion only terminated when Python's recursion limit was hit or when _get_model_info_helper raised "not mapped" at the deepest level. Either way the try/except caught it, so the bug stayed silent — but the cycle ran ~332 deep every time, emitting hundreds of DEBUG log lines per call. Surfaced as "infinite loop" in CI when the success_handler thread emitted that log spam against an already-closed stderr during test teardown. Replace the get_model_info() call with supports_function_calling(), which uses _get_model_info_helper directly and does not call get_supported_openai_params. Measured drop from 332 to 2 _get_model_info_helper calls per first uncached lookup. Also swap the test model from Qwen/Qwen3.5-9B (not in model_cost map) back to a mapped serverless model, Qwen/Qwen2.5-7B-Instruct-Turbo. The mapping gap is what made the recursion's tail end raise up into the success handler during teardown in the first place.
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
"""
|
|
Test TogetherAI LLM
|
|
"""
|
|
|
|
from base_llm_unit_tests import BaseLLMChatTest
|
|
import json
|
|
import os
|
|
import sys
|
|
from datetime import datetime
|
|
from unittest.mock import AsyncMock
|
|
|
|
sys.path.insert(
|
|
0, os.path.abspath("../..")
|
|
) # Adds the parent directory to the system path
|
|
|
|
import litellm
|
|
import pytest
|
|
|
|
|
|
class TestTogetherAI(BaseLLMChatTest):
|
|
def get_base_completion_call_args(self) -> dict:
|
|
litellm.set_verbose = True
|
|
return {"model": "together_ai/Qwen/Qwen2.5-7B-Instruct-Turbo"}
|
|
|
|
def test_tool_call_no_arguments(self, tool_call_no_arguments):
|
|
"""Test that tool calls with no arguments is translated correctly. Relevant issue: https://github.com/BerriAI/litellm/issues/6833"""
|
|
pass
|
|
|
|
@pytest.mark.parametrize(
|
|
"model, expected_bool",
|
|
[
|
|
("meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo", True),
|
|
("nvidia/Llama-3.1-Nemotron-70B-Instruct-HF", False),
|
|
],
|
|
)
|
|
def test_get_supported_response_format_together_ai(
|
|
self, model: str, expected_bool: bool
|
|
) -> None:
|
|
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
|
|
litellm.model_cost = litellm.get_model_cost_map(url="")
|
|
optional_params = litellm.get_supported_openai_params(
|
|
model, custom_llm_provider="together_ai"
|
|
)
|
|
# Mapped provider
|
|
assert isinstance(optional_params, list)
|
|
|
|
if expected_bool:
|
|
assert "response_format" in optional_params
|
|
assert "tools" in optional_params
|
|
else:
|
|
assert "response_format" not in optional_params
|
|
assert "tools" not in optional_params
|