mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 03:34:10 +00:00
Litellm dev 01 25 2025 p2 (#8003)
* fix(base_utils.py): supported nested json schema passed in for anthropic calls * refactor(base_utils.py): refactor ref parsing to prevent infinite loop * test(test_openai_endpoints.py): refactor anthropic test to use bedrock * fix(langfuse_prompt_management.py): add unit test for sync langfuse calls Resolves https://github.com/BerriAI/litellm/issues/7938#issuecomment-2613293757
This commit is contained in:
parent
a7b3c664d1
commit
08b124aeb6
12 changed files with 214 additions and 5 deletions
|
@ -312,6 +312,56 @@ class BaseLLMChatTest(ABC):
|
|||
except litellm.InternalServerError:
|
||||
pytest.skip("Model is overloaded")
|
||||
|
||||
@pytest.mark.flaky(retries=6, delay=1)
|
||||
def test_json_response_nested_json_schema(self):
|
||||
"""
|
||||
PROD Test: ensure nested json schema sent to proxy works as expected.
|
||||
"""
|
||||
from pydantic import BaseModel
|
||||
from litellm.utils import supports_response_schema
|
||||
from litellm.llms.base_llm.base_utils import type_to_response_format_param
|
||||
|
||||
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
|
||||
litellm.model_cost = litellm.get_model_cost_map(url="")
|
||||
|
||||
class CalendarEvent(BaseModel):
|
||||
name: str
|
||||
date: str
|
||||
participants: list[str]
|
||||
|
||||
class EventsList(BaseModel):
|
||||
events: list[CalendarEvent]
|
||||
|
||||
response_format = type_to_response_format_param(EventsList)
|
||||
|
||||
messages = [
|
||||
{"role": "user", "content": "List 5 important events in the XIX century"}
|
||||
]
|
||||
|
||||
base_completion_call_args = self.get_base_completion_call_args()
|
||||
if not supports_response_schema(base_completion_call_args["model"], None):
|
||||
pytest.skip(
|
||||
f"Model={base_completion_call_args['model']} does not support response schema"
|
||||
)
|
||||
|
||||
try:
|
||||
res = self.completion_function(
|
||||
**base_completion_call_args,
|
||||
messages=messages,
|
||||
response_format=response_format,
|
||||
timeout=60,
|
||||
)
|
||||
assert res is not None
|
||||
|
||||
print(res.choices[0].message)
|
||||
|
||||
assert res.choices[0].message.content is not None
|
||||
assert res.choices[0].message.tool_calls is None
|
||||
except litellm.Timeout:
|
||||
pytest.skip("Model took too long to respond")
|
||||
except litellm.InternalServerError:
|
||||
pytest.skip("Model is overloaded")
|
||||
|
||||
@pytest.mark.flaky(retries=6, delay=1)
|
||||
def test_json_response_format_stream(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue