Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cba545a
fix(caching): convert arg to equivalent kwargs in llm caching handler
Nov 12, 2024
a6ef9ab
fix(caching_handler.py): don't pass args to caching
Nov 12, 2024
a210214
fix(caching): remove all *args from caching.py
Nov 12, 2024
0bc9864
fix(caching): consistent function signatures + abc method
Nov 12, 2024
16bbed7
test(caching_unit_tests.py): add unit tests for llm caching
Nov 12, 2024
fcec2a3
refactor(litellm_logging.py): move to using cache key from hidden par…
Nov 12, 2024
56d0f53
fix(router.py): drop redis password requirement
Nov 12, 2024
da6cb4c
fix(proxy_server.py): fix faulty slack alerting check
Nov 12, 2024
96464a3
fix(langfuse.py): avoid copying functions/thread lock objects in meta…
Nov 12, 2024
7544685
test: update test
Nov 12, 2024
e86a47b
fix(key_management_endpoints.py): fix /key/update with metadata update
Nov 12, 2024
e3e4b29
fix(key_management_endpoints.py): fix key_prepare_update helper
Nov 13, 2024
4dc0d2d
fix(key_management_endpoints.py): reset value to none if set in key u…
Nov 13, 2024
e3f3f64
fix: update test
Nov 13, 2024
e470c08
Litellm dev 11 11 2024 (#6693)
Nov 11, 2024
60e4388
add clear doc string for GCS bucket logging
ishaan-jaff Nov 11, 2024
3ad8092
Add docs to export logs to Laminar (#6674)
dinmukhamedm Nov 11, 2024
91bfa58
(Feat) Add langsmith key based logging (#6682)
ishaan-jaff Nov 11, 2024
f3da4af
(fix) OpenAI's optional messages[].name does not work with Mistral A…
ishaan-jaff Nov 12, 2024
cff7aa5
add xAI on Admin UI (#6680)
ishaan-jaff Nov 12, 2024
37ee207
(docs) add benchmarks on 1K RPS (#6704)
ishaan-jaff Nov 12, 2024
99b205d
(feat) add cost tracking stable diffusion 3 on Bedrock (#6676)
ishaan-jaff Nov 12, 2024
5fb3a69
fix raise correct error 404 when /key/info is called on non-existent …
ishaan-jaff Nov 12, 2024
fae59f2
bump: version 1.52.4 β†’ 1.52.5
ishaan-jaff Nov 12, 2024
1adc6d5
add defaults used for GCS logging
ishaan-jaff Nov 12, 2024
09365cb
LiteLLM Minor Fixes & Improvements (11/12/2024) (#6705)
Nov 12, 2024
1f489dd
bump: version 1.52.5 β†’ 1.52.6
Nov 12, 2024
390541c
(feat) helm hook to sync db schema (#6715)
ishaan-jaff Nov 12, 2024
79a50e6
fix migrations job.yml
ishaan-jaff Nov 12, 2024
3677ced
handle standalone DB on helm hook
ishaan-jaff Nov 12, 2024
172bff0
fix argo cd annotations
ishaan-jaff Nov 12, 2024
e68cac5
fix db migration helm hook
ishaan-jaff Nov 12, 2024
20f119b
fix migration job
ishaan-jaff Nov 12, 2024
2359de4
doc fix Using Http/2 with Hypercorn
ishaan-jaff Nov 13, 2024
2bd0167
(fix proxy redis) Add redis sentinel support (#6154)
ishaan-jaff Nov 13, 2024
124b600
Fix: Update gpt-4o costs to that of gpt-4o-2024-08-06 (#6714)
klieret Nov 13, 2024
4b0c7b5
(fix) using Anthropic `response_format={"type": "json_object"}` (#6721)
ishaan-jaff Nov 13, 2024
e937133
(feat) Add cost tracking for Azure Dall-e-3 Image Generation + use b…
ishaan-jaff Nov 13, 2024
a096c01
fix remove dup test (#6718)
ishaan-jaff Nov 13, 2024
be64f92
(build) update db helm hook
ishaan-jaff Nov 13, 2024
6771647
(build) helm db pre sync hook
ishaan-jaff Nov 13, 2024
dd68053
(build) helm db sync hook
ishaan-jaff Nov 13, 2024
ad1e77b
test: run test_team_logging firdst
Nov 13, 2024
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ jobs:
pip install "pytest-retry==1.6.3"
pip install "pytest-cov==5.0.0"
pip install "pytest-asyncio==0.21.1"
pip install pytest-mock
pip install "respx==0.21.1"
pip install "google-generativeai==0.3.2"
pip install "google-cloud-aiplatform==1.43.0"
Expand Down
30 changes: 30 additions & 0 deletions deploy/charts/litellm-helm/templates/migrations-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This job runs the prisma migrations for the LiteLLM DB.

apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "litellm.fullname" . }}-migrations
annotations:
argocd.argoproj.io/hook: PreSync
argocd.argoproj.io/hook-delete-policy: Never # keep this resource so we can debug status on ArgoCD
checksum/config: {{ toYaml .Values | sha256sum }}
spec:
template:
spec:
containers:
- name: prisma-migrations
image: "ghcr.io/berriai/litellm:main-stable"
command: ["python", "litellm/proxy/prisma_migration.py"]
workingDir: "/app"
env:
{{- if .Values.db.deployStandalone }}
- name: DATABASE_URL
value: postgresql://{{ .Values.postgresql.auth.username }}:{{ .Values.postgresql.auth.password }}@{{ .Release.Name }}-postgresql/{{ .Values.postgresql.auth.database }}
{{- else if .Values.db.useExisting }}
- name: DATABASE_URL
value: {{ .Values.db.url | quote }}
{{- end }}
- name: DISABLE_SCHEMA_UPDATE
value: "{{ .Values.migrationJob.disableSchemaUpdate }}"
restartPolicy: OnFailure
backoffLimit: {{ .Values.migrationJob.backoffLimit }}
9 changes: 9 additions & 0 deletions deploy/charts/litellm-helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,12 @@ postgresql:
redis:
enabled: false
architecture: standalone

# Prisma migration job settings
migrationJob:
enabled: true # Enable or disable the schema migration Job
retries: 3 # Number of retries for the Job in case of failure
backoffLimit: 4 # Backoff limit for Job restarts
disableSchemaUpdate: false # Skip schema migrations for specific environments. When True, the job will exit with code 0.


1 change: 1 addition & 0 deletions docs/my-website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock
41 changes: 41 additions & 0 deletions docs/my-website/docs/benchmarks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Benchmarks

Benchmarks for LiteLLM Gateway (Proxy Server)

Locust Settings:
- 2500 Users
- 100 user Ramp Up


## Basic Benchmarks

Overhead when using a Deployed Proxy vs Direct to LLM
- Latency overhead added by LiteLLM Proxy: 107ms

| Metric | Direct to Fake Endpoint | Basic Litellm Proxy |
|--------|------------------------|---------------------|
| RPS | 1196 | 1133.2 |
| Median Latency (ms) | 33 | 140 |


## Logging Callbacks

### [GCS Bucket Logging](https://docs.litellm.ai/docs/proxy/bucket)

Using GCS Bucket has **no impact on latency, RPS compared to Basic Litellm Proxy**

| Metric | Basic Litellm Proxy | LiteLLM Proxy with GCS Bucket Logging |
|--------|------------------------|---------------------|
| RPS | 1133.2 | 1137.3 |
| Median Latency (ms) | 140 | 138 |


### [LangSmith logging](https://docs.litellm.ai/docs/proxy/logging)

Using LangSmith has **no impact on latency, RPS compared to Basic Litellm Proxy**

| Metric | Basic Litellm Proxy | LiteLLM Proxy with LangSmith |
|--------|------------------------|---------------------|
| RPS | 1133.2 | 1135 |
| Median Latency (ms) | 140 | 132 |

12 changes: 11 additions & 1 deletion docs/my-website/docs/observability/opentelemetry_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,19 @@ OTEL_ENDPOINT="http://0.0.0.0:4317"

</TabItem>

<TabItem value="laminar" label="Log to Laminar">

```shell
OTEL_EXPORTER="otlp_grpc"
OTEL_ENDPOINT="https://api.lmnr.ai:8443"
OTEL_HEADERS="authorization=Bearer <project-api-key>"
```

</TabItem>

</Tabs>

Use just 2 lines of code, to instantly log your LLM responses **across all providers** with OpenTelemetry:
Use just 1 line of code, to instantly log your LLM responses **across all providers** with OpenTelemetry:

```python
litellm.callbacks = ["otel"]
Expand Down
93 changes: 93 additions & 0 deletions docs/my-website/docs/providers/anthropic.md
Original file line number Diff line number Diff line change
Expand Up @@ -864,3 +864,96 @@ Human: How do I boil water?
Assistant:
```


## Usage - PDF

Pass base64 encoded PDF files to Anthropic models using the `image_url` field.

<Tabs>
<TabItem value="sdk" label="SDK">

### **using base64**
```python
from litellm import completion, supports_pdf_input
import base64
import requests

# URL of the file
url = "https://storage.googleapis.com/cloud-samples-data/generative-ai/pdf/2403.05530.pdf"

# Download the file
response = requests.get(url)
file_data = response.content

encoded_file = base64.b64encode(file_data).decode("utf-8")

## check if model supports pdf input - (2024/11/11) only claude-3-5-haiku-20241022 supports it
supports_pdf_input("anthropic/claude-3-5-haiku-20241022") # True

response = completion(
model="anthropic/claude-3-5-haiku-20241022",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "You are a very professional document summarization specialist. Please summarize the given document."},
{
"type": "image_url",
"image_url": f"data:application/pdf;base64,{encoded_file}", # πŸ‘ˆ PDF
},
],
}
],
max_tokens=300,
)

print(response.choices[0])
```
</TabItem>
<TabItem value="proxy" lable="PROXY">

1. Add model to config

```yaml
- model_name: claude-3-5-haiku-20241022
litellm_params:
model: anthropic/claude-3-5-haiku-20241022
api_key: os.environ/ANTHROPIC_API_KEY
```

2. Start Proxy

```
litellm --config /path/to/config.yaml
```

3. Test it!

```bash
curl http://0.0.0.0:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <YOUR-LITELLM-KEY>" \
-d '{
"model": "claude-3-5-haiku-20241022",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "You are a very professional document summarization specialist. Please summarize the given document"
},
{
"type": "image_url",
"image_url": "data:application/pdf;base64,{encoded_file}" # πŸ‘ˆ PDF
}
}
]
}
],
"max_tokens": 300
}'

```
</TabItem>
</Tabs>
12 changes: 10 additions & 2 deletions docs/my-website/docs/proxy/bucket.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LiteLLM Supports Logging to the following Cloud Buckets
- (Enterprise) ✨ [Google Cloud Storage Buckets](#logging-proxy-inputoutput-to-google-cloud-storage-buckets)
- (Free OSS) [Amazon s3 Buckets](#logging-proxy-inputoutput---s3-buckets)

## Logging Proxy Input/Output to Google Cloud Storage Buckets
## Google Cloud Storage Buckets

Log LLM Logs to [Google Cloud Storage Buckets](https://cloud.google.com/storage?hl=en)

Expand All @@ -20,6 +20,14 @@ Log LLM Logs to [Google Cloud Storage Buckets](https://cloud.google.com/storage?
:::


| Property | Details |
|----------|---------|
| Description | Log LLM Input/Output to cloud storage buckets |
| Load Test Benchmarks | [Benchmarks](https://docs.litellm.ai/docs/benchmarks) |
| Google Docs on Cloud Storage | [Google Cloud Storage](https://cloud.google.com/storage?hl=en) |



### Usage

1. Add `gcs_bucket` to LiteLLM Config.yaml
Expand Down Expand Up @@ -85,7 +93,7 @@ curl --location 'http://0.0.0.0:4000/chat/completions' \
6. Save the JSON file and add the path to `GCS_PATH_SERVICE_ACCOUNT`


## Logging Proxy Input/Output - s3 Buckets
## s3 Buckets

We will use the `--config` to set

Expand Down
2 changes: 2 additions & 0 deletions docs/my-website/docs/proxy/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ litellm_settings:
type: "redis"
service_name: "mymaster"
sentinel_nodes: [["localhost", 26379]]
sentinel_password: "password" # [OPTIONAL]
```

</TabItem>
Expand All @@ -149,6 +150,7 @@ You can configure redis sentinel in your .env by setting `REDIS_SENTINEL_NODES`
```env
REDIS_SENTINEL_NODES='[["localhost", 26379]]'
REDIS_SERVICE_NAME = "mymaster"
REDIS_SENTINEL_PASSWORD = "password"
```

:::note
Expand Down
4 changes: 2 additions & 2 deletions docs/my-website/docs/proxy/configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,8 @@ router_settings:
| EMAIL_SUPPORT_CONTACT | Support contact email address
| GCS_BUCKET_NAME | Name of the Google Cloud Storage bucket
| GCS_PATH_SERVICE_ACCOUNT | Path to the Google Cloud service account JSON file
| GCS_FLUSH_INTERVAL | Flush interval for GCS logging (in seconds). Specify how often you want a log to be sent to GCS.
| GCS_BATCH_SIZE | Batch size for GCS logging. Specify after how many logs you want to flush to GCS. If `BATCH_SIZE` is set to 10, logs are flushed every 10 logs.
| GCS_FLUSH_INTERVAL | Flush interval for GCS logging (in seconds). Specify how often you want a log to be sent to GCS. **Default is 20 seconds**
| GCS_BATCH_SIZE | Batch size for GCS logging. Specify after how many logs you want to flush to GCS. If `BATCH_SIZE` is set to 10, logs are flushed every 10 logs. **Default is 2048**
| GENERIC_AUTHORIZATION_ENDPOINT | Authorization endpoint for generic OAuth providers
| GENERIC_CLIENT_ID | Client ID for generic OAuth providers
| GENERIC_CLIENT_SECRET | Client secret for generic OAuth providers
Expand Down
33 changes: 30 additions & 3 deletions docs/my-website/docs/proxy/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,35 @@ Provide an ssl certificate when starting litellm proxy server

Use this if you want to run the proxy with hypercorn to support http/2

**Usage**
Pass the `--run_hypercorn` flag when starting the proxy
Step 1. Build your custom docker image with hypercorn

```shell
# Use the provided base image
FROM ghcr.io/berriai/litellm:main-latest

# Set the working directory to /app
WORKDIR /app

# Copy the configuration file into the container at /app
COPY config.yaml .

# Make sure your docker/entrypoint.sh is executable
RUN chmod +x ./docker/entrypoint.sh

# Expose the necessary port
EXPOSE 4000/tcp

# πŸ‘‰ Key Change: Install hypercorn
RUN pip install hypercorn

# Override the CMD instruction with your desired command and arguments
# WARNING: FOR PROD DO NOT USE `--detailed_debug` it slows down response times, instead use the following CMD
# CMD ["--port", "4000", "--config", "config.yaml"]

CMD ["--port", "4000", "--config", "config.yaml", "--detailed_debug"]
```

Step 2. Pass the `--run_hypercorn` flag when starting the proxy

```shell
docker run \
Expand All @@ -699,7 +726,7 @@ docker run \
-e SERVER_ROOT_PATH="/api/v1"\
-e DATABASE_URL=postgresql://<user>:<password>@<host>:<port>/<dbname> \
-e LITELLM_MASTER_KEY="sk-1234"\
ghcr.io/berriai/litellm:main-latest \
your_custom_docker_image \
--config /app/config.yaml
--run_hypercorn
```
Expand Down
Loading