Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

langfuse

БесплатноБез исполняемых скриптовНе проверен

Langfuse is an open-source LLM engineering platform that records traces of LLM calls, versions prompts, scores outputs and runs experiments on datasets. Use…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Langfuse

Overview

Langfuse stores traces (one per request), made of nested observations: plain spans, LLM generations with model, token usage and cost, tool calls and retrievals. On top of traces it offers versioned prompts, scores (numeric, boolean, categorical), datasets and experiments. Both SDKs are built on OpenTelemetry. Current generations at the time of writing: Python langfuse 5.x and the scoped JavaScript packages @langfuse/* 6.x. The old APIs, langfuse.decorators / langfuse_context in Python and the unscoped langfuse and langfuse-vercel npm packages (the v3 SDK), are legacy; do not use them in new code.

Instructions

Step 1: Configure credentials

Create a project in Langfuse Cloud (or your own instance) and copy its API keys into the environment. Never hardcode them.

export LANGFUSE_PUBLIC_KEY="pk-lf-..."      # from Project settings > API keys
export LANGFUSE_SECRET_KEY="sk-lf-..."
export LANGFUSE_BASE_URL="https://cloud.langfuse.com"   # US region: https://us.cloud.langfuse.com
pip install langfuse                                   # Python
npm install @langfuse/tracing @langfuse/otel @langfuse/client @opentelemetry/sdk-trace-node   # TypeScript

Step 2: Trace a pipeline (Python)

@observe turns a function into an observation and nests calls automatically. Attributes that belong to the whole trace (user, session, tags) are set with the propagate_attributes context manager, and everything else is updated through get_client().

import os
from openai import OpenAI
from langfuse import observe, get_client, propagate_attributes

llm = OpenAI()
MODEL = os.environ["OPENAI_MODEL"]            # whichever chat model your account uses

@observe(as_type="retriever")
def retrieve(question: str) -> list[str]:
    return search_index(question, top_k=5)    # your vector-store call

@observe(as_type="generation")
def generate(question: str, docs: list[str]) -> str:
    resp = llm.chat.completions.create(model=MODEL, messages=[
        {"role": "system", "content": "Answer from this context:\n" + "\n".join(docs)},
        {"role": "user", "content": question},
    ])
    get_client().update_current_generation(
        model=MODEL,
        usage_details={"input": resp.usage.prompt_tokens, "output": resp.usage.completion_tokens},
    )
    return resp.choices[0].message.content

@observe()
def answer_question(question: str, user_id: str, session_id: str) -> str:
    with propagate_attributes(user_id=user_id, session_id=session_id, tags=["rag", "production"]):
        return generate(question, retrieve(question))

To skip the manual usage code, import the OpenAI drop-in instead: from langfuse.openai import OpenAI. It records model, tokens and cost for every call. Short-lived scripts and serverless handlers must call get_client().flush() before exiting, or the last spans are lost.

Step 3: Trace in TypeScript

Register the span processor once at startup, then create observations with @langfuse/tracing.

// instrumentation.ts
import { LangfuseSpanProcessor } from "@langfuse/otel";
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";

export const langfuseSpanProcessor = new LangfuseSpanProcessor();
new NodeTracerProvider({ spanProcessors: [langfuseSpanProcessor] }).register();
import { startActiveObservation, startObservation, propagateAttributes } from "@langfuse/tracing";

await propagateAttributes({ userId: "user-42", sessionId: "chat-981" }, async () => {
  await startActiveObservation("support-request", async (span) => {
    span.update({ input: { question: "How do I reset my password?" } });
    const generation = startObservation("answer", { model: process.env.OPENAI_MODEL, input: [] }, { asType: "generation" });
    // ... call the LLM, then:
    generation.update({ output: "Open Settings > Security ...", usageDetails: { input: 212, output: 64 } });
    generation.end();
    span.update({ output: "answered" });
  });
});
await langfuseSpanProcessor.forceFlush();   // required on serverless before the function freezes

Wrappers exist for other stacks: observeOpenAI from @langfuse/openai, a callback handler in @langfuse/langchain, and @langfuse/vercel-ai-sdk for AI SDK v7. For the AI SDK versions up to 6, turn on experimental_telemetry: { isEnabled: true } in each call and use the span processor above.

Step 4: Manage prompts

Create a prompt in the UI (variables are written {{company_name}}), publish it with a label such as production, and fetch it by label so the app picks up new versions without a deploy. Prompts are cached in the SDK; pass fallback so an outage does not break the app.

from langfuse import get_client

prompt = get_client().get_prompt("support-system-prompt", label="production",
                                 fallback="You are a support agent for {{company_name}}.")
system_message = prompt.compile(company_name="Northwind O
Полный SKILL.md на GitHub

Установить langfuse в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл langfuse?

Langfuse is an open-source LLM engineering platform that records traces of LLM calls, versions prompts, scores outputs and runs experiments on datasets. Use when asked to add observability to an LLM or RAG app, trace OpenAI or Vercel AI SDK calls, track token cost and latency, manage prompts outside the code, score outputs, build an evaluation dataset, or self-host Langfuse.

Как установить скилл langfuse?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл langfuse запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить langfuse с