Skip to content

Commit 0388ce2

Browse files
committed
Open source the proxy
1 parent acb168f commit 0388ce2

File tree

15 files changed

+1043
-2
lines changed

15 files changed

+1043
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ env.bak/
105105
venv.bak/
106106
*.backup
107107

108+
# Secrets
109+
secrets.json
110+
108111
# Spyder project settings
109112
.spyderproject
110113
.spyproject

eval_protocol/adapters/fireworks_tracing.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
from __future__ import annotations
88
import logging
99
import requests
10-
import time
1110
from datetime import datetime
1211
from typing import Any, Dict, List, Optional, Protocol
12+
import os
1313

1414
from eval_protocol.models import EvaluationRow, InputMetadata, ExecutionMetadata, Message
1515
from .base import BaseAdapter
@@ -349,9 +349,11 @@ def get_evaluation_rows(
349349
else:
350350
url = f"{self.base_url}/v1/traces"
351351

352+
headers = {"Authorization": f"Bearer {os.environ.get('FIREWORKS_API_KEY')}"}
353+
352354
result = None
353355
try:
354-
response = requests.get(url, params=params, timeout=self.timeout)
356+
response = requests.get(url, params=params, timeout=self.timeout, headers=headers)
355357
response.raise_for_status()
356358
result = response.json()
357359
except requests.exceptions.HTTPError as e:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Metadata Extraction Gateway - Sits in front of LiteLLM
2+
FROM python:3.11-slim
3+
4+
WORKDIR /app
5+
6+
# Prevent Python from buffering stdout/stderr
7+
ENV PYTHONUNBUFFERED=1
8+
9+
# Set secrets path to proxy directory
10+
ENV SECRETS_PATH=/app/proxy_core/secrets.json
11+
12+
# Copy requirements file
13+
COPY ./requirements.txt /app/requirements.txt
14+
15+
# Install dependencies
16+
RUN pip install --no-cache-dir -r requirements.txt
17+
18+
# Copy the proxy package
19+
COPY ./proxy_core /app/proxy_core
20+
21+
# Expose port
22+
EXPOSE 4000
23+
24+
# Run the gateway as a module
25+
# LITELLM_URL will be set by environment (docker-compose or Cloud Run)
26+
CMD ["python", "-m", "proxy_core.main"]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
model_list:
2+
- model_name: "*"
3+
litellm_params:
4+
model: "*"
5+
litellm_settings:
6+
success_callback: ["langfuse"]
7+
failure_callback: ["langfuse"]
8+
drop_params: True
9+
general_settings:
10+
allow_client_side_credentials: true
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
services:
2+
# Redis - For tracking assistant message counts
3+
redis:
4+
image: redis:7-alpine
5+
platform: linux/amd64
6+
container_name: proxy-redis
7+
ports:
8+
- "6379:6379" # Expose for debugging if needed
9+
networks:
10+
- litellm-network
11+
restart: unless-stopped
12+
command: redis-server --appendonly yes
13+
volumes:
14+
- redis-data:/data
15+
16+
# LiteLLM Backend - Handles actual LLM proxying
17+
litellm-backend:
18+
image: litellm/litellm:v1.77.3-stable
19+
platform: linux/amd64
20+
container_name: litellm-backend
21+
command: ["--config", "/app/config.yaml", "--port", "4000", "--host", "0.0.0.0"]
22+
environment:
23+
- LANGFUSE_PUBLIC_KEY=dummy # Set dummy public and private key so Langfuse instance initializes in LiteLLM, then real keys get sent in proxy
24+
- LANGFUSE_SECRET_KEY=dummy
25+
- LANGFUSE_HOST=https://langfuse.fireworks.ai
26+
volumes:
27+
- ./config_no_cache.yaml:/app/config.yaml:ro
28+
ports:
29+
- "4001:4000" # Expose on 4001 for direct access if needed
30+
networks:
31+
- litellm-network
32+
restart: unless-stopped
33+
34+
# Metadata Gateway - Public-facing service that extracts metadata from URLs
35+
metadata-gateway:
36+
build:
37+
context: .
38+
dockerfile: Dockerfile.gateway
39+
container_name: metadata-gateway
40+
environment:
41+
# Point to the LiteLLM backend service
42+
- LITELLM_URL=http://litellm-backend:4000
43+
- PORT=4000
44+
# Redis configuration for assistant message counting
45+
- REDIS_HOST=redis
46+
- REDIS_PORT=6379
47+
# No password for local Redis
48+
- REQUEST_TIMEOUT=300
49+
# Logging level: INFO (default)
50+
- LOG_LEVEL=INFO
51+
ports:
52+
- "4000:4000" # Main public-facing port
53+
networks:
54+
- litellm-network
55+
depends_on:
56+
- litellm-backend
57+
- redis
58+
restart: unless-stopped
59+
60+
networks:
61+
litellm-network:
62+
driver: bridge
63+
64+
volumes:
65+
redis-data:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from .models import ProxyConfig
2+
from .app import create_app
3+
from .auth import AuthProvider, NoAuthProvider
4+
5+
__all__ = [
6+
"ProxyConfig",
7+
"create_app",
8+
"AuthProvider",
9+
"NoAuthProvider",
10+
]

0 commit comments

Comments
 (0)