Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions langfuse/_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,7 @@ def score_current_span(
data_type: Optional[Literal["NUMERIC", "BOOLEAN"]] = None,
comment: Optional[str] = None,
config_id: Optional[str] = None,
metadata: Optional[Any] = None,
) -> None: ...

@overload
Expand All @@ -2120,6 +2121,7 @@ def score_current_span(
data_type: Optional[Literal["CATEGORICAL"]] = "CATEGORICAL",
comment: Optional[str] = None,
config_id: Optional[str] = None,
metadata: Optional[Any] = None,
) -> None: ...

def score_current_span(
Expand All @@ -2131,6 +2133,7 @@ def score_current_span(
data_type: Optional[ScoreDataType] = None,
comment: Optional[str] = None,
config_id: Optional[str] = None,
metadata: Optional[Any] = None,
) -> None:
"""Create a score for the current active span.

Expand All @@ -2144,6 +2147,7 @@ def score_current_span(
data_type: Type of score (NUMERIC, BOOLEAN, or CATEGORICAL)
comment: Optional comment or explanation for the score
config_id: Optional ID of a score config defined in Langfuse
metadata: Optional metadata to be attached to the score

Example:
```python
Expand All @@ -2157,7 +2161,8 @@ def score_current_span(
name="relevance",
value=0.85,
data_type="NUMERIC",
comment="Mostly relevant but contains some tangential information"
comment="Mostly relevant but contains some tangential information",
metadata={"model": "gpt-4", "prompt_version": "v2"}
)
```
"""
Expand All @@ -2180,6 +2185,7 @@ def score_current_span(
data_type=cast(Literal["CATEGORICAL"], data_type),
comment=comment,
config_id=config_id,
metadata=metadata,
)

@overload
Expand All @@ -2192,6 +2198,7 @@ def score_current_trace(
data_type: Optional[Literal["NUMERIC", "BOOLEAN"]] = None,
comment: Optional[str] = None,
config_id: Optional[str] = None,
metadata: Optional[Any] = None,
) -> None: ...

@overload
Expand All @@ -2204,6 +2211,7 @@ def score_current_trace(
data_type: Optional[Literal["CATEGORICAL"]] = "CATEGORICAL",
comment: Optional[str] = None,
config_id: Optional[str] = None,
metadata: Optional[Any] = None,
) -> None: ...

def score_current_trace(
Expand All @@ -2215,6 +2223,7 @@ def score_current_trace(
data_type: Optional[ScoreDataType] = None,
comment: Optional[str] = None,
config_id: Optional[str] = None,
metadata: Optional[Any] = None,
) -> None:
"""Create a score for the current trace.

Expand All @@ -2229,6 +2238,7 @@ def score_current_trace(
data_type: Type of score (NUMERIC, BOOLEAN, or CATEGORICAL)
comment: Optional comment or explanation for the score
config_id: Optional ID of a score config defined in Langfuse
metadata: Optional metadata to be attached to the score

Example:
```python
Expand All @@ -2242,7 +2252,8 @@ def score_current_trace(
name="overall_quality",
value=0.95,
data_type="NUMERIC",
comment="High quality end-to-end response"
comment="High quality end-to-end response",
metadata={"evaluator": "gpt-4", "criteria": "comprehensive"}
)
```
"""
Expand All @@ -2263,6 +2274,7 @@ def score_current_trace(
data_type=cast(Literal["CATEGORICAL"], data_type),
comment=comment,
config_id=config_id,
metadata=metadata,
)

def flush(self) -> None:
Expand Down