forked from phoenix/litellm-mirror
LiteLLM Minor Fixes & Improvements (10/08/2024) (#6119)
* refactor(cost_calculator.py): move error line to debug - https://github.com/BerriAI/litellm/issues/5683#issuecomment-2398599498 * fix(migrate-hidden-params-to-read-from-standard-logging-payload): Fixes https://github.com/BerriAI/litellm/issues/5546#issuecomment-2399994026 * fix(types/utils.py): mark weight as a litellm param Fixes https://github.com/BerriAI/litellm/issues/5781 * feat(internal_user_endpoints.py): fix /user/info + show user max budget as default max budget Fixes https://github.com/BerriAI/litellm/issues/6117 * feat: support returning team member budget in `/user/info` Sets user max budget in team as max budget on ui Closes https://github.com/BerriAI/litellm/issues/6117 * bug fix for optional parameter passing to replicate (#6067) Signed-off-by: Mandana Vaziri <mvaziri@us.ibm.com> * fix(o1_transformation.py): handle o1 temperature=0 o1 doesn't support temp=0, allow admin to drop this param * test: fix test --------- Signed-off-by: Mandana Vaziri <mvaziri@us.ibm.com> Co-authored-by: Mandana Vaziri <mvaziri@us.ibm.com>
This commit is contained in:
parent
ac6fb0cbef
commit
9695c1af10
21 changed files with 260 additions and 86 deletions
|
@ -5,6 +5,35 @@ import asyncio
|
|||
import aiohttp
|
||||
import time, uuid
|
||||
from openai import AsyncOpenAI
|
||||
from typing import Optional
|
||||
|
||||
|
||||
async def get_user_info(session, get_user, call_user, view_all: Optional[bool] = None):
|
||||
"""
|
||||
Make sure only models user has access to are returned
|
||||
"""
|
||||
if view_all is True:
|
||||
url = "http://0.0.0.0:4000/user/info"
|
||||
else:
|
||||
url = f"http://0.0.0.0:4000/user/info?user_id={get_user}"
|
||||
headers = {
|
||||
"Authorization": f"Bearer {call_user}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
async with session.get(url, headers=headers) as response:
|
||||
status = response.status
|
||||
response_text = await response.text()
|
||||
print(response_text)
|
||||
print()
|
||||
|
||||
if status != 200:
|
||||
if call_user != get_user:
|
||||
return status
|
||||
else:
|
||||
print(f"call_user: {call_user}; get_user: {get_user}")
|
||||
raise Exception(f"Request did not return a 200 status code: {status}")
|
||||
return await response.json()
|
||||
|
||||
|
||||
async def new_user(
|
||||
|
@ -630,3 +659,13 @@ async def test_users_in_team_budget():
|
|||
print("got exception, this is expected")
|
||||
print(e)
|
||||
assert "Budget has been exceeded" in str(e)
|
||||
|
||||
## Check user info
|
||||
user_info = await get_user_info(session, get_user, call_user="sk-1234")
|
||||
|
||||
assert (
|
||||
user_info["teams"][0]["team_memberships"][0]["litellm_budget_table"][
|
||||
"max_budget"
|
||||
]
|
||||
== 0.0000001
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue