Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ jobs:
command: |
pwd
ls
python -m pytest tests/local_testing --cov=litellm --cov-report=xml -vv -k "router" -x -s -v --junitxml=test-results/junit.xml --durations=5
python -m pytest tests/local_testing tests/router_unit_tests --cov=litellm --cov-report=xml -vv -k "router" -x -s -v --junitxml=test-results/junit.xml --durations=5
no_output_timeout: 120m
- run:
name: Rename the coverage files
Expand Down Expand Up @@ -328,6 +328,48 @@ jobs:
paths:
- llm_translation_coverage.xml
- llm_translation_coverage
logging_testing:
docker:
- image: cimg/python:3.11
auth:
username: ${DOCKERHUB_USERNAME}
password: ${DOCKERHUB_PASSWORD}
working_directory: ~/project

steps:
- checkout
- run:
name: Install Dependencies
command: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
pip install "pytest==7.3.1"
pip install "pytest-retry==1.6.3"
pip install "pytest-cov==5.0.0"
pip install "pytest-asyncio==0.21.1"
pip install "respx==0.21.1"
# Run pytest and generate JUnit XML report
- run:
name: Run tests
command: |
pwd
ls
python -m pytest -vv tests/logging_callback_tests --cov=litellm --cov-report=xml -x -s -v --junitxml=test-results/junit.xml --durations=5
no_output_timeout: 120m
- run:
name: Rename the coverage files
command: |
mv coverage.xml logging_coverage.xml
mv .coverage logging_coverage

# Store test results
- store_test_results:
path: test-results
- persist_to_workspace:
root: .
paths:
- logging_coverage.xml
- logging_coverage
installing_litellm_on_python:
docker:
- image: circleci/python:3.8
Expand Down Expand Up @@ -380,6 +422,7 @@ jobs:
- run: python -c "from litellm import *" || (echo '🚨 import failed, this means you introduced unprotected imports! 🚨'; exit 1)
- run: ruff check ./litellm
- run: python ./tests/documentation_tests/test_general_setting_keys.py
- run: python ./tests/code_coverage_tests/router_code_coverage.py
- run: python ./tests/documentation_tests/test_env_keys.py

db_migration_disable_update_check:
Expand Down Expand Up @@ -768,7 +811,7 @@ jobs:
python -m venv venv
. venv/bin/activate
pip install coverage
coverage combine llm_translation_coverage litellm_router_coverage local_testing_coverage litellm_assistants_api_coverage ui_endpoint_testing_coverage
coverage combine llm_translation_coverage logging_coverage litellm_router_coverage local_testing_coverage litellm_assistants_api_coverage ui_endpoint_testing_coverage
coverage xml
- codecov/upload:
file: ./coverage.xml
Expand Down Expand Up @@ -1004,9 +1047,16 @@ workflows:
only:
- main
- /litellm_.*/
- logging_testing:
filters:
branches:
only:
- main
- /litellm_.*/
- upload-coverage:
requires:
- llm_translation_testing
- logging_testing
- litellm_router_testing
- local_testing
- litellm_assistants_api_testing
Expand Down Expand Up @@ -1035,6 +1085,7 @@ workflows:
- build_and_test
- load_testing
- llm_translation_testing
- logging_testing
- litellm_router_testing
- litellm_assistants_api_testing
- ui_endpoint_testing
Expand Down
33 changes: 11 additions & 22 deletions litellm/caching/caching_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
RedisSemanticCache,
S3Cache,
)
from litellm.litellm_core_utils.logging_utils import (
_assemble_complete_response_from_streaming_chunks,
)
from litellm.types.rerank import RerankResponse
from litellm.types.utils import (
CallTypes,
Expand Down Expand Up @@ -517,28 +520,14 @@ async def _add_streaming_response_to_cache(self, processed_chunk: ModelResponse)
"""
complete_streaming_response: Optional[
Union[ModelResponse, TextCompletionResponse]
] = None
if (
processed_chunk.choices[0].finish_reason is not None
): # if it's the last chunk
self.async_streaming_chunks.append(processed_chunk)
try:
end_time: datetime.datetime = datetime.datetime.now()
complete_streaming_response = litellm.stream_chunk_builder(
self.async_streaming_chunks,
messages=self.request_kwargs.get("messages", None),
start_time=self.start_time,
end_time=end_time,
)
except Exception as e:
verbose_logger.exception(
"Error occurred building stream chunk in success logging: {}".format(
str(e)
)
)
complete_streaming_response = None
else:
self.async_streaming_chunks.append(processed_chunk)
] = _assemble_complete_response_from_streaming_chunks(
result=processed_chunk,
start_time=self.start_time,
end_time=datetime.datetime.now(),
request_kwargs=self.request_kwargs,
streaming_chunks=self.async_streaming_chunks,
is_async=True,
)

# if a complete_streaming_response is assembled, add it to the cache
if complete_streaming_response is not None:
Expand Down
3 changes: 0 additions & 3 deletions litellm/integrations/gcs_bucket/gcs_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from litellm._logging import verbose_logger
from litellm.integrations.custom_logger import CustomLogger
from litellm.integrations.gcs_bucket.gcs_bucket_base import GCSBucketBase
from litellm.litellm_core_utils.logging_utils import (
convert_litellm_response_object_to_dict,
)
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler
from litellm.proxy._types import CommonProxyErrors, SpendLogsMetadata, SpendLogsPayload
from litellm.types.utils import (
Expand Down
3 changes: 0 additions & 3 deletions litellm/integrations/gcs_bucket/gcs_bucket_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import litellm
from litellm._logging import verbose_logger
from litellm.integrations.custom_logger import CustomLogger
from litellm.litellm_core_utils.logging_utils import (
convert_litellm_response_object_to_dict,
)
from litellm.llms.custom_httpx.http_handler import (
get_async_httpx_client,
httpxSpecialProvider,
Expand Down
Loading