Commit graph

4664 commits

Author SHA1 Message Date
Krish Dholakia
2e767c4885 UI (new_usage.tsx): Report 'total_tokens' + report success/failure calls (#9675)
* feat(internal_user_endpoints.py): return 'total_tokens' in `/user/daily/analytics`

* test(test_internal_user_endpoints.py): add unit test to assert spend metrics and dailyspend metadata always report the same fields

* build(schema.prisma): record success + failure calls to daily user table

allows understanding why model requests might exceed provider requests (e.g. user hit rate limit error)

* fix(internal_user_endpoints.py): report success / failure requests in API

* fix(proxy/utils.py): default to success

status can be missing or none at times for successful requests

* feat(new_usage.tsx): show success/failure calls on UI

* style(new_usage.tsx): ui cleanup

* fix: fix linting error

* fix: fix linting error

* feat(litellm-proxy-extras/): add new migration files
2025-03-31 22:48:43 -07:00
Krish Dholakia
564cdbc01f fix(proxy_server.py): Fix "Circular reference detected" error when max_parallel_requests = 0 (#9671)
* fix(proxy_server.py): remove non-functional parent backoff/retry on /chat/completion

Causes circular reference error

* fix(http_parsing_utils.py): safely return parsed body - don't allow mutation of cached request body by client functions

Root cause fix for circular reference error

* Revert "fix: Anthropic prompt caching on GCP Vertex AI (#9605)" (#9670)

This reverts commit a8673246dc.

* add type hints for AnthropicMessagesResponse

* define types for response form AnthropicMessagesResponse

* fix response typing

* allow using litellm.messages.acreate and litellm.messages.create

* fix anthropic_messages implementation

* add clear type hints to litellm.messages.create functions

* fix anthropic_messages

* working anthropic API tests

* fixes - anthropic messages interface

* use new anthropic interface

* fix code quality check

* docs anthropic messages endpoint

* add namespace_packages = True to mypy

* fix mypy lint errors

* docs anthropic messages interface

* test: fix unit test

* test(test_http_parsing_utils.py): update tests

---------

Co-authored-by: Ishaan Jaff <ishaanjaffer0324@gmail.com>
2025-03-31 22:06:02 -07:00
Ishaan Jaff
ee51ba97ff fix linting 2025-03-31 21:33:05 -07:00
Ishaan Jaff
b3fc324b48 unit testing for SpendUpdateQueue 2025-03-31 21:25:24 -07:00
Krish Dholakia
b01de8030b Openrouter streaming fixes + Anthropic 'file' message support (#9667)
* fix(openrouter/transformation.py): Handle error in openrouter stream

Fixes https://github.com/Aider-AI/aider/issues/3550

* test(test_openrouter_chat_transformation.py): add unit tests

* feat(anthropic/chat/transformation.py): add openai 'file' message content type support

Closes https://github.com/BerriAI/litellm/issues/9463

* fix(factory.py): add bedrock converse support for openai 'file' message content type

Closes https://github.com/BerriAI/litellm/issues/9463
2025-03-31 21:22:59 -07:00
Ishaan Jaff
55a2cf00f5 linting fix get_aggregated_db_spend_update_transactions 2025-03-31 21:15:21 -07:00
Ishaan Jaff
731e7f2284 add SpendUpdateQueue 2025-03-31 19:42:20 -07:00
Ishaan Jaff
9e015e6750 add spend tracking config.yaml 2025-03-31 19:42:00 -07:00
Ishaan Jaff
e71da94f03 test fixes 2025-03-31 19:33:10 -07:00
Ishaan Jaff
46c3b8e2a8 get_aggregated_db_spend_update_transactions 2025-03-31 19:31:53 -07:00
Ishaan Jaff
b845b8f863 use typed data structure for queue 2025-03-31 19:28:17 -07:00
Ishaan Jaff
5b706c049a fix update_end_user_spend 2025-03-31 19:05:58 -07:00
Ishaan Jaff
ab3a4064d0 fix docstring 2025-03-31 19:03:02 -07:00
Ishaan Jaff
c99cf3088c test spend accuracy 2025-03-31 19:01:17 -07:00
Ishaan Jaff
fc72a61627 fix update_database helper on db_spend_update_writer 2025-03-31 19:01:00 -07:00
Ishaan Jaff
462b43084f use spend_update_queue for RedisUpdateBuffer 2025-03-31 18:40:52 -07:00
Ishaan Jaff
0484cf5847 add new SpendUpdateQueue 2025-03-31 18:40:03 -07:00
Ishaan Jaff
8312b733d2 run black formatting 2025-03-31 16:12:31 -07:00
Ishaan Jaff
518723bfc7 docs mcp litellm 2025-03-29 21:59:58 -07:00
Ishaan Jaff
44ff6991b5 docs mcp tools 2025-03-29 20:42:14 -07:00
Ishaan Jaff
f5c0afcf96 Merge pull request #9642 from BerriAI/litellm_mcp_improvements_expose_sse_urls
[Feat] - MCP improvements, add support for using SSE MCP servers
2025-03-29 19:37:57 -07:00
Krish Dholakia
70f993d3d7 Add gemini audio input support + handle special tokens in sagemaker response (#9640)
* fix(internal_user_endpoints.py): cleanup unused variables on beta endpoint

no team/org split on daily user endpoint

* build(model_prices_and_context_window.json): gemini-2.0-flash supports audio input

* feat(gemini/transformation.py): support passing audio input to gemini

* test: fix test

* fix(gemini/transformation.py): support audio input as a url

enables passing google cloud bucket urls

* fix(gemini/transformation.py): support explicitly passing format of file

* fix(gemini/transformation.py): expand support for inferred file types from url

* fix(sagemaker/completion/transformation.py): fix special token error when counting sagemaker tokens

* test: fix import
2025-03-29 19:23:09 -07:00
Ishaan Jaff
198fb23d0c fix listing mcp tools 2025-03-29 18:40:58 -07:00
Ishaan Jaff
dde78a8ae9 fix order of imports 2025-03-29 18:32:06 -07:00
Ishaan Jaff
70e67c872b list_tool_rest_api 2025-03-29 17:55:37 -07:00
Ishaan Jaff
55ad7cbda0 fix import errors without mcp 2025-03-29 17:44:32 -07:00
Ishaan Jaff
6fa5de6353 fix showing list of MCP tools 2025-03-29 16:23:58 -07:00
Ishaan Jaff
759303687a render MCP tools on ui logs page 2025-03-29 16:01:34 -07:00
Ishaan Jaff
2dfd302a82 log MCP tool call metadata in SLP 2025-03-29 15:50:13 -07:00
Krish Dholakia
797a4bb1d5 install prisma migration files - connects litellm proxy to litellm's prisma migration files (#9637)
* build(README.md): initial commit adding a separate folder for additional proxy files. Meant to reduce size of core package

* build(litellm-proxy-extras/): new pip package for storing migration files

allows litellm proxy to use migration files, without adding them to core repo

* build(litellm-proxy-extras/): cleanup pyproject.toml

* build: move prisma migration files inside new proxy extras package

* build(run_migration.py): update script to write to correct folder

* build(proxy_cli.py): load in migration files from litellm-proxy-extras

Closes https://github.com/BerriAI/litellm/issues/9558

* build: add MIT license to litellm-proxy-extras

* test: update test

* fix: fix schema

* bump: version 0.1.0 → 0.1.1

* build(publish-proxy-extras.sh): add script for publishing new proxy-extras version

* build(liccheck.ini): add litellm-proxy-extras to authorized packages

* fix(litellm-proxy-extras/utils.py): move prisma migrate logic inside extra proxy pkg

easier since migrations folder already there

* build(pre-commit-config.yaml): add litellm_proxy_extras to ci tests

* docs(config_settings.md): document new env var

* build(pyproject.toml): bump relevant files when litellm-proxy-extras version changed

* build(pre-commit-config.yaml): run poetry check on litellm-proxy-extras as well
2025-03-29 15:27:09 -07:00
Ishaan Jaff
f1e1cdf730 working MCP tool call logging 2025-03-29 15:20:52 -07:00
Ishaan Jaff
db026d385c working MCP call tool method 2025-03-29 14:42:19 -07:00
Ishaan Jaff
7d00abc37f endpoints to list and call tools 2025-03-29 14:31:35 -07:00
Ishaan Jaff
6c7b42f575 REST API endpoint for MCP 2025-03-29 13:35:46 -07:00
Ishaan Jaff
790febde47 add testing mcp server 2025-03-29 12:52:46 -07:00
Ishaan Jaff
061f98c570 mcp server manager 2025-03-29 12:51:16 -07:00
Ishaan Jaff
c0d07987c4 use global_mcp_server_manager 2025-03-29 12:46:13 -07:00
Ishaan Jaff
ecc31e7899 init mcp client manager 2025-03-29 11:26:18 -07:00
Krish Dholakia
d7b294dd0a build(pyproject.toml): add new dev dependencies - for type checking (#9631)
* build(pyproject.toml): add new dev dependencies - for type checking

* build: reformat files to fit black

* ci: reformat to fit black

* ci(test-litellm.yml): make tests run clear

* build(pyproject.toml): add ruff

* fix: fix ruff checks

* build(mypy/): fix mypy linting errors

* fix(hashicorp_secret_manager.py): fix passing cert for tls auth

* build(mypy/): resolve all mypy errors

* test: update test

* fix: fix black formatting

* build(pre-commit-config.yaml): use poetry run black

* fix(proxy_server.py): fix linting error

* fix: fix ruff safe representation error
2025-03-29 11:02:13 -07:00
Ishaan Jaff
2f059f5028 MAX_REDIS_BUFFER_DEQUEUE_COUNT 2025-03-28 20:59:28 -07:00
Ishaan Jaff
64bc3f0c66 fix linting 2025-03-28 20:57:28 -07:00
Ishaan Jaff
0944640d6b Merge branch 'main' into litellm_use_redis_for_updates 2025-03-28 20:12:29 -07:00
Ishaan Jaff
93c20b8d2d fix - locking in memory leads to failing tests 2025-03-28 20:10:58 -07:00
Ishaan Jaff
fb98bd3a4a test local spend accuracy 2025-03-28 19:52:39 -07:00
Ishaan Jaff
96e4369160 prisma client in_memory_transaction_lock 2025-03-28 19:52:07 -07:00
Ishaan Jaff
96812a7da0 use asyncio lock for updating PrismaClient txs 2025-03-28 19:51:15 -07:00
Ishaan Jaff
7a63cbe8d0 redis update buffer queue 2025-03-28 17:24:54 -07:00
Ishaan Jaff
36f15f19af debugging for Redis TX management 2025-03-28 16:16:44 -07:00
Ishaan Jaff
b4e9683889 add docstring for DBSpendUpdateTransactions 2025-03-28 15:20:28 -07:00
Ishaan Jaff
cc9f47b1d2 fix loc of DBSpendUpdateTransactions 2025-03-28 15:17:01 -07:00