Skip to content

Commit f3955e2

Browse files
committed
🔨 update langfuse.mdc rule to reflect v3.x API migration
1 parent ddac1cb commit f3955e2

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

.cursor/rules/langfuse.mdc

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,28 @@ description:
33
globs: *.py
44
alwaysApply: false
55
---
6-
LangFuse is an LLM observability tool, to see how LLMs are behaving in our application. It uses callbacks to reord LLM inference. You should always use it when using LLM applications, to track if the LLM is behaving as we want it to.
6+
Langfuse is an LLM observability tool used to monitor LLM behavior in our application. It uses decorators and callbacks to record LLM inference. Always use it in LLM-related modules to ensure traceability.
77

8-
Below is the most typical usage.
8+
### Langfuse v3 Migration Guide
9+
As of Langfuse SDK v3.x, the `langfuse.decorators` module structure has changed.
10+
11+
**Typical Usage:**
912

1013
```python
11-
from langfuse.decorators import observe, langfuse_context
14+
from langfuse import observe, get_client
1215

13-
@observe
16+
@observe()
1417
def function_name(...):
18+
# To rename the span/observation or update metadata:
19+
get_client().update_current_span(name=f"descriptive_name_{id}")
1520

16-
# If we don't want the name of the span to be "function_name", and want to give a more descriptive name like with email, we should use the following
17-
langfuse_context.update_current_observation(name=f"{email}")
21+
# To get trace or observation IDs:
22+
trace_id = get_client().get_current_trace_id()
23+
observation_id = get_client().get_current_observation_id()
1824
```
1925

26+
**Key Changes from v2:**
27+
1. Import `observe` and `get_client` directly from `langfuse`.
28+
2. Replace `langfuse_context` with `get_client()`.
29+
3. Use `update_current_span()` instead of `update_current_observation()`.
30+

0 commit comments

Comments
 (0)