- class langgraph_agent_toolkit.core.observability.langfuse.LangfuseObservability(remote_first=False)[source][source]
Bases:
BaseObservabilityPlatformLangfuse implementation of observability platform.
Initialize LangfuseObservability.
- Parameters:
remote_first (bool) – If True, prioritize remote prompts over local ones.
- __init__(remote_first=False)[source][source]
Initialize LangfuseObservability.
- Parameters:
remote_first (bool) – If True, prioritize remote prompts over local ones.
- get_callback_handler(**kwargs)[source][source]
Get the Langfuse callback handler for LangChain.
- Return type:
LangchainCallbackHandler
- record_feedback(run_id, key, score, **kwargs)[source][source]
Record feedback/score for a trace in Langfuse.
- push_prompt(name, prompt_template, metadata=None, force_create_new_version=True)[source][source]
Push a prompt to Langfuse.
- Parameters:
- Return type:
None
- pull_prompt(name, return_with_prompt_object=False, cache_ttl_seconds=DEFAULT_CACHE_TTL_SECOND, template_format='f-string', label=None, version=None, **kwargs)[source][source]
Pull a prompt from Langfuse.
- Parameters:
name (str) – Name of the prompt
return_with_prompt_object (bool) – If True, return tuple of (prompt, langfuse_prompt)
cache_ttl_seconds (int | None) – Cache TTL for the prompt
template_format (Literal['f-string', 'mustache', 'jinja2']) – Format for the template
label (str | None) – Optional label to fetch specific version
version (int | None) – Optional version number to fetch
**kwargs – Additional kwargs (prompt_label, prompt_version as aliases)
- Returns:
ChatPromptTemplate or tuple of (ChatPromptTemplate, langfuse_prompt)
- Return type:
ChatPromptTemplate | str | dict | None | Tuple[ChatPromptTemplate | str | dict | None, Any]
- delete_prompt(name)[source][source]
Delete a prompt - Langfuse doesn’t support programmatic deletion.
- Parameters:
name (str)
- Return type:
None
- trace_context(run_id, **kwargs)[source][source]
Create a Langfuse trace context with predefined trace ID.
- Parameters:
run_id (str) – The run ID to use as trace ID
**kwargs – Additional context parameters (user_id, input, agent_name, etc.)
- Yields:
The span object (new SDK) or None (old SDK)