Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save isakulaksiz/90feb3fbe489fffeda70e8a4762938e5 to your computer and use it in GitHub Desktop.

Select an option

Save isakulaksiz/90feb3fbe489fffeda70e8a4762938e5 to your computer and use it in GitHub Desktop.
LiteLLM & Langfuse İzlenebilirlik Sistemi Kurulum Rehberi
Bu rehber; yerel dil modellerini (LM Studio) merkezi bir proxy (LiteLLM) üzerinden yönetmeyi ve tüm trafiği bir izleme paneli (Langfuse) üzerinden takip etmeyi sağlar.
1. Mimari Yapı
Sistem, Docker üzerinde izole bir ağda (litellm-net) çalışan üç ana bileşenden oluşur:
PostgreSQL 16: Veritabanı katmanı.
Langfuse: İzleme ve analiz arayüzü.
LiteLLM Proxy: Model yönetimi ve API gateway.
2. Kurulum Adımları
A. Network ve Veritabanı Hazırlığı
Öncelikle konteynerlerin birbirini tanıması için ağı oluşturun ve veritabanını başlatın:
+1
Bash
# Docker Network Oluşturma
docker network create litellm-net [cite: 11]
# PostgreSQL 16 Başlatma
docker run -d --name litellm-postgres \
--network litellm-net \
-e POSTGRES_USER=litellm \
-e POSTGRES_PASSWORD=litellm \
-e POSTGRES_DB=litellm \
-p 5432:5432 \
-v litellm_pgdata:/var/lib/postgresql/data \
postgres:16 [cite: 15, 16, 17, 18, 19, 20, 21, 22]
B. Langfuse Kurulumu
İzleme panelini ayağa kaldırın:
Bash
docker run -d --name langfuse \
--network litellm-net \
-e NODE_ENV=production \
-e NEXTAUTH_URL=http://localhost:3000 \
-e NEXTAUTH_SECRET=mysecret \
-e SALT=mysalt \
-e DATABASE_URL="postgresql://litellm:litellm@litellm-postgres:5432/litellm" \
-p 3000:3000 \
langfuse/langfuse:2 [cite: 26, 27, 28, 29, 30, 31, 32, 33, 34]
Not: Kurulum sonrası http://localhost:3000 adresinden hesap oluşturup Settings > API Keys altındaki Public ve Secret Key bilgilerini not alın.
3. LiteLLM Yapılandırması
litellm_config.yaml dosyasını aşağıdaki gibi oluşturun:
YAML
model_list:
- model_name: gemma-3-4b
litellm_params:
[cite_start]model: google/gemma-3-4b # LM Studio'daki tam isim [cite: 45]
[cite_start]api_base: http://host.docker.internal:1234/v1 [cite: 46]
[cite_start]api_key: "lm-studio" [cite: 47]
general_settings:
[cite_start]master_key: sk-admin-1234 [cite: 49]
[cite_start]store_model_in_db: true [cite: 50]
litellm_settings:
[cite_start]success_callback: ["langfuse"] [cite: 52]
[cite_start]failure_callback: ["langfuse"] [cite: 53]
Ardından Proxy'yi başlatın:
Bash
docker run -d --name litellm --network litellm-net \
-p 4000:4000 \
-v "$PWD/litellm_config.yaml:/app/config.yaml" \
-e DATABASE_URL="postgresql://litellm:litellm@litellm-postgres:5432/litellm" \
-e LANGFUSE_PUBLIC_KEY="NOT_ALDIĞINIZ_PUBLIC_KEY" \
-e LANGFUSE_SECRET_KEY="NOT_ALDIĞINIZ_SECRET_KEY" \
-e LANGFUSE_HOST="http://langfuse:3000" \
ghcr.io/berriai/litellm-database:main-stable \
--config /app/config.yaml [cite: 57, 58, 59, 60, 61, 62, 63, 64, 65]
4. Test ve Erişim Bilgileri
LiteLLM Admin UI: http://localhost:4000/ui (Giriş: admin / sk-1234)
Langfuse UI: http://localhost:3000
Test isteği (cURL):
Bash
curl --location 'http://localhost:4000/v1/chat/completions' \
--header 'Authorization: Bearer sk-admin-1234' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemma-3-4b",
"messages": [{"role": "user", "content": "Sistem testi başarılı mı?"}]
}' [cite: 68, 69, 72, 73, 74]
5. Sorun Giderme
Kaynak Hatası: LM Studio'da daha düşük parametreli (1B/3B) modellere geçin.
Bağlantı Testi: docker exec -it litellm ping langfuse -c 3 komutuyla ağ erişimini kontrol edin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment