Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Base image for building
ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/python:latest-dev
ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base

# Runtime image
ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/python:latest-dev
ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base
# Builder stage
FROM $LITELLM_BUILD_IMAGE AS builder

Expand All @@ -12,11 +12,9 @@ WORKDIR /app
USER root

# Install build dependencies
RUN apk add --no-cache gcc python3-dev openssl openssl-dev
RUN apk add --no-cache bash gcc py3-pip python3 python3-dev openssl openssl-dev


RUN pip install --upgrade pip>=24.3.1 && \
pip install build
RUN python -m pip install build

# Copy the current directory contents into the container at /app
COPY . .
Expand Down Expand Up @@ -48,10 +46,7 @@ FROM $LITELLM_RUNTIME_IMAGE AS runtime
USER root

# Install runtime dependencies
RUN apk add --no-cache openssl tzdata

# Upgrade pip to fix CVE-2025-8869
RUN pip install --upgrade pip>=24.3.1
RUN apk add --no-cache bash openssl tzdata nodejs npm python3 py3-pip

WORKDIR /app
# Copy the current directory contents into the container at /app
Expand Down
16 changes: 9 additions & 7 deletions docker/Dockerfile.database
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Base image for building
ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/python:latest-dev
ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base

# Runtime image
ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/python:latest-dev
ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base
# Builder stage
FROM $LITELLM_BUILD_IMAGE AS builder

Expand All @@ -13,13 +13,15 @@ USER root

# Install build dependencies
RUN apk add --no-cache \
build-base \
bash \
gcc \
py3-pip \
python3 \
python3-dev \
openssl \
openssl-dev


RUN pip install --upgrade pip && \
pip install build
RUN python -m pip install build

# Copy the current directory contents into the container at /app
COPY . .
Expand All @@ -46,7 +48,7 @@ FROM $LITELLM_RUNTIME_IMAGE AS runtime
USER root

# Install runtime dependencies
RUN apk add --no-cache openssl
RUN apk add --no-cache bash openssl tzdata nodejs npm python3 py3-pip

WORKDIR /app
# Copy the current directory contents into the container at /app
Expand Down
19 changes: 15 additions & 4 deletions docker/Dockerfile.non_root
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Base images
ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/python:latest-dev
ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/python:latest-dev
ARG LITELLM_BUILD_IMAGE=cgr.dev/chainguard/wolfi-base
ARG LITELLM_RUNTIME_IMAGE=cgr.dev/chainguard/wolfi-base

# -----------------
# Builder Stage
Expand All @@ -10,7 +10,18 @@ WORKDIR /app

# Install build dependencies including Node.js for UI build
USER root
RUN apk add --no-cache build-base bash nodejs npm \
RUN apk add --no-cache \
python3 \
py3-pip \
clang \
llvm \
lld \
gcc \
linux-headers \
build-base \
bash \
nodejs \
npm \
&& pip install --no-cache-dir --upgrade pip build

# Copy project files
Expand Down Expand Up @@ -56,7 +67,7 @@ WORKDIR /app
# Install runtime dependencies
USER root
RUN apk upgrade --no-cache && \
apk add --no-cache bash libstdc++ ca-certificates openssl supervisor
apk add --no-cache python3 py3-pip bash openssl tzdata nodejs npm supervisor

# Copy only necessary artifacts from builder stage for runtime
COPY . .
Expand Down
8 changes: 6 additions & 2 deletions litellm/litellm_core_utils/prompt_templates/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,17 @@ def is_non_content_values_set(message: AllMessageValues) -> bool:

def _audio_or_image_in_message_content(message: AllMessageValues) -> bool:
"""
Checks if message content contains an image or audio
Checks if message content contains an image or audio.
Supports both OpenAI format (image_url) and Anthropic format (image).
"""
message_content = message.get("content")
if message_content:
if message_content is not None and isinstance(message_content, list):
for c in message_content:
if c.get("type") == "image_url" or c.get("type") == "input_audio":
content_type = c.get("type")
# OpenAI format: image_url, input_audio
# Anthropic format: image
if content_type in ("image_url", "input_audio", "image"):
return True
return False

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# What is this?
## Handler file for calling claude-3 on vertex ai
from typing import Any, List, Optional
from typing import Any, Dict, List, Optional

import httpx

Expand All @@ -25,6 +25,28 @@ def __init__(self, status_code, message):
) # Call the base class constructor with the parameters it needs


def get_anthropic_beta_from_headers(headers: Dict) -> List[str]:
"""
Extract anthropic-beta header values and convert them to a list.
Supports comma-separated values from user headers.

Used by Vertex AI Anthropic transformation for consistent handling
of anthropic-beta headers that should be passed to Vertex AI.

Args:
headers (dict): Request headers dictionary

Returns:
List[str]: List of anthropic beta feature strings, empty list if no header
"""
anthropic_beta_header = headers.get("anthropic-beta")
if not anthropic_beta_header:
return []

# Split comma-separated values and strip whitespace
return [beta.strip() for beta in anthropic_beta_header.split(",")]


class VertexAIAnthropicConfig(AnthropicConfig):
"""
Reference:https://docs.anthropic.com/claude/reference/messages_post
Expand Down Expand Up @@ -68,6 +90,31 @@ def transform_request(
)

data.pop("model", None) # vertex anthropic doesn't accept 'model' parameter

# Handle anthropic_beta from user headers
anthropic_beta_list = get_anthropic_beta_from_headers(headers)

# Auto-add computer-use beta if computer use tools are present
tools = data.get("tools", [])
if tools:
for tool in tools:
tool_type = tool.get("type", "")
if tool_type.startswith("computer_"):
# Auto-add the computer-use beta header
if "computer-use-2024-10-22" not in anthropic_beta_list:
anthropic_beta_list.append("computer-use-2024-10-22")
break

# Remove duplicates while preserving order
if anthropic_beta_list:
unique_betas = []
seen = set()
for beta in anthropic_beta_list:
if beta not in seen:
unique_betas.append(beta)
seen.add(beta)
data["anthropic_beta"] = unique_betas

return data

def transform_response(
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Loading