langfuse generation spans with token usage; switch llm to vllm (qwen2.5-coder-7b on mcrndeb)
This commit is contained in:
@@ -83,7 +83,10 @@ class ComparePeriods(Analysis):
|
||||
system_len=len(interpret_system),
|
||||
user_len=len(interpret_user),
|
||||
))
|
||||
summary = chat(system=interpret_system, user=interpret_user, max_tokens=512)
|
||||
summary = chat(
|
||||
system=interpret_system, user=interpret_user,
|
||||
max_tokens=512, span_name="compare_periods.interpret",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception("compare_periods failed")
|
||||
await events.publish_current(events.tool_call_end("compare_periods", error=str(e)))
|
||||
@@ -122,6 +125,7 @@ def _generate_pair(question: str, period_a: str, period_b: str) -> dict[str, dic
|
||||
metrics_block=schema.render_metrics(),
|
||||
),
|
||||
max_tokens=1024,
|
||||
span_name="compare_periods.pair",
|
||||
)
|
||||
obj = json.loads(_extract_json(text))
|
||||
for k in ("a", "b"):
|
||||
|
||||
@@ -43,11 +43,13 @@ async def decide_next(question: str, metric: str, dimensions: list[str],
|
||||
history=format_history(slices),
|
||||
budget=budget,
|
||||
)
|
||||
with lf.span("drill_down.next", as_type="generation", input={"budget": budget}) as span:
|
||||
with lf.span("drill_down.next", input={"budget": budget}) as span:
|
||||
await events.publish_current(events.llm_call(
|
||||
"drill_down.next", system_len=len(system), user_len=len(user),
|
||||
))
|
||||
decision = _parse_json(chat(system=system, user=user, max_tokens=256))
|
||||
decision = _parse_json(chat(
|
||||
system=system, user=user, max_tokens=256, span_name="drill_down.next.gen",
|
||||
))
|
||||
|
||||
# Hard guard: the chosen dimension MUST be in the candidate list.
|
||||
if decision.get("action") == "drill":
|
||||
@@ -142,7 +144,7 @@ async def interpret(question: str, metric: str, slices: list[Slice]) -> str:
|
||||
await events.publish_current(events.llm_call(
|
||||
"drill_down.interpret", system_len=len(system), user_len=len(user),
|
||||
))
|
||||
return chat(system=system, user=user, max_tokens=512)
|
||||
return chat(system=system, user=user, max_tokens=512, span_name="drill_down.interpret")
|
||||
|
||||
|
||||
# ── Prompt-context formatters ──
|
||||
|
||||
Reference in New Issue
Block a user