版本与发布
你可以在 Litefuse 中追踪 LLM 应用的变更对各项指标的影响。这让你能够:
- 在生产环境中运行实验(A/B 测试),并衡量其对成本、延迟和质量的影响。
- 示例:“切换到新模型会带来什么影响?”
- 解释指标随时间的变化。
- 示例:“为什么这条 chain 的延迟变高了?“
Releases
release 用于追踪应用程序的整体版本。它通常被设置为应用的 semantic version 或 git commit hash。
SDK 按以下顺序查找 release:
- SDK 初始化参数
- 环境变量
- 主流部署平台上自动设置的 release 标识符
初始化
Python SDK 允许你在初始化客户端时设置 release:
from langfuse import Langfuse
# Set the release when initializing the client
langfuse = Langfuse(release="v2.1.24")主流平台自动识别
如果没有设置其他 release,Langfuse SDK 会回退到一组已知的 release 环境变量。
支持的平台包括:Vercel、Heroku、Netlify。完整的环境变量列表可参见 JS/TS 和 Python。
Versions
version 参数可以添加到所有 observation 类型上(例如 span、generation、event 以及其他 observation 类型)。这样你就可以使用 Litefuse 分析来追踪某个特定 name 对象的新 version 对各项指标的影响。
在某个 context 内为所有 observation 设置 version:
from langfuse import observe, propagate_attributes
@observe()
def process_data():
# Propagate version to all child observations
with propagate_attributes(version="1.0"):
# All nested operations automatically inherit version
result = perform_processing()
return result直接创建 observation 时:
from langfuse import get_client, propagate_attributes
langfuse = get_client()
with langfuse.start_as_current_observation(as_type="span", name="process-data") as span:
# Propagate version to all child observations
with propagate_attributes(version="1.0"):
# All observations created here automatically have version="1.0"
with span.start_as_current_observation(
as_type="generation",
name="guess-countries",
model="gpt-4o"
) as generation:
# This generation automatically has version="1.0"
pass为某个具体 observation 设置 version:
from langfuse import get_client
langfuse = get_client()
with langfuse.start_as_current_observation(as_type="span", name="process-data", version="1.0") as span:
# This span has version="1.0"
passNote on Attribute Propagation
We use Attribute Propagation to propagate `version` across all observations of a trace. We will use all observations with `version` to create `version`-level metrics. Please consider the following when using Attribute Propagation:
- Values must be strings ≤200 characters
- Call early in your trace to ensure all observations are covered. This way you make sure that all Metrics in Litefuse are accurate.
- Invalid values are dropped with a warning
Learn more: Python SDK | TypeScript SDK
Litefuse 界面中的 version 参数

这个页面对你有帮助吗?