litellm/litellm/litellm_core_utils
yuneng-jiang 9c0cd6e02e Fix ruff lint errors: unused imports, undefined names, and statement counts
Remove unused imports (F401), add missing TYPE_CHECKING imports for
forward references (F821), and extract helpers to reduce statement
counts below the 50-statement limit (PLR0915).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 14:34:43 -07:00
..
audio_utils Use audio content for caching 2025-12-08 19:31:22 +05:30
llm_cost_calc refactor(cost): dedupe image token usage cost helper 2026-02-26 15:07:51 -06:00
llm_response_utils Fix test_anthropic_messages_openai_model_streaming_cost_injection & openrouter image gen 2026-03-09 11:29:04 +05:30
prompt_templates Merge branch 'main' into litellm_oss_staging_03_10_2026 2026-03-11 18:32:17 +05:30
specialty_caches [Bug]: Performance Fix Max langfuse clients reached: 20 is greater than 20 (#11285) 2025-05-30 22:34:39 -07:00
tokenizers Code Quality Improvement - remove tokenizers/ from /llms (#7163) 2024-12-10 23:50:15 -08:00
api_route_to_call_types.py Agent Guardrails - on streaming output (#21206) 2026-02-14 11:36:52 -08:00
app_crypto.py [Fix] SQS Logger - Add Base64 handling (#16028) 2025-10-28 16:41:32 -07:00
asyncify.py (core sdk fix) - fix fallbacks stuck in infinite loop (#7751) 2025-01-13 19:34:34 -08:00
cached_imports.py fix: reduced __inits__ overhead in 7% (#14689) 2025-09-18 17:18:05 -07:00
cli_token_utils.py [Feat] Proxy CLI: Create a python method to login using litellm proxy (#14782) 2025-09-22 21:28:38 -07:00
core_helpers.py Fix ruff lint errors: unused imports, undefined names, and statement counts 2026-03-11 14:34:43 -07:00
coroutine_checker.py fix: iscoroutine removed from hot path +50 RPS (#14649) 2025-09-17 19:01:43 -07:00
credential_accessor.py fix(router.py): support reusable credentials via passthrough router (#9758) 2025-04-04 18:40:14 -07:00
custom_logger_registry.py feat: ability to trace metrics 2026-02-25 22:03:51 +05:30
dd_tracing.py _add_dd_apm_tags_for_litellm_call_id (#22219) 2026-02-26 16:42:23 -08:00
default_encoding.py fix: resolve Read-only file system error in non-root images (#19449) 2026-01-20 19:00:52 -08:00
dot_notation_indexing.py Add Kubernetes ServiceAccount JWT authentication support (#18055) 2026-01-02 14:02:31 +05:30
duration_parser.py Revert "feat: add model_cost aliases expansion support" 2026-03-10 22:39:19 -03:00
env_utils.py fix(callbacks): allow MAX_CALLBACKS override via env var (#20781) 2026-02-09 12:11:32 -08:00
exception_mapping_utils.py Fix encrypted content streaming affinity issue 2026-03-03 18:37:22 +05:30
fallback_utils.py fix: filter internal params in fallback code and fix test issues (#17941) 2025-12-13 15:05:26 -08:00
get_blog_posts.py fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
get_litellm_params.py Bug Fix: auto-inject prompt caching support for Gemini models (#21881) 2026-03-03 20:25:35 -08:00
get_llm_provider_logic.py feat(provider): add Amazon Bedrock Mantle as a first-class provider 2026-03-05 00:03:40 -05:00
get_model_cost_map.py fix: close docstring in _expand_model_aliases 2026-03-10 23:08:06 -03:00
get_provider_specific_headers.py [Fix] Forward anthropic-beta headers to Bedrock, VertexAI (#15700) 2025-10-18 16:26:32 -07:00
get_supported_openai_params.py merge: resolve conflicts between main and litellm_oss_staging_03_04_2026 2026-03-10 10:45:04 -03:00
health_check_helpers.py add docs and formatting 2026-02-28 14:08:09 +05:30
health_check_utils.py (Refactor) - Re use litellm.completion/litellm.embedding etc for health checks (#7455) 2024-12-28 18:38:54 -08:00
initialize_dynamic_callback_params.py Fix test_global_redaction_off_with_dynamic_params 2026-02-05 18:26:03 +05:30
json_validation_rule.py [Feat] Add Bridge from generateContent <> /chat/completions (#12081) 2025-06-27 11:08:55 -07:00
litellm_logging.py Bug Fix: auto-inject prompt caching support for Gemini models (#21881) 2026-03-03 20:25:35 -08:00
llm_request_utils.py [Feat] Enterprise - Allow dynamically disabling callbacks in request headers (#11985) 2025-06-23 14:32:05 -07:00
logging_callback_manager.py Merge origin/main into perf/callback-registration-routing 2026-02-21 12:40:23 -08:00
logging_utils.py fix(types): resolve MyPy assignment type errors in logging_utils and vertex transformation 2026-02-20 13:46:51 -03:00
logging_worker.py [Release Day] - Fixed CI/CD issues & changed processes (#19902) 2026-01-28 17:57:24 -08:00
mock_functions.py Support returning virtual key in custom auth + Handle provider-specific optional params for embedding calls (#11346) 2025-06-03 07:24:13 -07:00
model_param_helper.py perf: cache _get_relevant_args_to_use_for_logging() at module level (#20077) 2026-02-02 10:54:49 -08:00
model_response_utils.py fix: resolve memory leak caused by Pydantic 2.11+ deprecation warnings (#16110) 2025-11-01 13:16:32 -07:00
README.md Guardrails API - add streaming support (#17400) 2025-12-02 22:52:09 -08:00
realtime_streaming.py fix: resolve ruff PLR0915 and mypy type checking lint errors (#22359) 2026-02-28 15:43:26 -08:00
redact_messages.py Revert "feat: add model_cost aliases expansion support" 2026-03-10 22:39:19 -03:00
response_header_helpers.py fix(utils.py): guarantee openai-compatible headers always exist in response 2024-09-28 21:08:15 -07:00
rules.py fix: remove slow string operation (#14955) 2025-09-26 13:25:59 -07:00
safe_json_dumps.py fix: shared health check serialization (#21119) 2026-02-13 09:15:43 -08:00
safe_json_loads.py add support to parse metadata (#10832) 2025-05-14 12:03:49 -07:00
sensitive_data_masker.py fix: don't mask cost_per_token fields in SensitiveDataMasker 2026-02-20 18:13:27 -08:00
streaming_chunk_builder_utils.py fix(streaming): return None from count_reasoning_tokens when no reasoning content found (#23076) 2026-03-07 17:03:53 -08:00
streaming_handler.py fix(streaming): prevent Vertex AI Claude content truncation when finish_reason races content 2026-03-04 22:44:48 +01:00
thread_pool_executor.py (Fixes) OpenAI Streaming Token Counting + Fixes usage track when litellm.turn_off_message_logging=True (#8156) 2025-01-31 15:06:37 -08:00
token_counter.py remove prompt from getting logged (#21831) 2026-02-21 14:49:11 -08:00

Folder Contents

This folder contains general-purpose utilities that are used in multiple places in the codebase.

Core files:

  • streaming_handler.py: The core streaming logic + streaming related helper utils
  • core_helpers.py: code used in types/ - e.g. map_finish_reason.
  • exception_mapping_utils.py: utils for mapping exceptions to openai-compatible error types.
  • default_encoding.py: code for loading the default encoding (tiktoken)
  • get_llm_provider_logic.py: code for inferring the LLM provider from a given model name.
  • duration_parser.py: code for parsing durations - e.g. "1d", "1mo", "10s"
  • api_route_to_call_types.py: mapping of API routes to their corresponding CallTypes (e.g., /chat/completions -> [acompletion, completion])