mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
* fix(ui_sso.py): use common `get_user_object` logic across jwt + ui sso auth Allows finding users by their email, and attaching the sso user id to the user if found * Improve Team Management flow on UI (#8204) * build(teams.tsx): refactor teams page to make it easier to add members to a team make a row in table clickable -> allows user to add users to team they intended * build(teams.tsx): make it clear user should click on team id to view team details simplifies team management by putting team details on separate page * build(team_info.tsx): separately show user id and user email make it easy for user to understand the information they're seeing * build(team_info.tsx): add back in 'add member' button * build(team_info.tsx): working team member update on team_info.tsx * build(team_info.tsx): enable team member delete on ui allow user to delete accidental adds * build(internal_user_endpoints.py): expose new endpoint for ui to allow filtering on user table allows proxy admin to quickly find user they're looking for * feat(team_endpoints.py): expose new team filter endpoint for ui allows proxy admin to easily find team they're looking for * feat(user_search_modal.tsx): allow admin to filter on users when adding new user to teams * test: mark flaky test * test: mark flaky test * fix(exception_mapping_utils.py): fix anthropic text route error * fix(ui_sso.py): handle situation when user not in db
73 lines
2.1 KiB
Python
73 lines
2.1 KiB
Python
import asyncio
|
|
import os
|
|
import sys
|
|
import traceback
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
import litellm.types
|
|
import litellm.types.utils
|
|
from litellm.llms.anthropic.chat import ModelResponseIterator
|
|
|
|
load_dotenv()
|
|
import io
|
|
import os
|
|
|
|
sys.path.insert(
|
|
0, os.path.abspath("../..")
|
|
) # Adds the parent directory to the system path
|
|
from typing import Optional
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.parametrize("model", ["claude-2", "anthropic/claude-2"])
|
|
@pytest.mark.flaky(retries=6, delay=1)
|
|
async def test_acompletion_claude2(model):
|
|
try:
|
|
litellm.set_verbose = True
|
|
messages = [
|
|
{
|
|
"role": "system",
|
|
"content": "Your goal is generate a joke on the topic user gives.",
|
|
},
|
|
{"role": "user", "content": "Generate a 3 liner joke for me"},
|
|
]
|
|
# test without max-tokens
|
|
response = await litellm.acompletion(model=model, messages=messages)
|
|
# Add any assertions here to check the response
|
|
print(response)
|
|
print(response.usage)
|
|
print(response.usage.completion_tokens)
|
|
print(response["usage"]["completion_tokens"])
|
|
# print("new cost tracking")
|
|
except litellm.InternalServerError:
|
|
pytest.skip("model is overloaded.")
|
|
except Exception as e:
|
|
pytest.fail(f"Error occurred: {e}")
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_acompletion_claude2_stream():
|
|
try:
|
|
litellm.set_verbose = False
|
|
messages = [
|
|
{
|
|
"role": "system",
|
|
"content": "Your goal is generate a joke on the topic user gives.",
|
|
},
|
|
{"role": "user", "content": "Generate a 3 liner joke for me"},
|
|
]
|
|
# test without max-tokens
|
|
response = await litellm.acompletion(
|
|
model="anthropic_text/claude-2",
|
|
messages=messages,
|
|
stream=True,
|
|
max_tokens=10,
|
|
)
|
|
async for chunk in response:
|
|
print(chunk)
|
|
except Exception as e:
|
|
pytest.fail(f"Error occurred: {e}")
|