bugfix:修复部分提示词导致的格式错误问题及langfuse客户端复用bug
This commit is contained in:
@@ -77,7 +77,8 @@ async def ainvoke_screen(
|
||||
from langfuse.langchain import CallbackHandler
|
||||
from langgraph.types import Command
|
||||
|
||||
handler = CallbackHandler()
|
||||
# 明确回调所属项目,避免进程中存在多个客户端时跳过追踪
|
||||
handler = CallbackHandler(public_key=os.getenv("LANGFUSE_PUBLIC_KEY"))
|
||||
# 在当前异步上下文执行回调,手动记录的 Jev generation 才会挂到所属节点。
|
||||
handler.run_inline = True
|
||||
resume = isinstance(payload, Command) and payload.resume is not None
|
||||
@@ -156,16 +157,16 @@ def observe_decision(request: Any) -> Iterator[Any]:
|
||||
只有图回调已经挂上当前 span 时才记。没有父 span 就跳过,避免 Jev 单独变成一条 trace
|
||||
这里不吞异常:失败时标 ERROR 后原样抛出,调用方的 DecisionError 类型不变
|
||||
"""
|
||||
if not tracing_enabled() or _ensure_client() is None or not _has_active_span():
|
||||
client = _ensure_client() if tracing_enabled() else None
|
||||
if client is None or not _has_active_span():
|
||||
yield None
|
||||
return
|
||||
|
||||
from langfuse import get_client
|
||||
|
||||
model = request.model or settings.typesafe_model
|
||||
# 意图判断用固定名字,方便以后按名字做评测。别的决策题不要都叫 classify-intent
|
||||
name = "classify-intent" if set(request.decisions) == {"intent"} else "run-decision"
|
||||
with get_client().start_as_current_observation(
|
||||
# 复用本应用已经选定的客户端
|
||||
with client.start_as_current_observation(
|
||||
as_type="generation",
|
||||
name=name,
|
||||
model=model,
|
||||
|
||||
Reference in New Issue
Block a user