Lunary
Lunary
Lunary는 LLM 챗봇을 관리하고 개선하는 팀을 돕는 오픈소스 플랫폼이에요. 관측성, 프롬프트 관리, 분석을 제공하죠. LiteLLM과 Lunary을 연동해 응답을 로깅하고 프롬프트 템플릿을 관리하는 방법을 알려드릴게요.
출처: 문서
본문
언제든지 이메일 또는 데모 예약으로 연락할 수 있어요.
LiteLLM Python SDK와 함께 사용 (Usage with LiteLLM Python SDK)
사전 요구사항 (Pre-Requisites)
uv add litellm lunary
빠른 시작 (Quick Start)
먼저 Lunary 대시보드에서 Lunary 공개 키를 받아 주세요.
두 줄의 코드만으로 모든 프로바이더의 응답을 Lunary에 즉시 로깅할 수 있어요:
litellm.success_callback = ["lunary"]
litellm.failure_callback = ["lunary"]
전체 코드:
from litellm import completion
os.environ["LUNARY_PUBLIC_KEY"] = "your-lunary-public-key" # from https://app.lunary.ai/)
os.environ["OPENAI_API_KEY"] = ""
litellm.success_callback = ["lunary"]
litellm.failure_callback = ["lunary"]
response = completion(
model="gpt-5.6-terra",
messages=[{"role": "user", "content": "Hi there 👋"}],
user="ishaan_litellm"
)
LangChain ChatLiteLLM과 함께 사용 (Usage with LangChain ChatLiteLLM)
import os
from langchain.chat_models import ChatLiteLLM
from langchain.schema import HumanMessage
import litellm
os.environ["LUNARY_PUBLIC_KEY"] = "" # from https://app.lunary.ai/settings
os.environ['OPENAI_API_KEY']="sk-..."
litellm.success_callback = ["lunary"]
litellm.failure_callback = ["lunary"]
chat = ChatLiteLLM(
model="gpt-5.6-terra"
)
messages = [
HumanMessage(
content="what model are you"
)
]
chat(messages)
프롬프트 템플릿과 함께 사용 (Usage with Prompt Templates)
Lunary로 프롬프트 템플릿을 관리하고, LiteLLM으로 모든 LLM 프로바이더에서 사용할 수 있어요.
from litellm import completion
import lunary
template = lunary.render_template("template-slug", {
"name": "John", # Inject variables
})
litellm.success_callback = ["lunary"]
result = completion(**template)
사용자 지정 체인과 함께 사용 (Usage with custom chains)
LLM 호출을 사용자 지정 체인 안에 감싸서 트레이스로 시각화할 수 있어요.
import litellm
from litellm import completion
import lunary
litellm.success_callback = ["lunary"]
litellm.failure_callback = ["lunary"]
@lunary.chain("My custom chain name")
def my_chain(chain_input):
chain_run_id = lunary.run_manager.current_run_id
response = completion(
model="gpt-5.6-terra",
messages=[{"role": "user", "content": "Say 1"}],
metadata={"parent_run_id": chain_run_id},
)
response = completion(
model="gpt-5.6-terra",
messages=[{"role": "user", "content": "Say 2"}],
metadata={"parent_run_id": chain_run_id},
)
chain_output = response.choices[0].message
return chain_output
my_chain("Chain input")
LiteLLM 프록시 서버와 함께 사용 (Usage with LiteLLM Proxy Server)
1단계: 의존성 설치 및 환경 변수 설정
의존성을 설치해 주세요.
uv add litellm lunary
https://app.lunary.ai/settings에서 Lunary 공개 키를 받아 주세요.
export LUNARY_PUBLIC_KEY="<your-public-key>"
2단계: config.yaml 생성 및 lunary 콜백 설정
model_list:
- model_name: "*"
litellm_params:
model: "*"
litellm_settings:
success_callback: ["lunary"]
failure_callback: ["lunary"]
3단계: LiteLLM 프록시 시작
litellm --config config.yaml
4단계: 요청 보내기
curl -X POST 'http://0.0.0.0:4000/chat/completions' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-5.6-terra",
"messages": [
{
"role": "system",
"content": "You are a helpful math tutor. Guide the user through the solution step by step."
},
{
"role": "user",
"content": "how can I solve 8x + 7 = -23"
}
]
}'
LiteLLM 프록시에 요청하는 다양한 방법에 대한 자세한 내용은 이 페이지에서 확인할 수 있어요.
지원 및 창업자와 소통 (Support & Talk to Founders)
- Schedule Demo 👋
- Community Discord 💭
- Our emails ✉️ [email protected] / [email protected]