diff --git a/langfuse/api/__init__.py b/langfuse/api/__init__.py index 9ec280087..835bdfefa 100644 --- a/langfuse/api/__init__.py +++ b/langfuse/api/__init__.py @@ -137,6 +137,7 @@ OpenAiResponseUsageSchema, OpenAiUsage, OptionalObservationBody, + Organization, OrganizationApiKey, OrganizationApiKeysResponse, OrganizationProject, @@ -187,6 +188,7 @@ Score, ScoreBody, ScoreConfig, + ScoreConfigDataType, ScoreConfigs, ScoreDataType, ScoreEvent, @@ -392,6 +394,7 @@ "OpenAiResponseUsageSchema", "OpenAiUsage", "OptionalObservationBody", + "Organization", "OrganizationApiKey", "OrganizationApiKeysResponse", "OrganizationProject", @@ -442,6 +445,7 @@ "Score", "ScoreBody", "ScoreConfig", + "ScoreConfigDataType", "ScoreConfigs", "ScoreDataType", "ScoreEvent", diff --git a/langfuse/api/reference.md b/langfuse/api/reference.md index b84696be4..9a8489735 100644 --- a/langfuse/api/reference.md +++ b/langfuse/api/reference.md @@ -3191,6 +3191,8 @@ JSON string containing the query parameters with the following structure: Get metrics from the Langfuse project using a query object. +Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance. + For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api). @@ -4007,7 +4009,9 @@ client.observations.get(
-Get a list of observations +Get a list of observations. + +Consider using the [v2 observations endpoint](/api-reference#tag/observationsv2/GET/api/public/v2/observations) for cursor-based pagination and field selection.
@@ -6666,7 +6670,7 @@ Create a score configuration (config). Score configs are used to define the stru
```python -from langfuse import CreateScoreConfigRequest, ScoreDataType +from langfuse import CreateScoreConfigRequest, ScoreConfigDataType from langfuse.client import FernLangfuse client = FernLangfuse( @@ -6680,7 +6684,7 @@ client = FernLangfuse( client.score_configs.create( request=CreateScoreConfigRequest( name="name", - data_type=ScoreDataType.NUMERIC, + data_type=ScoreConfigDataType.NUMERIC, ), ) diff --git a/langfuse/api/resources/__init__.py b/langfuse/api/resources/__init__.py index 1095119a7..55c4e012a 100644 --- a/langfuse/api/resources/__init__.py +++ b/langfuse/api/resources/__init__.py @@ -92,6 +92,7 @@ PricingTierOperator, Score, ScoreConfig, + ScoreConfigDataType, ScoreDataType, ScoreSource, ScoreV1, @@ -211,6 +212,7 @@ ApiKeyList, ApiKeyResponse, ApiKeySummary, + Organization, Project, ProjectDeletionResponse, Projects, @@ -412,6 +414,7 @@ "OpenAiResponseUsageSchema", "OpenAiUsage", "OptionalObservationBody", + "Organization", "OrganizationApiKey", "OrganizationApiKeysResponse", "OrganizationProject", @@ -462,6 +465,7 @@ "Score", "ScoreBody", "ScoreConfig", + "ScoreConfigDataType", "ScoreConfigs", "ScoreDataType", "ScoreEvent", diff --git a/langfuse/api/resources/commons/__init__.py b/langfuse/api/resources/commons/__init__.py index 77097ba49..9e522548e 100644 --- a/langfuse/api/resources/commons/__init__.py +++ b/langfuse/api/resources/commons/__init__.py @@ -32,6 +32,7 @@ PricingTierOperator, Score, ScoreConfig, + ScoreConfigDataType, ScoreDataType, ScoreSource, ScoreV1, @@ -92,6 +93,7 @@ "PricingTierOperator", "Score", "ScoreConfig", + "ScoreConfigDataType", "ScoreDataType", "ScoreSource", "ScoreV1", diff --git a/langfuse/api/resources/commons/types/__init__.py b/langfuse/api/resources/commons/types/__init__.py index ee7f5714b..b9063f3fb 100644 --- a/langfuse/api/resources/commons/types/__init__.py +++ b/langfuse/api/resources/commons/types/__init__.py @@ -31,6 +31,7 @@ from .pricing_tier_operator import PricingTierOperator from .score import Score, Score_Boolean, Score_Categorical, Score_Numeric 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_v_1 import ScoreV1, ScoreV1_Boolean, ScoreV1_Categorical, ScoreV1_Numeric @@ -73,6 +74,7 @@ "PricingTierOperator", "Score", "ScoreConfig", + "ScoreConfigDataType", "ScoreDataType", "ScoreSource", "ScoreV1", diff --git a/langfuse/api/resources/commons/types/score_config.py b/langfuse/api/resources/commons/types/score_config.py index 4a7b30e0e..2f7248143 100644 --- a/langfuse/api/resources/commons/types/score_config.py +++ b/langfuse/api/resources/commons/types/score_config.py @@ -6,7 +6,7 @@ from ....core.datetime_utils import serialize_datetime from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from .config_category import ConfigCategory -from .score_data_type import ScoreDataType +from .score_config_data_type import ScoreConfigDataType class ScoreConfig(pydantic_v1.BaseModel): @@ -19,7 +19,7 @@ class ScoreConfig(pydantic_v1.BaseModel): created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") project_id: str = pydantic_v1.Field(alias="projectId") - data_type: ScoreDataType = pydantic_v1.Field(alias="dataType") + data_type: ScoreConfigDataType = pydantic_v1.Field(alias="dataType") is_archived: bool = pydantic_v1.Field(alias="isArchived") """ Whether the score config is archived. Defaults to false diff --git a/langfuse/api/resources/commons/types/score_config_data_type.py b/langfuse/api/resources/commons/types/score_config_data_type.py new file mode 100644 index 000000000..a7c9e7251 --- /dev/null +++ b/langfuse/api/resources/commons/types/score_config_data_type.py @@ -0,0 +1,25 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class ScoreConfigDataType(str, enum.Enum): + NUMERIC = "NUMERIC" + BOOLEAN = "BOOLEAN" + CATEGORICAL = "CATEGORICAL" + + def visit( + self, + numeric: typing.Callable[[], T_Result], + boolean: typing.Callable[[], T_Result], + categorical: typing.Callable[[], T_Result], + ) -> T_Result: + if self is ScoreConfigDataType.NUMERIC: + return numeric() + if self is ScoreConfigDataType.BOOLEAN: + return boolean() + if self is ScoreConfigDataType.CATEGORICAL: + return categorical() diff --git a/langfuse/api/resources/commons/types/score_data_type.py b/langfuse/api/resources/commons/types/score_data_type.py index c2eed12cd..67bd9958b 100644 --- a/langfuse/api/resources/commons/types/score_data_type.py +++ b/langfuse/api/resources/commons/types/score_data_type.py @@ -10,12 +10,14 @@ class ScoreDataType(str, enum.Enum): NUMERIC = "NUMERIC" BOOLEAN = "BOOLEAN" CATEGORICAL = "CATEGORICAL" + CORRECTION = "CORRECTION" def visit( self, numeric: typing.Callable[[], T_Result], boolean: typing.Callable[[], T_Result], categorical: typing.Callable[[], T_Result], + correction: typing.Callable[[], T_Result], ) -> T_Result: if self is ScoreDataType.NUMERIC: return numeric() @@ -23,3 +25,5 @@ def visit( return boolean() if self is ScoreDataType.CATEGORICAL: return categorical() + if self is ScoreDataType.CORRECTION: + return correction() diff --git a/langfuse/api/resources/ingestion/types/score_body.py b/langfuse/api/resources/ingestion/types/score_body.py index 549046564..8e72a5682 100644 --- a/langfuse/api/resources/ingestion/types/score_body.py +++ b/langfuse/api/resources/ingestion/types/score_body.py @@ -33,7 +33,11 @@ class ScoreBody(pydantic_v1.BaseModel): dataset_run_id: typing.Optional[str] = pydantic_v1.Field( alias="datasetRunId", default=None ) - name: str + name: str = pydantic_v1.Field() + """ + The name of the score. Always overrides "output" for correction scores. + """ + environment: typing.Optional[str] = None queue_id: typing.Optional[str] = pydantic_v1.Field(alias="queueId", default=None) """ diff --git a/langfuse/api/resources/metrics/client.py b/langfuse/api/resources/metrics/client.py index 471f5182e..098c520c7 100644 --- a/langfuse/api/resources/metrics/client.py +++ b/langfuse/api/resources/metrics/client.py @@ -25,6 +25,8 @@ def metrics( """ Get metrics from the Langfuse project using a query object. + Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance. + For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api). Parameters @@ -138,6 +140,8 @@ async def metrics( """ Get metrics from the Langfuse project using a query object. + Consider using the [v2 metrics endpoint](/api-reference#tag/metricsv2/GET/api/public/v2/metrics) for better performance. + For more details, see the [Metrics API documentation](https://langfuse.com/docs/metrics/features/metrics-api). Parameters diff --git a/langfuse/api/resources/observations/client.py b/langfuse/api/resources/observations/client.py index cac4efe4d..77cdd4ee6 100644 --- a/langfuse/api/resources/observations/client.py +++ b/langfuse/api/resources/observations/client.py @@ -111,7 +111,9 @@ def get_many( request_options: typing.Optional[RequestOptions] = None, ) -> ObservationsViews: """ - Get a list of observations + Get a list of observations. + + Consider using the [v2 observations endpoint](/api-reference#tag/observationsv2/GET/api/public/v2/observations) for cursor-based pagination and field selection. Parameters ---------- @@ -412,7 +414,9 @@ async def get_many( request_options: typing.Optional[RequestOptions] = None, ) -> ObservationsViews: """ - Get a list of observations + Get a list of observations. + + Consider using the [v2 observations endpoint](/api-reference#tag/observationsv2/GET/api/public/v2/observations) for cursor-based pagination and field selection. Parameters ---------- diff --git a/langfuse/api/resources/projects/__init__.py b/langfuse/api/resources/projects/__init__.py index 26c74c1c7..7161cfff1 100644 --- a/langfuse/api/resources/projects/__init__.py +++ b/langfuse/api/resources/projects/__init__.py @@ -5,6 +5,7 @@ ApiKeyList, ApiKeyResponse, ApiKeySummary, + Organization, Project, ProjectDeletionResponse, Projects, @@ -15,6 +16,7 @@ "ApiKeyList", "ApiKeyResponse", "ApiKeySummary", + "Organization", "Project", "ProjectDeletionResponse", "Projects", diff --git a/langfuse/api/resources/projects/types/__init__.py b/langfuse/api/resources/projects/types/__init__.py index c59b62a62..6fd44aa52 100644 --- a/langfuse/api/resources/projects/types/__init__.py +++ b/langfuse/api/resources/projects/types/__init__.py @@ -4,6 +4,7 @@ from .api_key_list import ApiKeyList from .api_key_response import ApiKeyResponse from .api_key_summary import ApiKeySummary +from .organization import Organization from .project import Project from .project_deletion_response import ProjectDeletionResponse from .projects import Projects @@ -13,6 +14,7 @@ "ApiKeyList", "ApiKeyResponse", "ApiKeySummary", + "Organization", "Project", "ProjectDeletionResponse", "Projects", diff --git a/langfuse/api/resources/projects/types/organization.py b/langfuse/api/resources/projects/types/organization.py new file mode 100644 index 000000000..1a46b6f6c --- /dev/null +++ b/langfuse/api/resources/projects/types/organization.py @@ -0,0 +1,50 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class Organization(pydantic_v1.BaseModel): + id: str = pydantic_v1.Field() + """ + The unique identifier of the organization + """ + + name: str = pydantic_v1.Field() + """ + The name of the organization + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/langfuse/api/resources/projects/types/project.py b/langfuse/api/resources/projects/types/project.py index cf257d406..913dbb040 100644 --- a/langfuse/api/resources/projects/types/project.py +++ b/langfuse/api/resources/projects/types/project.py @@ -5,11 +5,17 @@ from ....core.datetime_utils import serialize_datetime from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .organization import Organization class Project(pydantic_v1.BaseModel): id: str name: str + organization: Organization = pydantic_v1.Field() + """ + The organization this project belongs to + """ + metadata: typing.Dict[str, typing.Any] = pydantic_v1.Field() """ Metadata for the project diff --git a/langfuse/api/resources/score_configs/client.py b/langfuse/api/resources/score_configs/client.py index 7faea8312..9ac68ccce 100644 --- a/langfuse/api/resources/score_configs/client.py +++ b/langfuse/api/resources/score_configs/client.py @@ -48,7 +48,7 @@ def create( Examples -------- - from langfuse import CreateScoreConfigRequest, ScoreDataType + from langfuse import CreateScoreConfigRequest, ScoreConfigDataType from langfuse.client import FernLangfuse client = FernLangfuse( @@ -62,7 +62,7 @@ def create( client.score_configs.create( request=CreateScoreConfigRequest( name="name", - data_type=ScoreDataType.NUMERIC, + data_type=ScoreConfigDataType.NUMERIC, ), ) """ @@ -339,7 +339,7 @@ async def create( -------- import asyncio - from langfuse import CreateScoreConfigRequest, ScoreDataType + from langfuse import CreateScoreConfigRequest, ScoreConfigDataType from langfuse.client import AsyncFernLangfuse client = AsyncFernLangfuse( @@ -356,7 +356,7 @@ async def main() -> None: await client.score_configs.create( request=CreateScoreConfigRequest( name="name", - data_type=ScoreDataType.NUMERIC, + data_type=ScoreConfigDataType.NUMERIC, ), ) diff --git a/langfuse/api/resources/score_configs/types/create_score_config_request.py b/langfuse/api/resources/score_configs/types/create_score_config_request.py index e136af157..eb5c5e325 100644 --- a/langfuse/api/resources/score_configs/types/create_score_config_request.py +++ b/langfuse/api/resources/score_configs/types/create_score_config_request.py @@ -6,12 +6,12 @@ from ....core.datetime_utils import serialize_datetime from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 from ...commons.types.config_category import ConfigCategory -from ...commons.types.score_data_type import ScoreDataType +from ...commons.types.score_config_data_type import ScoreConfigDataType class CreateScoreConfigRequest(pydantic_v1.BaseModel): name: str - data_type: ScoreDataType = pydantic_v1.Field(alias="dataType") + data_type: ScoreConfigDataType = pydantic_v1.Field(alias="dataType") categories: typing.Optional[typing.List[ConfigCategory]] = pydantic_v1.Field( default=None )