forked from phoenix/litellm-mirror
Litellm stable pr 10 30 2024 (#6821)
* Update organization_endpoints.py to be able to list organizations (#6473) * Update organization_endpoints.py to be able to list organizations * Update test_organizations.py * Update test_organizations.py add test for list * Update test_organizations.py correct indentation * Add unreleased Claude 3.5 Haiku models. (#6476) --------- Co-authored-by: superpoussin22 <vincent.nadal@orange.fr> Co-authored-by: David Manouchehri <david.manouchehri@ai.moda>
This commit is contained in:
parent
98c7889013
commit
cf579fe644
4 changed files with 105 additions and 2 deletions
|
@ -2803,6 +2803,18 @@
|
||||||
"supports_vision": true,
|
"supports_vision": true,
|
||||||
"supports_assistant_prefill": true
|
"supports_assistant_prefill": true
|
||||||
},
|
},
|
||||||
|
"vertex_ai/claude-3-5-haiku@20241022": {
|
||||||
|
"max_tokens": 8192,
|
||||||
|
"max_input_tokens": 200000,
|
||||||
|
"max_output_tokens": 8192,
|
||||||
|
"input_cost_per_token": 0.00000025,
|
||||||
|
"output_cost_per_token": 0.00000125,
|
||||||
|
"litellm_provider": "vertex_ai-anthropic_models",
|
||||||
|
"mode": "chat",
|
||||||
|
"supports_function_calling": true,
|
||||||
|
"supports_vision": true,
|
||||||
|
"supports_assistant_prefill": true
|
||||||
|
},
|
||||||
"vertex_ai/claude-3-haiku@20240307": {
|
"vertex_ai/claude-3-haiku@20240307": {
|
||||||
"max_tokens": 4096,
|
"max_tokens": 4096,
|
||||||
"max_input_tokens": 200000,
|
"max_input_tokens": 200000,
|
||||||
|
@ -4662,7 +4674,8 @@
|
||||||
"litellm_provider": "bedrock",
|
"litellm_provider": "bedrock",
|
||||||
"mode": "chat",
|
"mode": "chat",
|
||||||
"supports_assistant_prefill": true,
|
"supports_assistant_prefill": true,
|
||||||
"supports_function_calling": true
|
"supports_function_calling": true,
|
||||||
|
"supports_vision": true
|
||||||
},
|
},
|
||||||
"us.anthropic.claude-3-opus-20240229-v1:0": {
|
"us.anthropic.claude-3-opus-20240229-v1:0": {
|
||||||
"max_tokens": 4096,
|
"max_tokens": 4096,
|
||||||
|
@ -4728,7 +4741,8 @@
|
||||||
"output_cost_per_token": 0.000005,
|
"output_cost_per_token": 0.000005,
|
||||||
"litellm_provider": "bedrock",
|
"litellm_provider": "bedrock",
|
||||||
"mode": "chat",
|
"mode": "chat",
|
||||||
"supports_function_calling": true
|
"supports_function_calling": true,
|
||||||
|
"supports_vision": true
|
||||||
},
|
},
|
||||||
"eu.anthropic.claude-3-opus-20240229-v1:0": {
|
"eu.anthropic.claude-3-opus-20240229-v1:0": {
|
||||||
"max_tokens": 4096,
|
"max_tokens": 4096,
|
||||||
|
|
|
@ -198,6 +198,45 @@ async def delete_organization():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@router.get(
|
||||||
|
"/organization/list",
|
||||||
|
tags=["organization management"],
|
||||||
|
dependencies=[Depends(user_api_key_auth)],
|
||||||
|
)
|
||||||
|
async def list_organization(
|
||||||
|
user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
```
|
||||||
|
curl --location --request GET 'http://0.0.0.0:4000/organization/list' \
|
||||||
|
--header 'Authorization: Bearer sk-1234'
|
||||||
|
```
|
||||||
|
"""
|
||||||
|
from litellm.proxy.proxy_server import prisma_client
|
||||||
|
|
||||||
|
if prisma_client is None:
|
||||||
|
raise HTTPException(status_code=500, detail={"error": "No db connected"})
|
||||||
|
|
||||||
|
if (
|
||||||
|
user_api_key_dict.user_role is None
|
||||||
|
or user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN
|
||||||
|
):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=401,
|
||||||
|
detail={
|
||||||
|
"error": f"Only admins can list orgs. Your role is = {user_api_key_dict.user_role}"
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if prisma_client is None:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=400,
|
||||||
|
detail={"error": CommonProxyErrors.db_not_connected_error.value},
|
||||||
|
)
|
||||||
|
response= await prisma_client.db.litellm_organizationtable.find_many()
|
||||||
|
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
@router.post(
|
@router.post(
|
||||||
"/organization/info",
|
"/organization/info",
|
||||||
tags=["organization management"],
|
tags=["organization management"],
|
||||||
|
|
|
@ -2803,6 +2803,18 @@
|
||||||
"supports_vision": true,
|
"supports_vision": true,
|
||||||
"supports_assistant_prefill": true
|
"supports_assistant_prefill": true
|
||||||
},
|
},
|
||||||
|
"vertex_ai/claude-3-5-haiku@20241022": {
|
||||||
|
"max_tokens": 8192,
|
||||||
|
"max_input_tokens": 200000,
|
||||||
|
"max_output_tokens": 8192,
|
||||||
|
"input_cost_per_token": 0.00000025,
|
||||||
|
"output_cost_per_token": 0.00000125,
|
||||||
|
"litellm_provider": "vertex_ai-anthropic_models",
|
||||||
|
"mode": "chat",
|
||||||
|
"supports_function_calling": true,
|
||||||
|
"supports_vision": true,
|
||||||
|
"supports_assistant_prefill": true
|
||||||
|
},
|
||||||
"vertex_ai/claude-3-haiku@20240307": {
|
"vertex_ai/claude-3-haiku@20240307": {
|
||||||
"max_tokens": 4096,
|
"max_tokens": 4096,
|
||||||
"max_input_tokens": 200000,
|
"max_input_tokens": 200000,
|
||||||
|
|
|
@ -29,6 +29,22 @@ async def new_organization(session, i, organization_alias, max_budget=None):
|
||||||
|
|
||||||
return await response.json()
|
return await response.json()
|
||||||
|
|
||||||
|
async def list_organization(session, i):
|
||||||
|
url = "http://0.0.0.0:4000/organization/list"
|
||||||
|
headers = {"Authorization": "Bearer sk-1234", "Content-Type": "application/json"}
|
||||||
|
|
||||||
|
async with session.post(url, headers=headers) as response:
|
||||||
|
status = response.status
|
||||||
|
response_json = await response.json()
|
||||||
|
|
||||||
|
print(f"Response {i} (Status code: {status}):")
|
||||||
|
print(response_json)
|
||||||
|
print()
|
||||||
|
|
||||||
|
if status != 200:
|
||||||
|
raise Exception(f"Request {i} did not return a 200 status code: {status}")
|
||||||
|
|
||||||
|
return await response.json()
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_organization_new():
|
async def test_organization_new():
|
||||||
|
@ -44,3 +60,25 @@ async def test_organization_new():
|
||||||
for i in range(1, 20)
|
for i in range(1, 20)
|
||||||
]
|
]
|
||||||
await asyncio.gather(*tasks)
|
await asyncio.gather(*tasks)
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_organization_list():
|
||||||
|
"""
|
||||||
|
create 2 new Organizations
|
||||||
|
check if the Organization list is not empty
|
||||||
|
"""
|
||||||
|
organization_alias = f"Organization: {uuid.uuid4()}"
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
tasks = [
|
||||||
|
new_organization(
|
||||||
|
session=session, i=0, organization_alias=organization_alias
|
||||||
|
)
|
||||||
|
for i in range(1, 2)
|
||||||
|
]
|
||||||
|
await asyncio.gather(*tasks)
|
||||||
|
|
||||||
|
response_json = await list_organization(session)
|
||||||
|
print(len(response_json))
|
||||||
|
|
||||||
|
if len(response_json)==0:
|
||||||
|
raise Exception(f"Return empty list of organization")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue