Commit graph

2254 commits

Author SHA1 Message Date
Krrish Dholakia
b4a8665d11 fix(utils.py): fix custom pricing when litellm model != response obj model name 2024-05-13 15:25:35 -07:00
Ishaan Jaff
12cf9d71c7 feat - /spend/report endpoint 2024-05-13 15:01:02 -07:00
Ishaan Jaff
9d4b727913 fix - show team based spend reports 2024-05-13 13:56:48 -07:00
Ishaan Jaff
21845bc061
Merge pull request #3609 from BerriAI/litellm_send_daily_spend_report
[Feat] send weekly spend reports by Team/Tag
2024-05-13 12:45:37 -07:00
Ishaan Jaff
40b2f33a80 fix - only schedule spend alerting when db is not none 2024-05-13 12:30:54 -07:00
Marc Abramowitz
1efa2e65ac Merge branch 'main' into msabramo/fix-pydantic-warnings 2024-05-13 11:34:06 -07:00
Marc Abramowitz
73541b1f17 Merge branch 'msabramo/pydantic_replace_root_validator_with_model_validator' into msabramo/fix-pydantic-warnings 2024-05-13 11:25:55 -07:00
Ishaan Jaff
aac81c59b5 test - weekly / monthly spend report alerts on /health/services 2024-05-13 10:50:26 -07:00
Ishaan Jaff
197eb44832 fix scheduling spend reports 2024-05-13 10:45:22 -07:00
Ishaan Jaff
4a679bb640 schedule weekly/monthly spend reports 2024-05-13 10:44:19 -07:00
Marc Abramowitz
4ccdbfd67d model_config = ConfigDict instead of model_config = dict 2024-05-13 10:38:01 -07:00
Marc Abramowitz
abd90e6296 Revert root_validator => model_validator change
I have it in a separate PR:

https://github.com/BerriAI/litellm/pull/3611
2024-05-13 10:33:04 -07:00
Marc Abramowitz
ad8c3ac2c3 Change pydantic root_validator to model_validator
pydantic v1 uses `root_validator` and pydantic v2 uses `model_validator`.

pydantic v2 emits a warning when `root_validator` is used. E.g.:

```
litellm/proxy/_types.py:225
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:225:
  PydanticDeprecatedSince20: Pydantic V1 style `@root_validator`
  validators are deprecated.
  You should migrate to Pydantic V2 style `@model_validator` validators,
  see the migration guide for more details.
  Deprecated in Pydantic V2.0 to be removed in V3.0.
  See Pydantic V2 Migration Guide at
  https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)
```

This change eliminates those warnings with pydantic v2, while retaining
compatibility with pydantic v1.

pydantic 2.7.1 before

```
$ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py
...
litellm/proxy/_types.py:225
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:225: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)
...
========================== 10 passed, 2 skipped, 39 warnings in 8.67s ===========================
```

pydantic 2.7.1 after

```
$ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py
...
========================== 10 passed, 2 skipped, 27 warnings in 9.85s ===========================
```

pydantic 1.10.5 after

```
$ poetry run pip install 'pydantic<2'
...
Successfully installed pydantic-1.10.15
$ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py
...
=========================== 10 passed, 2 skipped, 1 warning in 8.13s ============================
```
2024-05-13 10:23:44 -07:00
Ishaan Jaff
2cd584a3ad feat - send_monthly_spend_report 2024-05-13 10:17:40 -07:00
Ishaan Jaff
07247452c5 feat - show monthly spend reports 2024-05-13 10:10:44 -07:00
Krrish Dholakia
13e1577753 fix(slack_alerting.py): don't fire spam alerts when backend api call fails 2024-05-13 10:04:43 -07:00
Ishaan Jaff
50f3677989 feat - _get_weekly_spend_reports 2024-05-13 09:26:51 -07:00
Ishaan Jaff
b7bbaf1a68 feat - send daily spend reports 2024-05-13 09:25:31 -07:00
Krrish Dholakia
c3293474dd fix(proxy_server.py): return 'allowed-model-region' in headers 2024-05-13 08:48:16 -07:00
Ishaan Jaff
514c5737f8
Merge pull request #3587 from BerriAI/litellm_proxy_use_batch_completions_model_csv
[Feat] Use csv values for proxy batch completions (OpenAI Python compatible)
2024-05-13 07:55:12 -07:00
Marc Abramowitz
876840e995 Update pydantic code to fix warnings
Before:

