Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 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
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ uv run mypy langfuse --no-error-summary

### Update openapi spec

1. Generate Fern Python SDK in [langfuse](https://github.com/langfuse/langfuse) and copy the files generated in `generated/python` into the `langfuse/api` folder in this repo.
2. Execute the linter by running `uv run ruff format .`
3. Rebuild and deploy the package to PyPi.
A PR with the changes is automatically created upon changing the Spec in the langfuse repo.

### Publish release

Expand Down
22 changes: 11 additions & 11 deletions langfuse/_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ def create_score(
trace_id: Optional[str] = None,
score_id: Optional[str] = None,
observation_id: Optional[str] = None,
data_type: Optional[Literal["CATEGORICAL"]] = "CATEGORICAL",
data_type: Optional[Literal["CATEGORICAL", "TEXT"]] = "CATEGORICAL",
comment: Optional[str] = None,
config_id: Optional[str] = None,
metadata: Optional[Any] = None,
Expand Down Expand Up @@ -1777,13 +1777,13 @@ def create_score(

Args:
name: Name of the score (e.g., "relevance", "accuracy")
value: Score value (can be numeric for NUMERIC/BOOLEAN types or string for CATEGORICAL)
value: Score value (can be numeric for NUMERIC/BOOLEAN types or string for CATEGORICAL/TEXT)
session_id: ID of the Langfuse session to associate the score with
dataset_run_id: ID of the Langfuse dataset run to associate the score with
trace_id: ID of the Langfuse trace to associate the score with
observation_id: Optional ID of the specific observation to score. Trace ID must be provided too.
score_id: Optional custom ID for the score (auto-generated if not provided)
data_type: Type of score (NUMERIC, BOOLEAN, or CATEGORICAL)
data_type: Type of score (NUMERIC, BOOLEAN, CATEGORICAL, or TEXT)
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
Expand Down Expand Up @@ -1907,7 +1907,7 @@ def score_current_span(
name: str,
value: str,
score_id: Optional[str] = None,
data_type: Optional[Literal["CATEGORICAL"]] = "CATEGORICAL",
data_type: Optional[Literal["CATEGORICAL", "TEXT"]] = "CATEGORICAL",
comment: Optional[str] = None,
config_id: Optional[str] = None,
metadata: Optional[Any] = None,
Expand All @@ -1931,9 +1931,9 @@ def score_current_span(

Args:
name: Name of the score (e.g., "relevance", "accuracy")
value: Score value (can be numeric for NUMERIC/BOOLEAN types or string for CATEGORICAL)
value: Score value (can be numeric for NUMERIC/BOOLEAN types or string for CATEGORICAL/TEXT)
score_id: Optional custom ID for the score (auto-generated if not provided)
data_type: Type of score (NUMERIC, BOOLEAN, or CATEGORICAL)
data_type: Type of score (NUMERIC, BOOLEAN, CATEGORICAL, or TEXT)
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
Expand Down Expand Up @@ -1971,7 +1971,7 @@ def score_current_span(
name=name,
value=cast(str, value),
score_id=score_id,
data_type=cast(Literal["CATEGORICAL"], data_type),
data_type=cast(Literal["CATEGORICAL", "TEXT"], data_type),
comment=comment,
config_id=config_id,
metadata=metadata,
Expand All @@ -1997,7 +1997,7 @@ def score_current_trace(
name: str,
value: str,
score_id: Optional[str] = None,
data_type: Optional[Literal["CATEGORICAL"]] = "CATEGORICAL",
data_type: Optional[Literal["CATEGORICAL", "TEXT"]] = "CATEGORICAL",
comment: Optional[str] = None,
config_id: Optional[str] = None,
metadata: Optional[Any] = None,
Expand All @@ -2022,9 +2022,9 @@ def score_current_trace(

Args:
name: Name of the score (e.g., "user_satisfaction", "overall_quality")
value: Score value (can be numeric for NUMERIC/BOOLEAN types or string for CATEGORICAL)
value: Score value (can be numeric for NUMERIC/BOOLEAN types or string for CATEGORICAL/TEXT)
score_id: Optional custom ID for the score (auto-generated if not provided)
data_type: Type of score (NUMERIC, BOOLEAN, or CATEGORICAL)
data_type: Type of score (NUMERIC, BOOLEAN, CATEGORICAL, or TEXT)
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
Expand Down Expand Up @@ -2060,7 +2060,7 @@ def score_current_trace(
name=name,
value=cast(str, value),
score_id=score_id,
data_type=cast(Literal["CATEGORICAL"], data_type),
data_type=cast(Literal["CATEGORICAL", "TEXT"], data_type),
comment=comment,
config_id=config_id,
metadata=metadata,
Expand Down
16 changes: 8 additions & 8 deletions langfuse/_client/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def score(
value: str,
score_id: Optional[str] = None,
data_type: Optional[
Literal[ScoreDataType.CATEGORICAL]
Literal[ScoreDataType.CATEGORICAL, ScoreDataType.TEXT]
] = ScoreDataType.CATEGORICAL,
comment: Optional[str] = None,
config_id: Optional[str] = None,
Expand All @@ -335,9 +335,9 @@ def score(

Args:
name: Name of the score (e.g., "relevance", "accuracy")
value: Score value (numeric for NUMERIC/BOOLEAN, string for CATEGORICAL)
value: Score value (numeric for NUMERIC/BOOLEAN, string for CATEGORICAL/TEXT)
score_id: Optional custom ID for the score (auto-generated if not provided)
data_type: Type of score (NUMERIC, BOOLEAN, or CATEGORICAL)
data_type: Type of score (NUMERIC, BOOLEAN, CATEGORICAL, or TEXT)
comment: Optional comment or explanation for the score
config_id: Optional ID of a score config defined in Langfuse
timestamp: Optional timestamp for the score (defaults to current UTC time)
Expand All @@ -364,7 +364,7 @@ def score(
trace_id=self.trace_id,
observation_id=self.id,
score_id=score_id,
data_type=cast(Literal["CATEGORICAL"], data_type),
data_type=cast(Literal["CATEGORICAL", "TEXT"], data_type),
comment=comment,
config_id=config_id,
timestamp=timestamp,
Expand Down Expand Up @@ -395,7 +395,7 @@ def score_trace(
value: str,
score_id: Optional[str] = None,
data_type: Optional[
Literal[ScoreDataType.CATEGORICAL]
Literal[ScoreDataType.CATEGORICAL, ScoreDataType.TEXT]
] = ScoreDataType.CATEGORICAL,
comment: Optional[str] = None,
config_id: Optional[str] = None,
Expand Down Expand Up @@ -423,9 +423,9 @@ def score_trace(

Args:
name: Name of the score (e.g., "user_satisfaction", "overall_quality")
value: Score value (numeric for NUMERIC/BOOLEAN, string for CATEGORICAL)
value: Score value (numeric for NUMERIC/BOOLEAN, string for CATEGORICAL/TEXT)
score_id: Optional custom ID for the score (auto-generated if not provided)
data_type: Type of score (NUMERIC, BOOLEAN, or CATEGORICAL)
data_type: Type of score (NUMERIC, BOOLEAN, CATEGORICAL, or TEXT)
comment: Optional comment or explanation for the score
config_id: Optional ID of a score config defined in Langfuse
timestamp: Optional timestamp for the score (defaults to current UTC time)
Expand All @@ -451,7 +451,7 @@ def score_trace(
value=cast(str, value),
trace_id=self.trace_id,
score_id=score_id,
data_type=cast(Literal["CATEGORICAL"], data_type),
data_type=cast(Literal["CATEGORICAL", "TEXT"], data_type),
comment=comment,
config_id=config_id,
timestamp=timestamp,
Expand Down
18 changes: 18 additions & 0 deletions langfuse/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,16 @@
ScoreV1_Boolean,
ScoreV1_Categorical,
ScoreV1_Numeric,
ScoreV1_Text,
Score_Boolean,
Score_Categorical,
Score_Correction,
Score_Numeric,
Score_Text,
Session,
SessionWithTraces,
TextScore,
TextScoreV1,
Trace,
TraceWithDetails,
TraceWithFullDetails,
Expand Down Expand Up @@ -281,10 +285,12 @@
GetScoresResponseDataCategorical,
GetScoresResponseDataCorrection,
GetScoresResponseDataNumeric,
GetScoresResponseDataText,
GetScoresResponseData_Boolean,
GetScoresResponseData_Categorical,
GetScoresResponseData_Correction,
GetScoresResponseData_Numeric,
GetScoresResponseData_Text,
GetScoresResponseTraceData,
)
from .sessions import PaginatedSessions
Expand Down Expand Up @@ -377,10 +383,12 @@
"GetScoresResponseDataCategorical": ".scores",
"GetScoresResponseDataCorrection": ".scores",
"GetScoresResponseDataNumeric": ".scores",
"GetScoresResponseDataText": ".scores",
"GetScoresResponseData_Boolean": ".scores",
"GetScoresResponseData_Categorical": ".scores",
"GetScoresResponseData_Correction": ".scores",
"GetScoresResponseData_Numeric": ".scores",
"GetScoresResponseData_Text": ".scores",
"GetScoresResponseTraceData": ".scores",
"HealthResponse": ".health",
"IngestionError": ".ingestion",
Expand Down Expand Up @@ -489,10 +497,12 @@
"ScoreV1_Boolean": ".commons",
"ScoreV1_Categorical": ".commons",
"ScoreV1_Numeric": ".commons",
"ScoreV1_Text": ".commons",
"Score_Boolean": ".commons",
"Score_Categorical": ".commons",
"Score_Correction": ".commons",
"Score_Numeric": ".commons",
"Score_Text": ".commons",
"SdkLogBody": ".ingestion",
"SdkLogEvent": ".ingestion",
"ServiceProviderConfig": ".scim",
Expand All @@ -501,6 +511,8 @@
"SessionWithTraces": ".commons",
"Sort": ".trace",
"TextPrompt": ".prompts",
"TextScore": ".commons",
"TextScoreV1": ".commons",
"Trace": ".commons",
"TraceBody": ".ingestion",
"TraceEvent": ".ingestion",
Expand Down Expand Up @@ -664,10 +676,12 @@ def __dir__():
"GetScoresResponseDataCategorical",
"GetScoresResponseDataCorrection",
"GetScoresResponseDataNumeric",
"GetScoresResponseDataText",
"GetScoresResponseData_Boolean",
"GetScoresResponseData_Categorical",
"GetScoresResponseData_Correction",
"GetScoresResponseData_Numeric",
"GetScoresResponseData_Text",
"GetScoresResponseTraceData",
"HealthResponse",
"IngestionError",
Expand Down Expand Up @@ -776,10 +790,12 @@ def __dir__():
"ScoreV1_Boolean",
"ScoreV1_Categorical",
"ScoreV1_Numeric",
"ScoreV1_Text",
"Score_Boolean",
"Score_Categorical",
"Score_Correction",
"Score_Numeric",
"Score_Text",
"SdkLogBody",
"SdkLogEvent",
"ServiceProviderConfig",
Expand All @@ -788,6 +804,8 @@ def __dir__():
"SessionWithTraces",
"Sort",
"TextPrompt",
"TextScore",
"TextScoreV1",
"Trace",
"TraceBody",
"TraceEvent",
Expand Down
12 changes: 12 additions & 0 deletions langfuse/api/commons/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@
ScoreV1_Boolean,
ScoreV1_Categorical,
ScoreV1_Numeric,
ScoreV1_Text,
Score_Boolean,
Score_Categorical,
Score_Correction,
Score_Numeric,
Score_Text,
Session,
SessionWithTraces,
TextScore,
TextScoreV1,
Trace,
TraceWithDetails,
TraceWithFullDetails,
Expand Down Expand Up @@ -110,12 +114,16 @@
"ScoreV1_Boolean": ".types",
"ScoreV1_Categorical": ".types",
"ScoreV1_Numeric": ".types",
"ScoreV1_Text": ".types",
"Score_Boolean": ".types",
"Score_Categorical": ".types",
"Score_Correction": ".types",
"Score_Numeric": ".types",
"Score_Text": ".types",
"Session": ".types",
"SessionWithTraces": ".types",
"TextScore": ".types",
"TextScoreV1": ".types",
"Trace": ".types",
"TraceWithDetails": ".types",
"TraceWithFullDetails": ".types",
Expand Down Expand Up @@ -196,12 +204,16 @@ def __dir__():
"ScoreV1_Boolean",
"ScoreV1_Categorical",
"ScoreV1_Numeric",
"ScoreV1_Text",
"Score_Boolean",
"Score_Categorical",
"Score_Correction",
"Score_Numeric",
"Score_Text",
"Session",
"SessionWithTraces",
"TextScore",
"TextScoreV1",
"Trace",
"TraceWithDetails",
"TraceWithFullDetails",
Expand Down
19 changes: 18 additions & 1 deletion langfuse/api/commons/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,23 @@
Score_Categorical,
Score_Correction,
Score_Numeric,
Score_Text,
)
from .score_config import ScoreConfig
from .score_config_data_type import ScoreConfigDataType
from .score_data_type import ScoreDataType
from .score_source import ScoreSource
from .score_v1 import ScoreV1, ScoreV1_Boolean, ScoreV1_Categorical, ScoreV1_Numeric
from .score_v1 import (
ScoreV1,
ScoreV1_Boolean,
ScoreV1_Categorical,
ScoreV1_Numeric,
ScoreV1_Text,
)
from .session import Session
from .session_with_traces import SessionWithTraces
from .text_score import TextScore
from .text_score_v1 import TextScoreV1
from .trace import Trace
from .trace_with_details import TraceWithDetails
from .trace_with_full_details import TraceWithFullDetails
Expand Down Expand Up @@ -96,12 +105,16 @@
"ScoreV1_Boolean": ".score_v1",
"ScoreV1_Categorical": ".score_v1",
"ScoreV1_Numeric": ".score_v1",
"ScoreV1_Text": ".score_v1",
"Score_Boolean": ".score",
"Score_Categorical": ".score",
"Score_Correction": ".score",
"Score_Numeric": ".score",
"Score_Text": ".score",
"Session": ".session",
"SessionWithTraces": ".session_with_traces",
"TextScore": ".text_score",
"TextScoreV1": ".text_score_v1",
"Trace": ".trace",
"TraceWithDetails": ".trace_with_details",
"TraceWithFullDetails": ".trace_with_full_details",
Expand Down Expand Up @@ -177,12 +190,16 @@ def __dir__():
"ScoreV1_Boolean",
"ScoreV1_Categorical",
"ScoreV1_Numeric",
"ScoreV1_Text",
"Score_Boolean",
"Score_Categorical",
"Score_Correction",
"Score_Numeric",
"Score_Text",
"Session",
"SessionWithTraces",
"TextScore",
"TextScoreV1",
"Trace",
"TraceWithDetails",
"TraceWithFullDetails",
Expand Down
Loading
Loading