```shell
$ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py
====================================== test session starts ======================================
platform darwin -- Python 3.12.3, pytest-7.4.4, pluggy-1.5.0
rootdir: /Users/abramowi/Code/OpenSource/litellm
plugins: anyio-4.3.0, asyncio-0.23.6, mock-3.14.0
asyncio: mode=Mode.STRICT
collected 12 items

litellm/tests/test_proxy_server.py s..........s                                           [100%]

======================================= warnings summary ========================================
../../../Library/Caches/pypoetry/virtualenvs/litellm-Fe7WjZrx-py3.12/lib/python3.12/site-packages/pydantic/_internal/_config.py:284: 25 warnings
  /Users/abramowi/Library/Caches/pypoetry/virtualenvs/litellm-Fe7WjZrx-py3.12/lib/python3.12/site-packages/pydantic/_internal/_config.py:284: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

litellm/proxy/_types.py:225
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:225: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:312
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:312: PydanticDeprecatedSince20: `pydantic.config.Extra` is deprecated, use literal values instead (e.g. `extra='allow'`). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    extra = Extra.allow  # Allow extra fields

litellm/proxy/_types.py:315
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:315: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:344
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:344: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:391
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:391: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:460
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:460: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:480
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:480: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:493
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:493: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:538
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:538: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:575
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:575: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:870
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:870: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:897
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:897: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/proxy/_types.py:918
  /Users/abramowi/Code/OpenSource/litellm/litellm/proxy/_types.py:918: PydanticDeprecatedSince20: Pydantic V1 style `@root_validator` validators are deprecated. You should migrate to Pydantic V2 style `@model_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/
    @root_validator(pre=True)

litellm/utils.py:43
  /Users/abramowi/Code/OpenSource/litellm/litellm/utils.py:43: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources  # type: ignore

litellm/tests/test_proxy_server.py::test_bedrock_embedding
litellm/tests/test_proxy_server.py::test_chat_completion
litellm/tests/test_proxy_server.py::test_chat_completion_azure
litellm/tests/test_proxy_server.py::test_chat_completion_optional_params
litellm/tests/test_proxy_server.py::test_embedding
litellm/tests/test_proxy_server.py::test_engines_model_chat_completions
litellm/tests/test_proxy_server.py::test_health
litellm/tests/test_proxy_server.py::test_img_gen
litellm/tests/test_proxy_server.py::test_openai_deployments_model_chat_completions_azure
  /Users/abramowi/Library/Caches/pypoetry/virtualenvs/litellm-Fe7WjZrx-py3.12/lib/python3.12/site-packages/httpx/_client.py:680: DeprecationWarning: The 'app' shortcut is now deprecated. Use the explicit style 'transport=WSGITransport(app=...)' instead.
    warnings.warn(message, DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================== 10 passed, 2 skipped, 48 warnings in 9.83s ===========================
```

After:

```shell
$ env -i PATH=$PATH poetry run pytest litellm/tests/test_proxy_server.py
====================================== test session starts ======================================
platform darwin -- Python 3.12.3, pytest-7.4.4, pluggy-1.5.0
rootdir: /Users/abramowi/Code/OpenSource/litellm
plugins: anyio-4.3.0, asyncio-0.23.6, mock-3.14.0
asyncio: mode=Mode.STRICT
collected 12 items

litellm/tests/test_proxy_server.py s..........s                                           [100%]

======================================= warnings summary ========================================
litellm/utils.py:43
  /Users/abramowi/Code/OpenSource/litellm/litellm/utils.py:43: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources  # type: ignore

litellm/tests/test_proxy_server.py::test_bedrock_embedding
litellm/tests/test_proxy_server.py::test_chat_completion
litellm/tests/test_proxy_server.py::test_chat_completion_azure
litellm/tests/test_proxy_server.py::test_chat_completion_optional_params
litellm/tests/test_proxy_server.py::test_embedding
litellm/tests/test_proxy_server.py::test_engines_model_chat_completions
litellm/tests/test_proxy_server.py::test_health
litellm/tests/test_proxy_server.py::test_img_gen
litellm/tests/test_proxy_server.py::test_openai_deployments_model_chat_completions_azure
  /Users/abramowi/Library/Caches/pypoetry/virtualenvs/litellm-Fe7WjZrx-py3.12/lib/python3.12/site-packages/httpx/_client.py:680: DeprecationWarning: The 'app' shortcut is now deprecated. Use the explicit style 'transport=WSGITransport(app=...)' instead.
    warnings.warn(message, DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================== 10 passed, 2 skipped, 10 warnings in 9.62s ===========================
```
2024-05-12 10:11:48 -07:00
Krrish Dholakia
b4684d5132 fix(proxy_server.py): linting fix 2024-05-11 22:05:01 -07:00
Krrish Dholakia
15a6e59431 fix(proxy/_types.py): allow jwt admin to access spend routes 2024-05-11 21:31:34 -07:00
Krish Dholakia
1d651c6049
Merge branch 'main' into litellm_bedrock_command_r_support 2024-05-11 21:24:42 -07:00
Ishaan Jaff
d7f7120880 ui - new build 2024-05-11 15:58:55 -07:00
Ishaan Jaff
91a6a0eef4 (Fix) - linting errors 2024-05-11 15:57:06 -07:00
Ishaan Jaff
d4288b134b fix - use csv list for batch completions 2024-05-11 14:24:48 -07:00
Ishaan Jaff
bf909a89f8
Merge pull request #3585 from BerriAI/litellm_router_batch_comp
[Litellm Proxy + litellm.Router] - Pass the same message/prompt to N models
2024-05-11 13:51:45 -07:00
Krrish Dholakia
4a3b084961 feat(bedrock_httpx.py): moves to using httpx client for bedrock cohere calls 2024-05-11 13:43:08 -07:00
Ishaan Jaff
31cb1be279 edit dev config.yaml 2024-05-11 13:24:59 -07:00
Ishaan Jaff
b8c7bbcb9f support batch /chat/completions on proxy 2024-05-11 13:24:25 -07:00
Krish Dholakia
86d0c0ae4e
Merge pull request #3582 from BerriAI/litellm_explicit_region_name_setting
feat(router.py): allow setting model_region in litellm_params
2024-05-11 11:36:22 -07:00
Krrish Dholakia
ebc927f1c8 feat(router.py): allow setting model_region in litellm_params
Closes https://github.com/BerriAI/litellm/issues/3580
2024-05-11 10:18:08 -07:00
Krish Dholakia
bbe1300c5b
Merge branch 'main' into feat/add-azure-content-filter 2024-05-11 09:30:38 -07:00
Krrish Dholakia
94f3d361b0 fix(vertex_ai.py): fix list tool call responses
Closes https://github.com/BerriAI/litellm/issues/3147
2024-05-10 20:05:58 -07:00
Ishaan Jaff
ed2c05d10d fix triton params 2024-05-10 19:14:48 -07:00
Ishaan Jaff
2c0c9e1fa4
Merge pull request #3573 from BerriAI/litellm_team_based_failure_callback
[Feat] Use Team based callbacks with litellm.failure_callbacks
2024-05-10 17:53:15 -07:00
Krrish Dholakia
9e9f5d41d9 fix(proxy_server.py): check + get end-user obj even for master key calls
fixes issue where region-based routing wasn't working for end-users if master key was given
2024-05-10 16:54:51 -07:00
Ishaan Jaff
92b86056cf fix langfuse team based logging tests 2024-05-10 16:39:49 -07:00
Ishaan Jaff
b6e0f00ed8 fix - using failure callbacks with team based logging 2024-05-10 16:18:13 -07:00
Ishaan Jaff
933f8ed16b fix - proxy_server.py 2024-05-10 13:47:35 -07:00
Krish Dholakia
8a35354dd6
Merge pull request #3378 from duckboy81/patch-1
Expand access for other jwt algorithms
2024-05-10 10:07:36 -07:00
Nick Wong
d3a228d03b
added changes from upstream
Merge branch 'main' into fix/error-on-get-user-role
2024-05-09 16:14:14 -07:00
Nick Wong
c42f1ce2c6
removed extra default dict return, which causes error if user_role is a string 2024-05-09 16:13:26 -07:00
Krrish Dholakia
927d36148f feat(proxy_server.py): expose new /team/list endpoint
Closes https://github.com/BerriAI/litellm/issues/3523
2024-05-09 13:21:00 -07:00
Krrish Dholakia
e3f25a4a1f fix(auth_checks.py): fix 'get_end_user_object'
await cache get
2024-05-09 13:05:56 -07:00
Krish Dholakia
8ad979cdfe
Merge branch 'main' into litellm_region_based_routing 2024-05-08 22:19:51 -07:00
Krrish Dholakia
3d18897d69 feat(router.py): enable filtering model group by 'allowed_model_region' 2024-05-08 22:10:17 -07:00
Krrish Dholakia
db666b01e5 feat(proxy_server.py): add CRUD endpoints for 'end_user' management
allow admin to specify region + default models for end users
2024-05-08 18:50:36 -07:00
Ishaan Jaff
dea4a081c7 ui - new build 2024-05-08 18:45:54 -07:00