From bb2372a4dde104d0a044b39b1a8b52c1f659192d Mon Sep 17 00:00:00 2001 From: langfuse-bot Date: Wed, 14 Oct 2026 06:45:04 +0000 Subject: [PATCH] feat(api): update API spec from langfuse/langfuse 7cb2eed --- langfuse/api/__init__.py | 124 +------ langfuse/api/client.py | 19 -- langfuse/api/commons/__init__.py | 3 + langfuse/api/commons/types/__init__.py | 3 + .../types/open_ai_usage.py | 0 langfuse/api/ingestion/__init__.py | 160 --------- langfuse/api/ingestion/client.py | 246 -------------- langfuse/api/ingestion/raw_client.py | 318 ------------------ langfuse/api/ingestion/types/__init__.py | 160 --------- langfuse/api/ingestion/types/base_event.py | 27 -- .../api/ingestion/types/create_event_body.py | 14 - .../api/ingestion/types/create_event_event.py | 19 -- .../ingestion/types/create_generation_body.py | 40 --- .../types/create_generation_event.py | 19 -- .../types/create_observation_event.py | 19 -- .../api/ingestion/types/create_span_body.py | 19 -- .../api/ingestion/types/create_span_event.py | 19 -- .../api/ingestion/types/ingestion_error.py | 17 - .../api/ingestion/types/ingestion_event.py | 141 -------- .../api/ingestion/types/ingestion_response.py | 23 -- .../api/ingestion/types/ingestion_success.py | 15 - .../api/ingestion/types/ingestion_usage.py | 8 - .../api/ingestion/types/observation_body.py | 53 --- .../api/ingestion/types/observation_type.py | 54 --- .../types/open_ai_completion_usage_schema.py | 26 -- .../types/open_ai_response_usage_schema.py | 24 -- .../types/optional_observation_body.py | 36 -- langfuse/api/ingestion/types/score_event.py | 15 - langfuse/api/ingestion/types/trace_body.py | 36 -- langfuse/api/ingestion/types/trace_event.py | 19 -- .../api/ingestion/types/update_event_body.py | 14 - .../ingestion/types/update_generation_body.py | 40 --- .../types/update_generation_event.py | 19 -- .../types/update_observation_event.py | 19 -- .../api/ingestion/types/update_span_body.py | 19 -- .../api/ingestion/types/update_span_event.py | 19 -- langfuse/api/ingestion/types/usage_details.py | 10 - langfuse/api/scores/__init__.py | 3 + langfuse/api/scores/types/__init__.py | 3 + .../{ingestion => scores}/types/score_body.py | 2 +- 40 files changed, 17 insertions(+), 1807 deletions(-) rename langfuse/api/{ingestion => commons}/types/open_ai_usage.py (100%) delete mode 100644 langfuse/api/ingestion/__init__.py delete mode 100644 langfuse/api/ingestion/client.py delete mode 100644 langfuse/api/ingestion/raw_client.py delete mode 100644 langfuse/api/ingestion/types/__init__.py delete mode 100644 langfuse/api/ingestion/types/base_event.py delete mode 100644 langfuse/api/ingestion/types/create_event_body.py delete mode 100644 langfuse/api/ingestion/types/create_event_event.py delete mode 100644 langfuse/api/ingestion/types/create_generation_body.py delete mode 100644 langfuse/api/ingestion/types/create_generation_event.py delete mode 100644 langfuse/api/ingestion/types/create_observation_event.py delete mode 100644 langfuse/api/ingestion/types/create_span_body.py delete mode 100644 langfuse/api/ingestion/types/create_span_event.py delete mode 100644 langfuse/api/ingestion/types/ingestion_error.py delete mode 100644 langfuse/api/ingestion/types/ingestion_event.py delete mode 100644 langfuse/api/ingestion/types/ingestion_response.py delete mode 100644 langfuse/api/ingestion/types/ingestion_success.py delete mode 100644 langfuse/api/ingestion/types/ingestion_usage.py delete mode 100644 langfuse/api/ingestion/types/observation_body.py delete mode 100644 langfuse/api/ingestion/types/observation_type.py delete mode 100644 langfuse/api/ingestion/types/open_ai_completion_usage_schema.py delete mode 100644 langfuse/api/ingestion/types/open_ai_response_usage_schema.py delete mode 100644 langfuse/api/ingestion/types/optional_observation_body.py delete mode 100644 langfuse/api/ingestion/types/score_event.py delete mode 100644 langfuse/api/ingestion/types/trace_body.py delete mode 100644 langfuse/api/ingestion/types/trace_event.py delete mode 100644 langfuse/api/ingestion/types/update_event_body.py delete mode 100644 langfuse/api/ingestion/types/update_generation_body.py delete mode 100644 langfuse/api/ingestion/types/update_generation_event.py delete mode 100644 langfuse/api/ingestion/types/update_observation_event.py delete mode 100644 langfuse/api/ingestion/types/update_span_body.py delete mode 100644 langfuse/api/ingestion/types/update_span_event.py delete mode 100644 langfuse/api/ingestion/types/usage_details.py rename langfuse/api/{ingestion => scores}/types/score_body.py (98%) diff --git a/langfuse/api/__init__.py b/langfuse/api/__init__.py index 0952ed7d5..e4763032e 100644 --- a/langfuse/api/__init__.py +++ b/langfuse/api/__init__.py @@ -20,7 +20,6 @@ experiments, feedback, health, - ingestion, llm_connections, media, metrics, @@ -101,6 +100,7 @@ NumericScore, ObservationLevel, ObservationV2, + OpenAiUsage, PricingTier, PricingTierAttributeCondition, PricingTierAttributeSource, @@ -257,47 +257,6 @@ SubmitFeedbackResponse, ) from .health import HealthResponse, ServiceUnavailableError - from .ingestion import ( - BaseEvent, - CreateEventBody, - CreateEventEvent, - CreateGenerationBody, - CreateGenerationEvent, - CreateObservationEvent, - CreateSpanBody, - CreateSpanEvent, - IngestionError, - IngestionEvent, - IngestionEvent_EventCreate, - IngestionEvent_GenerationCreate, - IngestionEvent_GenerationUpdate, - IngestionEvent_ObservationCreate, - IngestionEvent_ObservationUpdate, - IngestionEvent_ScoreCreate, - IngestionEvent_SpanCreate, - IngestionEvent_SpanUpdate, - IngestionEvent_TraceCreate, - IngestionResponse, - IngestionSuccess, - IngestionUsage, - ObservationBody, - ObservationType, - OpenAiCompletionUsageSchema, - OpenAiResponseUsageSchema, - OpenAiUsage, - OptionalObservationBody, - ScoreBody, - ScoreEvent, - TraceBody, - TraceEvent, - UpdateEventBody, - UpdateGenerationBody, - UpdateGenerationEvent, - UpdateObservationEvent, - UpdateSpanBody, - UpdateSpanEvent, - UsageDetails, - ) from .llm_connections import ( DeleteLlmConnectionResponse, LlmAdapter, @@ -407,6 +366,7 @@ GetScoresV3Meta, GetScoresV3Response, NumericScoreV3, + ScoreBody, ScoreSubjectExperimentV3, ScoreSubjectObservationV3, ScoreSubjectSessionV3, @@ -440,7 +400,6 @@ "AsyncLangfuseAPI": ".client", "AuthenticationScheme": ".scim", "BadRequestError": ".evaluation_errors", - "BaseEvent": ".ingestion", "BasePrompt": ".prompts", "BaseScore": ".commons", "BaseScoreV3": ".scores", @@ -491,13 +450,8 @@ "CreateEvaluatorRequest": ".evaluators", "CreateEvaluatorRequest_Code": ".evaluators", "CreateEvaluatorRequest_LlmAsJudge": ".evaluators", - "CreateEventBody": ".ingestion", - "CreateEventEvent": ".ingestion", - "CreateGenerationBody": ".ingestion", - "CreateGenerationEvent": ".ingestion", "CreateLlmAsJudgeEvaluatorRequest": ".evaluators", "CreateModelRequest": ".models", - "CreateObservationEvent": ".ingestion", "CreatePromptRequest": ".prompts", "CreateScoreBatchError": ".scores", "CreateScoreBatchResponse": ".scores", @@ -508,8 +462,6 @@ "CreateScoreValue": ".commons", "CreateScoresRequest": ".scores", "CreateScoresResponse": ".scores", - "CreateSpanBody": ".ingestion", - "CreateSpanEvent": ".ingestion", "CreateTextPromptRequest": ".prompts", "CreateTextPromptType": ".prompts", "Creator": ".evaluators", @@ -600,20 +552,6 @@ "GetScoresV3Meta": ".scores", "GetScoresV3Response": ".scores", "HealthResponse": ".health", - "IngestionError": ".ingestion", - "IngestionEvent": ".ingestion", - "IngestionEvent_EventCreate": ".ingestion", - "IngestionEvent_GenerationCreate": ".ingestion", - "IngestionEvent_GenerationUpdate": ".ingestion", - "IngestionEvent_ObservationCreate": ".ingestion", - "IngestionEvent_ObservationUpdate": ".ingestion", - "IngestionEvent_ScoreCreate": ".ingestion", - "IngestionEvent_SpanCreate": ".ingestion", - "IngestionEvent_SpanUpdate": ".ingestion", - "IngestionEvent_TraceCreate": ".ingestion", - "IngestionResponse": ".ingestion", - "IngestionSuccess": ".ingestion", - "IngestionUsage": ".ingestion", "InternalServerError": ".evaluation_errors", "LangfuseAPI": ".client", "LegacyEvaluationObject": ".evaluation_commons", @@ -641,16 +579,11 @@ "NumberObjectEvaluationRuleFilter": ".evaluation_commons", "NumericScore": ".commons", "NumericScoreV3": ".scores", - "ObservationBody": ".ingestion", "ObservationLevel": ".commons", - "ObservationType": ".ingestion", "ObservationV2": ".commons", "ObservationsV2Meta": ".observations", "ObservationsV2Response": ".observations", - "OpenAiCompletionUsageSchema": ".ingestion", - "OpenAiResponseUsageSchema": ".ingestion", - "OpenAiUsage": ".ingestion", - "OptionalObservationBody": ".ingestion", + "OpenAiUsage": ".commons", "Organization": ".projects", "OrganizationApiKey": ".organizations", "OrganizationApiKeysResponse": ".organizations", @@ -719,12 +652,11 @@ "ScimUser": ".scim", "ScimUsersListResponse": ".scim", "Score": ".commons", - "ScoreBody": ".ingestion", + "ScoreBody": ".scores", "ScoreConfig": ".commons", "ScoreConfigDataType": ".commons", "ScoreConfigs": ".score_configs", "ScoreDataType": ".commons", - "ScoreEvent": ".ingestion", "ScoreSource": ".commons", "ScoreSubjectExperimentV3": ".scores", "ScoreSubjectObservationV3": ".scores", @@ -757,25 +689,16 @@ "TextScore": ".commons", "TextScoreV3": ".scores", "TooManyRequestsError": ".evaluation_errors", - "TraceBody": ".ingestion", - "TraceEvent": ".ingestion", "UnauthorizedError": ".commons", "UpdateAnnotationQueueItemRequest": ".annotation_queues", "UpdateCodeEvaluatorRequest": ".evaluators", "UpdateEvaluationRuleRequest": ".evaluation_rules", "UpdateEvaluatorMetadataRequest": ".evaluators", "UpdateEvaluatorRequest": ".evaluators", - "UpdateEventBody": ".ingestion", - "UpdateGenerationBody": ".ingestion", - "UpdateGenerationEvent": ".ingestion", "UpdateLlmAsJudgeEvaluatorRequest": ".evaluators", - "UpdateObservationEvent": ".ingestion", "UpdateScoreConfigRequest": ".score_configs", - "UpdateSpanBody": ".ingestion", - "UpdateSpanEvent": ".ingestion", "UpsertLlmConnectionRequest": ".llm_connections", "Usage": ".commons", - "UsageDetails": ".ingestion", "UserMeta": ".scim", "annotation_queues": ".annotation_queues", "blob_storage_integrations": ".blob_storage_integrations", @@ -790,7 +713,6 @@ "experiments": ".experiments", "feedback": ".feedback", "health": ".health", - "ingestion": ".ingestion", "llm_connections": ".llm_connections", "media": ".media", "metrics": ".metrics", @@ -852,7 +774,6 @@ def __dir__(): "AsyncLangfuseAPI", "AuthenticationScheme", "BadRequestError", - "BaseEvent", "BasePrompt", "BaseScore", "BaseScoreV3", @@ -903,13 +824,8 @@ def __dir__(): "CreateEvaluatorRequest", "CreateEvaluatorRequest_Code", "CreateEvaluatorRequest_LlmAsJudge", - "CreateEventBody", - "CreateEventEvent", - "CreateGenerationBody", - "CreateGenerationEvent", "CreateLlmAsJudgeEvaluatorRequest", "CreateModelRequest", - "CreateObservationEvent", "CreatePromptRequest", "CreateScoreBatchError", "CreateScoreBatchResponse", @@ -920,8 +836,6 @@ def __dir__(): "CreateScoreValue", "CreateScoresRequest", "CreateScoresResponse", - "CreateSpanBody", - "CreateSpanEvent", "CreateTextPromptRequest", "CreateTextPromptType", "Creator", @@ -1012,20 +926,6 @@ def __dir__(): "GetScoresV3Meta", "GetScoresV3Response", "HealthResponse", - "IngestionError", - "IngestionEvent", - "IngestionEvent_EventCreate", - "IngestionEvent_GenerationCreate", - "IngestionEvent_GenerationUpdate", - "IngestionEvent_ObservationCreate", - "IngestionEvent_ObservationUpdate", - "IngestionEvent_ScoreCreate", - "IngestionEvent_SpanCreate", - "IngestionEvent_SpanUpdate", - "IngestionEvent_TraceCreate", - "IngestionResponse", - "IngestionSuccess", - "IngestionUsage", "InternalServerError", "LangfuseAPI", "LegacyEvaluationObject", @@ -1053,16 +953,11 @@ def __dir__(): "NumberObjectEvaluationRuleFilter", "NumericScore", "NumericScoreV3", - "ObservationBody", "ObservationLevel", - "ObservationType", "ObservationV2", "ObservationsV2Meta", "ObservationsV2Response", - "OpenAiCompletionUsageSchema", - "OpenAiResponseUsageSchema", "OpenAiUsage", - "OptionalObservationBody", "Organization", "OrganizationApiKey", "OrganizationApiKeysResponse", @@ -1136,7 +1031,6 @@ def __dir__(): "ScoreConfigDataType", "ScoreConfigs", "ScoreDataType", - "ScoreEvent", "ScoreSource", "ScoreSubjectExperimentV3", "ScoreSubjectObservationV3", @@ -1169,25 +1063,16 @@ def __dir__(): "TextScore", "TextScoreV3", "TooManyRequestsError", - "TraceBody", - "TraceEvent", "UnauthorizedError", "UpdateAnnotationQueueItemRequest", "UpdateCodeEvaluatorRequest", "UpdateEvaluationRuleRequest", "UpdateEvaluatorMetadataRequest", "UpdateEvaluatorRequest", - "UpdateEventBody", - "UpdateGenerationBody", - "UpdateGenerationEvent", "UpdateLlmAsJudgeEvaluatorRequest", - "UpdateObservationEvent", "UpdateScoreConfigRequest", - "UpdateSpanBody", - "UpdateSpanEvent", "UpsertLlmConnectionRequest", "Usage", - "UsageDetails", "UserMeta", "annotation_queues", "blob_storage_integrations", @@ -1202,7 +1087,6 @@ def __dir__(): "experiments", "feedback", "health", - "ingestion", "llm_connections", "media", "metrics", diff --git a/langfuse/api/client.py b/langfuse/api/client.py index 30708f728..a6d960093 100644 --- a/langfuse/api/client.py +++ b/langfuse/api/client.py @@ -27,7 +27,6 @@ from .experiments.client import AsyncExperimentsClient, ExperimentsClient from .feedback.client import AsyncFeedbackClient, FeedbackClient from .health.client import AsyncHealthClient, HealthClient - from .ingestion.client import AsyncIngestionClient, IngestionClient from .llm_connections.client import AsyncLlmConnectionsClient, LlmConnectionsClient from .media.client import AsyncMediaClient, MediaClient from .metrics.client import AsyncMetricsClient, MetricsClient @@ -135,7 +134,6 @@ def __init__( self._experiments: typing.Optional[ExperimentsClient] = None self._feedback: typing.Optional[FeedbackClient] = None self._health: typing.Optional[HealthClient] = None - self._ingestion: typing.Optional[IngestionClient] = None self._llm_connections: typing.Optional[LlmConnectionsClient] = None self._media: typing.Optional[MediaClient] = None self._metrics: typing.Optional[MetricsClient] = None @@ -240,14 +238,6 @@ def health(self): self._health = HealthClient(client_wrapper=self._client_wrapper) return self._health - @property - def ingestion(self): - if self._ingestion is None: - from .ingestion.client import IngestionClient # noqa: E402 - - self._ingestion = IngestionClient(client_wrapper=self._client_wrapper) - return self._ingestion - @property def llm_connections(self): if self._llm_connections is None: @@ -469,7 +459,6 @@ def __init__( self._experiments: typing.Optional[AsyncExperimentsClient] = None self._feedback: typing.Optional[AsyncFeedbackClient] = None self._health: typing.Optional[AsyncHealthClient] = None - self._ingestion: typing.Optional[AsyncIngestionClient] = None self._llm_connections: typing.Optional[AsyncLlmConnectionsClient] = None self._media: typing.Optional[AsyncMediaClient] = None self._metrics: typing.Optional[AsyncMetricsClient] = None @@ -580,14 +569,6 @@ def health(self): self._health = AsyncHealthClient(client_wrapper=self._client_wrapper) return self._health - @property - def ingestion(self): - if self._ingestion is None: - from .ingestion.client import AsyncIngestionClient # noqa: E402 - - self._ingestion = AsyncIngestionClient(client_wrapper=self._client_wrapper) - return self._ingestion - @property def llm_connections(self): if self._llm_connections is None: diff --git a/langfuse/api/commons/__init__.py b/langfuse/api/commons/__init__.py index bf6de4b6e..dc0e9f1a4 100644 --- a/langfuse/api/commons/__init__.py +++ b/langfuse/api/commons/__init__.py @@ -29,6 +29,7 @@ NumericScore, ObservationLevel, ObservationV2, + OpenAiUsage, PricingTier, PricingTierAttributeCondition, PricingTierAttributeSource, @@ -85,6 +86,7 @@ "NumericScore": ".types", "ObservationLevel": ".types", "ObservationV2": ".types", + "OpenAiUsage": ".types", "PricingTier": ".types", "PricingTierAttributeCondition": ".types", "PricingTierAttributeSource": ".types", @@ -164,6 +166,7 @@ def __dir__(): "NumericScore", "ObservationLevel", "ObservationV2", + "OpenAiUsage", "PricingTier", "PricingTierAttributeCondition", "PricingTierAttributeSource", diff --git a/langfuse/api/commons/types/__init__.py b/langfuse/api/commons/types/__init__.py index 412219c03..2fbabb37e 100644 --- a/langfuse/api/commons/types/__init__.py +++ b/langfuse/api/commons/types/__init__.py @@ -28,6 +28,7 @@ from .numeric_score import NumericScore from .observation_level import ObservationLevel from .observation_v2 import ObservationV2 + from .open_ai_usage import OpenAiUsage from .pricing_tier import PricingTier from .pricing_tier_attribute_condition import PricingTierAttributeCondition from .pricing_tier_attribute_source import PricingTierAttributeSource @@ -74,6 +75,7 @@ "NumericScore": ".numeric_score", "ObservationLevel": ".observation_level", "ObservationV2": ".observation_v2", + "OpenAiUsage": ".open_ai_usage", "PricingTier": ".pricing_tier", "PricingTierAttributeCondition": ".pricing_tier_attribute_condition", "PricingTierAttributeSource": ".pricing_tier_attribute_source", @@ -148,6 +150,7 @@ def __dir__(): "NumericScore", "ObservationLevel", "ObservationV2", + "OpenAiUsage", "PricingTier", "PricingTierAttributeCondition", "PricingTierAttributeSource", diff --git a/langfuse/api/ingestion/types/open_ai_usage.py b/langfuse/api/commons/types/open_ai_usage.py similarity index 100% rename from langfuse/api/ingestion/types/open_ai_usage.py rename to langfuse/api/commons/types/open_ai_usage.py diff --git a/langfuse/api/ingestion/__init__.py b/langfuse/api/ingestion/__init__.py deleted file mode 100644 index 7a0d7c762..000000000 --- a/langfuse/api/ingestion/__init__.py +++ /dev/null @@ -1,160 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -# isort: skip_file - -import typing -from importlib import import_module - -if typing.TYPE_CHECKING: - from .types import ( - BaseEvent, - CreateEventBody, - CreateEventEvent, - CreateGenerationBody, - CreateGenerationEvent, - CreateObservationEvent, - CreateSpanBody, - CreateSpanEvent, - IngestionError, - IngestionEvent, - IngestionEvent_EventCreate, - IngestionEvent_GenerationCreate, - IngestionEvent_GenerationUpdate, - IngestionEvent_ObservationCreate, - IngestionEvent_ObservationUpdate, - IngestionEvent_ScoreCreate, - IngestionEvent_SpanCreate, - IngestionEvent_SpanUpdate, - IngestionEvent_TraceCreate, - IngestionResponse, - IngestionSuccess, - IngestionUsage, - ObservationBody, - ObservationType, - OpenAiCompletionUsageSchema, - OpenAiResponseUsageSchema, - OpenAiUsage, - OptionalObservationBody, - ScoreBody, - ScoreEvent, - TraceBody, - TraceEvent, - UpdateEventBody, - UpdateGenerationBody, - UpdateGenerationEvent, - UpdateObservationEvent, - UpdateSpanBody, - UpdateSpanEvent, - UsageDetails, - ) -_dynamic_imports: typing.Dict[str, str] = { - "BaseEvent": ".types", - "CreateEventBody": ".types", - "CreateEventEvent": ".types", - "CreateGenerationBody": ".types", - "CreateGenerationEvent": ".types", - "CreateObservationEvent": ".types", - "CreateSpanBody": ".types", - "CreateSpanEvent": ".types", - "IngestionError": ".types", - "IngestionEvent": ".types", - "IngestionEvent_EventCreate": ".types", - "IngestionEvent_GenerationCreate": ".types", - "IngestionEvent_GenerationUpdate": ".types", - "IngestionEvent_ObservationCreate": ".types", - "IngestionEvent_ObservationUpdate": ".types", - "IngestionEvent_ScoreCreate": ".types", - "IngestionEvent_SpanCreate": ".types", - "IngestionEvent_SpanUpdate": ".types", - "IngestionEvent_TraceCreate": ".types", - "IngestionResponse": ".types", - "IngestionSuccess": ".types", - "IngestionUsage": ".types", - "ObservationBody": ".types", - "ObservationType": ".types", - "OpenAiCompletionUsageSchema": ".types", - "OpenAiResponseUsageSchema": ".types", - "OpenAiUsage": ".types", - "OptionalObservationBody": ".types", - "ScoreBody": ".types", - "ScoreEvent": ".types", - "TraceBody": ".types", - "TraceEvent": ".types", - "UpdateEventBody": ".types", - "UpdateGenerationBody": ".types", - "UpdateGenerationEvent": ".types", - "UpdateObservationEvent": ".types", - "UpdateSpanBody": ".types", - "UpdateSpanEvent": ".types", - "UsageDetails": ".types", -} - - -def __getattr__(attr_name: str) -> typing.Any: - module_name = _dynamic_imports.get(attr_name) - if module_name is None: - raise AttributeError( - f"No {attr_name} found in _dynamic_imports for module name -> {__name__}" - ) - try: - module = import_module(module_name, __package__) - if module_name == f".{attr_name}": - return module - else: - return getattr(module, attr_name) - except ImportError as e: - raise ImportError( - f"Failed to import {attr_name} from {module_name}: {e}" - ) from e - except AttributeError as e: - raise AttributeError( - f"Failed to get {attr_name} from {module_name}: {e}" - ) from e - - -def __dir__(): - lazy_attrs = list(_dynamic_imports.keys()) - return sorted(lazy_attrs) - - -__all__ = [ - "BaseEvent", - "CreateEventBody", - "CreateEventEvent", - "CreateGenerationBody", - "CreateGenerationEvent", - "CreateObservationEvent", - "CreateSpanBody", - "CreateSpanEvent", - "IngestionError", - "IngestionEvent", - "IngestionEvent_EventCreate", - "IngestionEvent_GenerationCreate", - "IngestionEvent_GenerationUpdate", - "IngestionEvent_ObservationCreate", - "IngestionEvent_ObservationUpdate", - "IngestionEvent_ScoreCreate", - "IngestionEvent_SpanCreate", - "IngestionEvent_SpanUpdate", - "IngestionEvent_TraceCreate", - "IngestionResponse", - "IngestionSuccess", - "IngestionUsage", - "ObservationBody", - "ObservationType", - "OpenAiCompletionUsageSchema", - "OpenAiResponseUsageSchema", - "OpenAiUsage", - "OptionalObservationBody", - "ScoreBody", - "ScoreEvent", - "TraceBody", - "TraceEvent", - "UpdateEventBody", - "UpdateGenerationBody", - "UpdateGenerationEvent", - "UpdateObservationEvent", - "UpdateSpanBody", - "UpdateSpanEvent", - "UsageDetails", -] diff --git a/langfuse/api/ingestion/client.py b/langfuse/api/ingestion/client.py deleted file mode 100644 index 4e78c2e2a..000000000 --- a/langfuse/api/ingestion/client.py +++ /dev/null @@ -1,246 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import typing_extensions -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.request_options import RequestOptions -from .raw_client import AsyncRawIngestionClient, RawIngestionClient -from .types.ingestion_event import IngestionEvent -from .types.ingestion_response import IngestionResponse - -# this is used as the default value for optional parameters -OMIT = typing.cast(typing.Any, ...) - - -class IngestionClient: - def __init__(self, *, client_wrapper: SyncClientWrapper): - self._raw_client = RawIngestionClient(client_wrapper=client_wrapper) - - @property - def with_raw_response(self) -> RawIngestionClient: - """ - Retrieves a raw implementation of this client that returns raw responses. - - Returns - ------- - RawIngestionClient - """ - return self._raw_client - - @typing_extensions.deprecated( - "On Langfuse Cloud, this is the deprecated Langfuse v3 ingestion API and it is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs; if you use custom auto-instrumentation, send them to the OpenTelemetry endpoint at `POST /api/public/otel/v1/traces` (for example with curl); see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`; all other public APIs may have data delays of several minutes. Self-hosted deployments are unaffected by the November 16 date; this behavior begins only when they enable v4-only write mode.", - category=None, - ) - def batch( - self, - *, - batch: typing.Sequence[IngestionEvent], - metadata: typing.Optional[typing.Any] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> IngestionResponse: - """ - **Legacy endpoint for batch ingestion for Langfuse Observability.** - - This is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types. - - To write scores, prefer `POST /api/public/scores`: https://langfuse.com/docs/api-and-data-platform/features/scores-api - - To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl: https://langfuse.com/integrations/native/opentelemetry - - To read data back, use the v4 read APIs: https://langfuse.com/docs/api-and-data-platform/features/observations-api and https://langfuse.com/docs/metrics/features/metrics-api - - The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - - Within each batch, there can be multiple events. - Each event has a type, an id, a timestamp, metadata and a body. - Internally, we refer to this as the "event envelope" as it tells us something about the event but not the trace. - We use the event id within this envelope to deduplicate messages to avoid processing the same event twice, i.e. the event id should be unique per request. - The event.body.id is the ID of the actual trace and will be used for updates and will be visible within the Langfuse App. - I.e. if you want to update a trace, you'd use the same body id, but separate event IDs. - - Notes: - - Introduction to data model: https://langfuse.com/docs/observability/data-model - - Batch sizes are limited to 3.5 MB in total. You need to adjust the number of events per batch accordingly. - - The API does not return a 4xx status code for input errors. Instead, it responds with a 207 status code, which includes a list of the encountered errors. - - Parameters - ---------- - batch : typing.Sequence[IngestionEvent] - Batch of events to be ingested, discriminated by attribute `type`. From November 16, 2026 on Langfuse Cloud, only `score-create` events are accepted; all other event types are rejected. - - metadata : typing.Optional[typing.Any] - Optional. Metadata field used by the Langfuse SDKs for debugging. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - IngestionResponse - - Examples - -------- - import datetime - - from langfuse import LangfuseAPI - from langfuse.ingestion import IngestionEvent_TraceCreate, TraceBody - - client = LangfuseAPI( - x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", - x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", - x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", - username="YOUR_USERNAME", - password="YOUR_PASSWORD", - base_url="https://yourhost.com/path/to/api", - ) - client.ingestion.batch( - batch=[ - IngestionEvent_TraceCreate( - id="abcdef-1234-5678-90ab", - timestamp="2022-01-01T00:00:00.000Z", - body=TraceBody( - id="abcdef-1234-5678-90ab", - timestamp=datetime.datetime.fromisoformat( - "2022-01-01 00:00:00+00:00", - ), - environment="production", - name="My Trace", - user_id="1234-5678-90ab-cdef", - input="My input", - output="My output", - session_id="1234-5678-90ab-cdef", - release="1.0.0", - version="1.0.0", - metadata="My metadata", - tags=["tag1", "tag2"], - public=True, - ), - ) - ], - ) - """ - _response = self._raw_client.batch( - batch=batch, metadata=metadata, request_options=request_options - ) - return _response.data - - -class AsyncIngestionClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._raw_client = AsyncRawIngestionClient(client_wrapper=client_wrapper) - - @property - def with_raw_response(self) -> AsyncRawIngestionClient: - """ - Retrieves a raw implementation of this client that returns raw responses. - - Returns - ------- - AsyncRawIngestionClient - """ - return self._raw_client - - @typing_extensions.deprecated( - "On Langfuse Cloud, this is the deprecated Langfuse v3 ingestion API and it is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs; if you use custom auto-instrumentation, send them to the OpenTelemetry endpoint at `POST /api/public/otel/v1/traces` (for example with curl); see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`; all other public APIs may have data delays of several minutes. Self-hosted deployments are unaffected by the November 16 date; this behavior begins only when they enable v4-only write mode.", - category=None, - ) - async def batch( - self, - *, - batch: typing.Sequence[IngestionEvent], - metadata: typing.Optional[typing.Any] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> IngestionResponse: - """ - **Legacy endpoint for batch ingestion for Langfuse Observability.** - - This is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types. - - To write scores, prefer `POST /api/public/scores`: https://langfuse.com/docs/api-and-data-platform/features/scores-api - - To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl: https://langfuse.com/integrations/native/opentelemetry - - To read data back, use the v4 read APIs: https://langfuse.com/docs/api-and-data-platform/features/observations-api and https://langfuse.com/docs/metrics/features/metrics-api - - The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - - Within each batch, there can be multiple events. - Each event has a type, an id, a timestamp, metadata and a body. - Internally, we refer to this as the "event envelope" as it tells us something about the event but not the trace. - We use the event id within this envelope to deduplicate messages to avoid processing the same event twice, i.e. the event id should be unique per request. - The event.body.id is the ID of the actual trace and will be used for updates and will be visible within the Langfuse App. - I.e. if you want to update a trace, you'd use the same body id, but separate event IDs. - - Notes: - - Introduction to data model: https://langfuse.com/docs/observability/data-model - - Batch sizes are limited to 3.5 MB in total. You need to adjust the number of events per batch accordingly. - - The API does not return a 4xx status code for input errors. Instead, it responds with a 207 status code, which includes a list of the encountered errors. - - Parameters - ---------- - batch : typing.Sequence[IngestionEvent] - Batch of events to be ingested, discriminated by attribute `type`. From November 16, 2026 on Langfuse Cloud, only `score-create` events are accepted; all other event types are rejected. - - metadata : typing.Optional[typing.Any] - Optional. Metadata field used by the Langfuse SDKs for debugging. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - IngestionResponse - - Examples - -------- - import asyncio - import datetime - - from langfuse import AsyncLangfuseAPI - from langfuse.ingestion import IngestionEvent_TraceCreate, TraceBody - - client = AsyncLangfuseAPI( - x_langfuse_sdk_name="YOUR_X_LANGFUSE_SDK_NAME", - x_langfuse_sdk_version="YOUR_X_LANGFUSE_SDK_VERSION", - x_langfuse_public_key="YOUR_X_LANGFUSE_PUBLIC_KEY", - username="YOUR_USERNAME", - password="YOUR_PASSWORD", - base_url="https://yourhost.com/path/to/api", - ) - - - async def main() -> None: - await client.ingestion.batch( - batch=[ - IngestionEvent_TraceCreate( - id="abcdef-1234-5678-90ab", - timestamp="2022-01-01T00:00:00.000Z", - body=TraceBody( - id="abcdef-1234-5678-90ab", - timestamp=datetime.datetime.fromisoformat( - "2022-01-01 00:00:00+00:00", - ), - environment="production", - name="My Trace", - user_id="1234-5678-90ab-cdef", - input="My input", - output="My output", - session_id="1234-5678-90ab-cdef", - release="1.0.0", - version="1.0.0", - metadata="My metadata", - tags=["tag1", "tag2"], - public=True, - ), - ) - ], - ) - - - asyncio.run(main()) - """ - _response = await self._raw_client.batch( - batch=batch, metadata=metadata, request_options=request_options - ) - return _response.data diff --git a/langfuse/api/ingestion/raw_client.py b/langfuse/api/ingestion/raw_client.py deleted file mode 100644 index 95b01adb3..000000000 --- a/langfuse/api/ingestion/raw_client.py +++ /dev/null @@ -1,318 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing -import typing_extensions -from json.decoder import JSONDecodeError - -from ..commons.errors.access_denied_error import AccessDeniedError -from ..commons.errors.error import Error -from ..commons.errors.method_not_allowed_error import MethodNotAllowedError -from ..commons.errors.not_found_error import NotFoundError -from ..commons.errors.unauthorized_error import UnauthorizedError -from ..core.api_error import ApiError -from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper -from ..core.http_response import AsyncHttpResponse, HttpResponse -from ..core.pydantic_utilities import parse_obj_as -from ..core.request_options import RequestOptions -from ..core.serialization import convert_and_respect_annotation_metadata -from .types.ingestion_event import IngestionEvent -from .types.ingestion_response import IngestionResponse - -# this is used as the default value for optional parameters -OMIT = typing.cast(typing.Any, ...) - - -class RawIngestionClient: - def __init__(self, *, client_wrapper: SyncClientWrapper): - self._client_wrapper = client_wrapper - - @typing_extensions.deprecated( - "On Langfuse Cloud, this is the deprecated Langfuse v3 ingestion API and it is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs; if you use custom auto-instrumentation, send them to the OpenTelemetry endpoint at `POST /api/public/otel/v1/traces` (for example with curl); see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`; all other public APIs may have data delays of several minutes. Self-hosted deployments are unaffected by the November 16 date; this behavior begins only when they enable v4-only write mode.", - category=None, - ) - def batch( - self, - *, - batch: typing.Sequence[IngestionEvent], - metadata: typing.Optional[typing.Any] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> HttpResponse[IngestionResponse]: - """ - **Legacy endpoint for batch ingestion for Langfuse Observability.** - - This is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types. - - To write scores, prefer `POST /api/public/scores`: https://langfuse.com/docs/api-and-data-platform/features/scores-api - - To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl: https://langfuse.com/integrations/native/opentelemetry - - To read data back, use the v4 read APIs: https://langfuse.com/docs/api-and-data-platform/features/observations-api and https://langfuse.com/docs/metrics/features/metrics-api - - The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - - Within each batch, there can be multiple events. - Each event has a type, an id, a timestamp, metadata and a body. - Internally, we refer to this as the "event envelope" as it tells us something about the event but not the trace. - We use the event id within this envelope to deduplicate messages to avoid processing the same event twice, i.e. the event id should be unique per request. - The event.body.id is the ID of the actual trace and will be used for updates and will be visible within the Langfuse App. - I.e. if you want to update a trace, you'd use the same body id, but separate event IDs. - - Notes: - - Introduction to data model: https://langfuse.com/docs/observability/data-model - - Batch sizes are limited to 3.5 MB in total. You need to adjust the number of events per batch accordingly. - - The API does not return a 4xx status code for input errors. Instead, it responds with a 207 status code, which includes a list of the encountered errors. - - Parameters - ---------- - batch : typing.Sequence[IngestionEvent] - Batch of events to be ingested, discriminated by attribute `type`. From November 16, 2026 on Langfuse Cloud, only `score-create` events are accepted; all other event types are rejected. - - metadata : typing.Optional[typing.Any] - Optional. Metadata field used by the Langfuse SDKs for debugging. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - HttpResponse[IngestionResponse] - """ - _response = self._client_wrapper.httpx_client.request( - "api/public/ingestion", - method="POST", - json={ - "batch": convert_and_respect_annotation_metadata( - object_=batch, - annotation=typing.Sequence[IngestionEvent], - direction="write", - ), - "metadata": metadata, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - IngestionResponse, - parse_obj_as( - type_=IngestionResponse, # type: ignore - object_=_response.json(), - ), - ) - return HttpResponse(response=_response, data=_data) - if _response.status_code == 400: - raise Error( - headers=dict(_response.headers), - body=typing.cast( - typing.Any, - parse_obj_as( - type_=typing.Any, # type: ignore - object_=_response.json(), - ), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - headers=dict(_response.headers), - body=typing.cast( - typing.Any, - parse_obj_as( - type_=typing.Any, # type: ignore - object_=_response.json(), - ), - ), - ) - if _response.status_code == 403: - raise AccessDeniedError( - headers=dict(_response.headers), - body=typing.cast( - typing.Any, - parse_obj_as( - type_=typing.Any, # type: ignore - object_=_response.json(), - ), - ), - ) - if _response.status_code == 405: - raise MethodNotAllowedError( - headers=dict(_response.headers), - body=typing.cast( - typing.Any, - parse_obj_as( - type_=typing.Any, # type: ignore - object_=_response.json(), - ), - ), - ) - if _response.status_code == 404: - raise NotFoundError( - headers=dict(_response.headers), - body=typing.cast( - typing.Any, - parse_obj_as( - type_=typing.Any, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError( - status_code=_response.status_code, - headers=dict(_response.headers), - body=_response.text, - ) - raise ApiError( - status_code=_response.status_code, - headers=dict(_response.headers), - body=_response_json, - ) - - -class AsyncRawIngestionClient: - def __init__(self, *, client_wrapper: AsyncClientWrapper): - self._client_wrapper = client_wrapper - - @typing_extensions.deprecated( - "On Langfuse Cloud, this is the deprecated Langfuse v3 ingestion API and it is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs; if you use custom auto-instrumentation, send them to the OpenTelemetry endpoint at `POST /api/public/otel/v1/traces` (for example with curl); see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`; all other public APIs may have data delays of several minutes. Self-hosted deployments are unaffected by the November 16 date; this behavior begins only when they enable v4-only write mode.", - category=None, - ) - async def batch( - self, - *, - batch: typing.Sequence[IngestionEvent], - metadata: typing.Optional[typing.Any] = OMIT, - request_options: typing.Optional[RequestOptions] = None, - ) -> AsyncHttpResponse[IngestionResponse]: - """ - **Legacy endpoint for batch ingestion for Langfuse Observability.** - - This is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types. - - To write scores, prefer `POST /api/public/scores`: https://langfuse.com/docs/api-and-data-platform/features/scores-api - - To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl: https://langfuse.com/integrations/native/opentelemetry - - To read data back, use the v4 read APIs: https://langfuse.com/docs/api-and-data-platform/features/observations-api and https://langfuse.com/docs/metrics/features/metrics-api - - The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - - Within each batch, there can be multiple events. - Each event has a type, an id, a timestamp, metadata and a body. - Internally, we refer to this as the "event envelope" as it tells us something about the event but not the trace. - We use the event id within this envelope to deduplicate messages to avoid processing the same event twice, i.e. the event id should be unique per request. - The event.body.id is the ID of the actual trace and will be used for updates and will be visible within the Langfuse App. - I.e. if you want to update a trace, you'd use the same body id, but separate event IDs. - - Notes: - - Introduction to data model: https://langfuse.com/docs/observability/data-model - - Batch sizes are limited to 3.5 MB in total. You need to adjust the number of events per batch accordingly. - - The API does not return a 4xx status code for input errors. Instead, it responds with a 207 status code, which includes a list of the encountered errors. - - Parameters - ---------- - batch : typing.Sequence[IngestionEvent] - Batch of events to be ingested, discriminated by attribute `type`. From November 16, 2026 on Langfuse Cloud, only `score-create` events are accepted; all other event types are rejected. - - metadata : typing.Optional[typing.Any] - Optional. Metadata field used by the Langfuse SDKs for debugging. - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - AsyncHttpResponse[IngestionResponse] - """ - _response = await self._client_wrapper.httpx_client.request( - "api/public/ingestion", - method="POST", - json={ - "batch": convert_and_respect_annotation_metadata( - object_=batch, - annotation=typing.Sequence[IngestionEvent], - direction="write", - ), - "metadata": metadata, - }, - request_options=request_options, - omit=OMIT, - ) - try: - if 200 <= _response.status_code < 300: - _data = typing.cast( - IngestionResponse, - parse_obj_as( - type_=IngestionResponse, # type: ignore - object_=_response.json(), - ), - ) - return AsyncHttpResponse(response=_response, data=_data) - if _response.status_code == 400: - raise Error( - headers=dict(_response.headers), - body=typing.cast( - typing.Any, - parse_obj_as( - type_=typing.Any, # type: ignore - object_=_response.json(), - ), - ), - ) - if _response.status_code == 401: - raise UnauthorizedError( - headers=dict(_response.headers), - body=typing.cast( - typing.Any, - parse_obj_as( - type_=typing.Any, # type: ignore - object_=_response.json(), - ), - ), - ) - if _response.status_code == 403: - raise AccessDeniedError( - headers=dict(_response.headers), - body=typing.cast( - typing.Any, - parse_obj_as( - type_=typing.Any, # type: ignore - object_=_response.json(), - ), - ), - ) - if _response.status_code == 405: - raise MethodNotAllowedError( - headers=dict(_response.headers), - body=typing.cast( - typing.Any, - parse_obj_as( - type_=typing.Any, # type: ignore - object_=_response.json(), - ), - ), - ) - if _response.status_code == 404: - raise NotFoundError( - headers=dict(_response.headers), - body=typing.cast( - typing.Any, - parse_obj_as( - type_=typing.Any, # type: ignore - object_=_response.json(), - ), - ), - ) - _response_json = _response.json() - except JSONDecodeError: - raise ApiError( - status_code=_response.status_code, - headers=dict(_response.headers), - body=_response.text, - ) - raise ApiError( - status_code=_response.status_code, - headers=dict(_response.headers), - body=_response_json, - ) diff --git a/langfuse/api/ingestion/types/__init__.py b/langfuse/api/ingestion/types/__init__.py deleted file mode 100644 index 4fd3b0e7e..000000000 --- a/langfuse/api/ingestion/types/__init__.py +++ /dev/null @@ -1,160 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -# isort: skip_file - -import typing -from importlib import import_module - -if typing.TYPE_CHECKING: - from .base_event import BaseEvent - from .create_event_body import CreateEventBody - from .create_event_event import CreateEventEvent - from .create_generation_body import CreateGenerationBody - from .create_generation_event import CreateGenerationEvent - from .create_observation_event import CreateObservationEvent - from .create_span_body import CreateSpanBody - from .create_span_event import CreateSpanEvent - from .ingestion_error import IngestionError - from .ingestion_event import ( - IngestionEvent, - IngestionEvent_EventCreate, - IngestionEvent_GenerationCreate, - IngestionEvent_GenerationUpdate, - IngestionEvent_ObservationCreate, - IngestionEvent_ObservationUpdate, - IngestionEvent_ScoreCreate, - IngestionEvent_SpanCreate, - IngestionEvent_SpanUpdate, - IngestionEvent_TraceCreate, - ) - from .ingestion_response import IngestionResponse - from .ingestion_success import IngestionSuccess - from .ingestion_usage import IngestionUsage - from .observation_body import ObservationBody - from .observation_type import ObservationType - from .open_ai_completion_usage_schema import OpenAiCompletionUsageSchema - from .open_ai_response_usage_schema import OpenAiResponseUsageSchema - from .open_ai_usage import OpenAiUsage - from .optional_observation_body import OptionalObservationBody - from .score_body import ScoreBody - from .score_event import ScoreEvent - from .trace_body import TraceBody - from .trace_event import TraceEvent - from .update_event_body import UpdateEventBody - from .update_generation_body import UpdateGenerationBody - from .update_generation_event import UpdateGenerationEvent - from .update_observation_event import UpdateObservationEvent - from .update_span_body import UpdateSpanBody - from .update_span_event import UpdateSpanEvent - from .usage_details import UsageDetails -_dynamic_imports: typing.Dict[str, str] = { - "BaseEvent": ".base_event", - "CreateEventBody": ".create_event_body", - "CreateEventEvent": ".create_event_event", - "CreateGenerationBody": ".create_generation_body", - "CreateGenerationEvent": ".create_generation_event", - "CreateObservationEvent": ".create_observation_event", - "CreateSpanBody": ".create_span_body", - "CreateSpanEvent": ".create_span_event", - "IngestionError": ".ingestion_error", - "IngestionEvent": ".ingestion_event", - "IngestionEvent_EventCreate": ".ingestion_event", - "IngestionEvent_GenerationCreate": ".ingestion_event", - "IngestionEvent_GenerationUpdate": ".ingestion_event", - "IngestionEvent_ObservationCreate": ".ingestion_event", - "IngestionEvent_ObservationUpdate": ".ingestion_event", - "IngestionEvent_ScoreCreate": ".ingestion_event", - "IngestionEvent_SpanCreate": ".ingestion_event", - "IngestionEvent_SpanUpdate": ".ingestion_event", - "IngestionEvent_TraceCreate": ".ingestion_event", - "IngestionResponse": ".ingestion_response", - "IngestionSuccess": ".ingestion_success", - "IngestionUsage": ".ingestion_usage", - "ObservationBody": ".observation_body", - "ObservationType": ".observation_type", - "OpenAiCompletionUsageSchema": ".open_ai_completion_usage_schema", - "OpenAiResponseUsageSchema": ".open_ai_response_usage_schema", - "OpenAiUsage": ".open_ai_usage", - "OptionalObservationBody": ".optional_observation_body", - "ScoreBody": ".score_body", - "ScoreEvent": ".score_event", - "TraceBody": ".trace_body", - "TraceEvent": ".trace_event", - "UpdateEventBody": ".update_event_body", - "UpdateGenerationBody": ".update_generation_body", - "UpdateGenerationEvent": ".update_generation_event", - "UpdateObservationEvent": ".update_observation_event", - "UpdateSpanBody": ".update_span_body", - "UpdateSpanEvent": ".update_span_event", - "UsageDetails": ".usage_details", -} - - -def __getattr__(attr_name: str) -> typing.Any: - module_name = _dynamic_imports.get(attr_name) - if module_name is None: - raise AttributeError( - f"No {attr_name} found in _dynamic_imports for module name -> {__name__}" - ) - try: - module = import_module(module_name, __package__) - if module_name == f".{attr_name}": - return module - else: - return getattr(module, attr_name) - except ImportError as e: - raise ImportError( - f"Failed to import {attr_name} from {module_name}: {e}" - ) from e - except AttributeError as e: - raise AttributeError( - f"Failed to get {attr_name} from {module_name}: {e}" - ) from e - - -def __dir__(): - lazy_attrs = list(_dynamic_imports.keys()) - return sorted(lazy_attrs) - - -__all__ = [ - "BaseEvent", - "CreateEventBody", - "CreateEventEvent", - "CreateGenerationBody", - "CreateGenerationEvent", - "CreateObservationEvent", - "CreateSpanBody", - "CreateSpanEvent", - "IngestionError", - "IngestionEvent", - "IngestionEvent_EventCreate", - "IngestionEvent_GenerationCreate", - "IngestionEvent_GenerationUpdate", - "IngestionEvent_ObservationCreate", - "IngestionEvent_ObservationUpdate", - "IngestionEvent_ScoreCreate", - "IngestionEvent_SpanCreate", - "IngestionEvent_SpanUpdate", - "IngestionEvent_TraceCreate", - "IngestionResponse", - "IngestionSuccess", - "IngestionUsage", - "ObservationBody", - "ObservationType", - "OpenAiCompletionUsageSchema", - "OpenAiResponseUsageSchema", - "OpenAiUsage", - "OptionalObservationBody", - "ScoreBody", - "ScoreEvent", - "TraceBody", - "TraceEvent", - "UpdateEventBody", - "UpdateGenerationBody", - "UpdateGenerationEvent", - "UpdateObservationEvent", - "UpdateSpanBody", - "UpdateSpanEvent", - "UsageDetails", -] diff --git a/langfuse/api/ingestion/types/base_event.py b/langfuse/api/ingestion/types/base_event.py deleted file mode 100644 index 70c6bcfa4..000000000 --- a/langfuse/api/ingestion/types/base_event.py +++ /dev/null @@ -1,27 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ...core.pydantic_utilities import UniversalBaseModel - - -class BaseEvent(UniversalBaseModel): - id: str = pydantic.Field() - """ - UUID v4 that identifies the event - """ - - timestamp: str = pydantic.Field() - """ - Datetime (ISO 8601) of event creation in client. Should be as close to actual event creation in client as possible, this timestamp will be used for ordering of events in future release. Resolution: milliseconds (required), microseconds (optimal). - """ - - metadata: typing.Optional[typing.Any] = pydantic.Field(default=None) - """ - Optional. Metadata field used by the Langfuse SDKs for debugging. - """ - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/create_event_body.py b/langfuse/api/ingestion/types/create_event_body.py deleted file mode 100644 index 0473d8a0d..000000000 --- a/langfuse/api/ingestion/types/create_event_body.py +++ /dev/null @@ -1,14 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .optional_observation_body import OptionalObservationBody - - -class CreateEventBody(OptionalObservationBody): - id: typing.Optional[str] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/create_event_event.py b/langfuse/api/ingestion/types/create_event_event.py deleted file mode 100644 index a0b80a166..000000000 --- a/langfuse/api/ingestion/types/create_event_event.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .base_event import BaseEvent -from .create_event_body import CreateEventBody - - -class CreateEventEvent(BaseEvent): - """ - Sunset warning: this is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types, including this one. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl; see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - """ - - body: CreateEventBody - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/create_generation_body.py b/langfuse/api/ingestion/types/create_generation_body.py deleted file mode 100644 index 72cb57116..000000000 --- a/langfuse/api/ingestion/types/create_generation_body.py +++ /dev/null @@ -1,40 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -import typing_extensions -from ...commons.types.map_value import MapValue -from ...core.serialization import FieldMetadata -from .create_span_body import CreateSpanBody -from .ingestion_usage import IngestionUsage -from .usage_details import UsageDetails - - -class CreateGenerationBody(CreateSpanBody): - completion_start_time: typing_extensions.Annotated[ - typing.Optional[dt.datetime], FieldMetadata(alias="completionStartTime") - ] = None - model: typing.Optional[str] = None - model_parameters: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, MapValue]], - FieldMetadata(alias="modelParameters"), - ] = None - usage: typing.Optional[IngestionUsage] = None - usage_details: typing_extensions.Annotated[ - typing.Optional[UsageDetails], FieldMetadata(alias="usageDetails") - ] = None - cost_details: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, float]], FieldMetadata(alias="costDetails") - ] = None - prompt_name: typing_extensions.Annotated[ - typing.Optional[str], FieldMetadata(alias="promptName") - ] = None - prompt_version: typing_extensions.Annotated[ - typing.Optional[int], FieldMetadata(alias="promptVersion") - ] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/create_generation_event.py b/langfuse/api/ingestion/types/create_generation_event.py deleted file mode 100644 index 9ee974a10..000000000 --- a/langfuse/api/ingestion/types/create_generation_event.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .base_event import BaseEvent -from .create_generation_body import CreateGenerationBody - - -class CreateGenerationEvent(BaseEvent): - """ - Sunset warning: this is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types, including this one. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl; see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - """ - - body: CreateGenerationBody - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/create_observation_event.py b/langfuse/api/ingestion/types/create_observation_event.py deleted file mode 100644 index 68f0c73f1..000000000 --- a/langfuse/api/ingestion/types/create_observation_event.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .base_event import BaseEvent -from .observation_body import ObservationBody - - -class CreateObservationEvent(BaseEvent): - """ - Sunset warning: this is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types, including this one. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl; see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - """ - - body: ObservationBody - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/create_span_body.py b/langfuse/api/ingestion/types/create_span_body.py deleted file mode 100644 index 7a47d9748..000000000 --- a/langfuse/api/ingestion/types/create_span_body.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -import typing_extensions -from ...core.serialization import FieldMetadata -from .create_event_body import CreateEventBody - - -class CreateSpanBody(CreateEventBody): - end_time: typing_extensions.Annotated[ - typing.Optional[dt.datetime], FieldMetadata(alias="endTime") - ] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/create_span_event.py b/langfuse/api/ingestion/types/create_span_event.py deleted file mode 100644 index 9b40bcf6b..000000000 --- a/langfuse/api/ingestion/types/create_span_event.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .base_event import BaseEvent -from .create_span_body import CreateSpanBody - - -class CreateSpanEvent(BaseEvent): - """ - Sunset warning: this is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types, including this one. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl; see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - """ - - body: CreateSpanBody - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/ingestion_error.py b/langfuse/api/ingestion/types/ingestion_error.py deleted file mode 100644 index 2391d95eb..000000000 --- a/langfuse/api/ingestion/types/ingestion_error.py +++ /dev/null @@ -1,17 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ...core.pydantic_utilities import UniversalBaseModel - - -class IngestionError(UniversalBaseModel): - id: str - status: int - message: typing.Optional[str] = None - error: typing.Optional[typing.Any] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/ingestion_event.py b/langfuse/api/ingestion/types/ingestion_event.py deleted file mode 100644 index 3ee88e030..000000000 --- a/langfuse/api/ingestion/types/ingestion_event.py +++ /dev/null @@ -1,141 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from __future__ import annotations - -import typing - -import pydantic -import typing_extensions -from ...core.pydantic_utilities import UniversalBaseModel -from .create_event_body import CreateEventBody -from .create_generation_body import CreateGenerationBody -from .create_span_body import CreateSpanBody -from .observation_body import ObservationBody -from .score_body import ScoreBody -from .trace_body import TraceBody -from .update_generation_body import UpdateGenerationBody -from .update_span_body import UpdateSpanBody - - -class IngestionEvent_TraceCreate(UniversalBaseModel): - type: typing.Literal["trace-create"] = "trace-create" - body: TraceBody - id: str - timestamp: str - metadata: typing.Optional[typing.Any] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) - - -class IngestionEvent_ScoreCreate(UniversalBaseModel): - type: typing.Literal["score-create"] = "score-create" - body: ScoreBody - id: str - timestamp: str - metadata: typing.Optional[typing.Any] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) - - -class IngestionEvent_SpanCreate(UniversalBaseModel): - type: typing.Literal["span-create"] = "span-create" - body: CreateSpanBody - id: str - timestamp: str - metadata: typing.Optional[typing.Any] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) - - -class IngestionEvent_SpanUpdate(UniversalBaseModel): - type: typing.Literal["span-update"] = "span-update" - body: UpdateSpanBody - id: str - timestamp: str - metadata: typing.Optional[typing.Any] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) - - -class IngestionEvent_GenerationCreate(UniversalBaseModel): - type: typing.Literal["generation-create"] = "generation-create" - body: CreateGenerationBody - id: str - timestamp: str - metadata: typing.Optional[typing.Any] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) - - -class IngestionEvent_GenerationUpdate(UniversalBaseModel): - type: typing.Literal["generation-update"] = "generation-update" - body: UpdateGenerationBody - id: str - timestamp: str - metadata: typing.Optional[typing.Any] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) - - -class IngestionEvent_EventCreate(UniversalBaseModel): - type: typing.Literal["event-create"] = "event-create" - body: CreateEventBody - id: str - timestamp: str - metadata: typing.Optional[typing.Any] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) - - -class IngestionEvent_ObservationCreate(UniversalBaseModel): - type: typing.Literal["observation-create"] = "observation-create" - body: ObservationBody - id: str - timestamp: str - metadata: typing.Optional[typing.Any] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) - - -class IngestionEvent_ObservationUpdate(UniversalBaseModel): - type: typing.Literal["observation-update"] = "observation-update" - body: ObservationBody - id: str - timestamp: str - metadata: typing.Optional[typing.Any] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) - - -IngestionEvent = typing_extensions.Annotated[ - typing.Union[ - IngestionEvent_TraceCreate, - IngestionEvent_ScoreCreate, - IngestionEvent_SpanCreate, - IngestionEvent_SpanUpdate, - IngestionEvent_GenerationCreate, - IngestionEvent_GenerationUpdate, - IngestionEvent_EventCreate, - IngestionEvent_ObservationCreate, - IngestionEvent_ObservationUpdate, - ], - pydantic.Field(discriminator="type"), -] diff --git a/langfuse/api/ingestion/types/ingestion_response.py b/langfuse/api/ingestion/types/ingestion_response.py deleted file mode 100644 index 063b9a773..000000000 --- a/langfuse/api/ingestion/types/ingestion_response.py +++ /dev/null @@ -1,23 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -import typing_extensions -from ...commons.types.deprecation import Deprecation -from ...core.pydantic_utilities import UniversalBaseModel -from ...core.serialization import FieldMetadata -from .ingestion_error import IngestionError -from .ingestion_success import IngestionSuccess - - -class IngestionResponse(UniversalBaseModel): - successes: typing.List[IngestionSuccess] - errors: typing.List[IngestionError] - deprecation: typing_extensions.Annotated[ - typing.Optional[Deprecation], FieldMetadata(alias="_deprecation") - ] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/ingestion_success.py b/langfuse/api/ingestion/types/ingestion_success.py deleted file mode 100644 index e7894797a..000000000 --- a/langfuse/api/ingestion/types/ingestion_success.py +++ /dev/null @@ -1,15 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ...core.pydantic_utilities import UniversalBaseModel - - -class IngestionSuccess(UniversalBaseModel): - id: str - status: int - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/ingestion_usage.py b/langfuse/api/ingestion/types/ingestion_usage.py deleted file mode 100644 index 8b3f67103..000000000 --- a/langfuse/api/ingestion/types/ingestion_usage.py +++ /dev/null @@ -1,8 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -from ...commons.types.usage import Usage -from .open_ai_usage import OpenAiUsage - -IngestionUsage = typing.Union[Usage, OpenAiUsage] diff --git a/langfuse/api/ingestion/types/observation_body.py b/langfuse/api/ingestion/types/observation_body.py deleted file mode 100644 index e989a768f..000000000 --- a/langfuse/api/ingestion/types/observation_body.py +++ /dev/null @@ -1,53 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -import typing_extensions -from ...commons.types.map_value import MapValue -from ...commons.types.observation_level import ObservationLevel -from ...commons.types.usage import Usage -from ...core.pydantic_utilities import UniversalBaseModel -from ...core.serialization import FieldMetadata -from .observation_type import ObservationType - - -class ObservationBody(UniversalBaseModel): - id: typing.Optional[str] = None - trace_id: typing_extensions.Annotated[ - typing.Optional[str], FieldMetadata(alias="traceId") - ] = None - type: ObservationType - name: typing.Optional[str] = None - start_time: typing_extensions.Annotated[ - typing.Optional[dt.datetime], FieldMetadata(alias="startTime") - ] = None - end_time: typing_extensions.Annotated[ - typing.Optional[dt.datetime], FieldMetadata(alias="endTime") - ] = None - completion_start_time: typing_extensions.Annotated[ - typing.Optional[dt.datetime], FieldMetadata(alias="completionStartTime") - ] = None - model: typing.Optional[str] = None - model_parameters: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, MapValue]], - FieldMetadata(alias="modelParameters"), - ] = None - input: typing.Optional[typing.Any] = None - version: typing.Optional[str] = None - metadata: typing.Optional[typing.Any] = None - output: typing.Optional[typing.Any] = None - usage: typing.Optional[Usage] = None - level: typing.Optional[ObservationLevel] = None - status_message: typing_extensions.Annotated[ - typing.Optional[str], FieldMetadata(alias="statusMessage") - ] = None - parent_observation_id: typing_extensions.Annotated[ - typing.Optional[str], FieldMetadata(alias="parentObservationId") - ] = None - environment: typing.Optional[str] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/observation_type.py b/langfuse/api/ingestion/types/observation_type.py deleted file mode 100644 index f769e34cf..000000000 --- a/langfuse/api/ingestion/types/observation_type.py +++ /dev/null @@ -1,54 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -from ...core import enum - -T_Result = typing.TypeVar("T_Result") - - -class ObservationType(enum.StrEnum): - SPAN = "SPAN" - GENERATION = "GENERATION" - EVENT = "EVENT" - AGENT = "AGENT" - TOOL = "TOOL" - CHAIN = "CHAIN" - RETRIEVER = "RETRIEVER" - EVALUATOR = "EVALUATOR" - EMBEDDING = "EMBEDDING" - GUARDRAIL = "GUARDRAIL" - - def visit( - self, - span: typing.Callable[[], T_Result], - generation: typing.Callable[[], T_Result], - event: typing.Callable[[], T_Result], - agent: typing.Callable[[], T_Result], - tool: typing.Callable[[], T_Result], - chain: typing.Callable[[], T_Result], - retriever: typing.Callable[[], T_Result], - evaluator: typing.Callable[[], T_Result], - embedding: typing.Callable[[], T_Result], - guardrail: typing.Callable[[], T_Result], - ) -> T_Result: - if self is ObservationType.SPAN: - return span() - if self is ObservationType.GENERATION: - return generation() - if self is ObservationType.EVENT: - return event() - if self is ObservationType.AGENT: - return agent() - if self is ObservationType.TOOL: - return tool() - if self is ObservationType.CHAIN: - return chain() - if self is ObservationType.RETRIEVER: - return retriever() - if self is ObservationType.EVALUATOR: - return evaluator() - if self is ObservationType.EMBEDDING: - return embedding() - if self is ObservationType.GUARDRAIL: - return guardrail() diff --git a/langfuse/api/ingestion/types/open_ai_completion_usage_schema.py b/langfuse/api/ingestion/types/open_ai_completion_usage_schema.py deleted file mode 100644 index 292c51e79..000000000 --- a/langfuse/api/ingestion/types/open_ai_completion_usage_schema.py +++ /dev/null @@ -1,26 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ...core.pydantic_utilities import UniversalBaseModel - - -class OpenAiCompletionUsageSchema(UniversalBaseModel): - """ - OpenAI Usage schema from (Chat-)Completion APIs - """ - - prompt_tokens: int - completion_tokens: int - total_tokens: int - prompt_tokens_details: typing.Optional[typing.Dict[str, typing.Optional[int]]] = ( - None - ) - completion_tokens_details: typing.Optional[ - typing.Dict[str, typing.Optional[int]] - ] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/open_ai_response_usage_schema.py b/langfuse/api/ingestion/types/open_ai_response_usage_schema.py deleted file mode 100644 index 93cbc7dba..000000000 --- a/langfuse/api/ingestion/types/open_ai_response_usage_schema.py +++ /dev/null @@ -1,24 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from ...core.pydantic_utilities import UniversalBaseModel - - -class OpenAiResponseUsageSchema(UniversalBaseModel): - """ - OpenAI Usage schema from Response API - """ - - input_tokens: int - output_tokens: int - total_tokens: int - input_tokens_details: typing.Optional[typing.Dict[str, typing.Optional[int]]] = None - output_tokens_details: typing.Optional[typing.Dict[str, typing.Optional[int]]] = ( - None - ) - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/optional_observation_body.py b/langfuse/api/ingestion/types/optional_observation_body.py deleted file mode 100644 index f2aaf9b6d..000000000 --- a/langfuse/api/ingestion/types/optional_observation_body.py +++ /dev/null @@ -1,36 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -import typing_extensions -from ...commons.types.observation_level import ObservationLevel -from ...core.pydantic_utilities import UniversalBaseModel -from ...core.serialization import FieldMetadata - - -class OptionalObservationBody(UniversalBaseModel): - trace_id: typing_extensions.Annotated[ - typing.Optional[str], FieldMetadata(alias="traceId") - ] = None - name: typing.Optional[str] = None - start_time: typing_extensions.Annotated[ - typing.Optional[dt.datetime], FieldMetadata(alias="startTime") - ] = None - metadata: typing.Optional[typing.Any] = None - input: typing.Optional[typing.Any] = None - output: typing.Optional[typing.Any] = None - level: typing.Optional[ObservationLevel] = None - status_message: typing_extensions.Annotated[ - typing.Optional[str], FieldMetadata(alias="statusMessage") - ] = None - parent_observation_id: typing_extensions.Annotated[ - typing.Optional[str], FieldMetadata(alias="parentObservationId") - ] = None - version: typing.Optional[str] = None - environment: typing.Optional[str] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/score_event.py b/langfuse/api/ingestion/types/score_event.py deleted file mode 100644 index d0d470899..000000000 --- a/langfuse/api/ingestion/types/score_event.py +++ /dev/null @@ -1,15 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .base_event import BaseEvent -from .score_body import ScoreBody - - -class ScoreEvent(BaseEvent): - body: ScoreBody - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/trace_body.py b/langfuse/api/ingestion/types/trace_body.py deleted file mode 100644 index 7fb2842a0..000000000 --- a/langfuse/api/ingestion/types/trace_body.py +++ /dev/null @@ -1,36 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -import typing_extensions -from ...core.pydantic_utilities import UniversalBaseModel -from ...core.serialization import FieldMetadata - - -class TraceBody(UniversalBaseModel): - id: typing.Optional[str] = None - timestamp: typing.Optional[dt.datetime] = None - name: typing.Optional[str] = None - user_id: typing_extensions.Annotated[ - typing.Optional[str], FieldMetadata(alias="userId") - ] = None - input: typing.Optional[typing.Any] = None - output: typing.Optional[typing.Any] = None - session_id: typing_extensions.Annotated[ - typing.Optional[str], FieldMetadata(alias="sessionId") - ] = None - release: typing.Optional[str] = None - version: typing.Optional[str] = None - metadata: typing.Optional[typing.Any] = None - tags: typing.Optional[typing.List[str]] = None - environment: typing.Optional[str] = None - public: typing.Optional[bool] = pydantic.Field(default=None) - """ - Make trace publicly accessible via url - """ - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/trace_event.py b/langfuse/api/ingestion/types/trace_event.py deleted file mode 100644 index 3c89ec52b..000000000 --- a/langfuse/api/ingestion/types/trace_event.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .base_event import BaseEvent -from .trace_body import TraceBody - - -class TraceEvent(BaseEvent): - """ - Sunset warning: this is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types, including this one. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl; see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - """ - - body: TraceBody - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/update_event_body.py b/langfuse/api/ingestion/types/update_event_body.py deleted file mode 100644 index 055f66f08..000000000 --- a/langfuse/api/ingestion/types/update_event_body.py +++ /dev/null @@ -1,14 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .optional_observation_body import OptionalObservationBody - - -class UpdateEventBody(OptionalObservationBody): - id: str - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/update_generation_body.py b/langfuse/api/ingestion/types/update_generation_body.py deleted file mode 100644 index 1d453e759..000000000 --- a/langfuse/api/ingestion/types/update_generation_body.py +++ /dev/null @@ -1,40 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -import typing_extensions -from ...commons.types.map_value import MapValue -from ...core.serialization import FieldMetadata -from .ingestion_usage import IngestionUsage -from .update_span_body import UpdateSpanBody -from .usage_details import UsageDetails - - -class UpdateGenerationBody(UpdateSpanBody): - completion_start_time: typing_extensions.Annotated[ - typing.Optional[dt.datetime], FieldMetadata(alias="completionStartTime") - ] = None - model: typing.Optional[str] = None - model_parameters: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, MapValue]], - FieldMetadata(alias="modelParameters"), - ] = None - usage: typing.Optional[IngestionUsage] = None - prompt_name: typing_extensions.Annotated[ - typing.Optional[str], FieldMetadata(alias="promptName") - ] = None - usage_details: typing_extensions.Annotated[ - typing.Optional[UsageDetails], FieldMetadata(alias="usageDetails") - ] = None - cost_details: typing_extensions.Annotated[ - typing.Optional[typing.Dict[str, float]], FieldMetadata(alias="costDetails") - ] = None - prompt_version: typing_extensions.Annotated[ - typing.Optional[int], FieldMetadata(alias="promptVersion") - ] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/update_generation_event.py b/langfuse/api/ingestion/types/update_generation_event.py deleted file mode 100644 index 359c0934b..000000000 --- a/langfuse/api/ingestion/types/update_generation_event.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .base_event import BaseEvent -from .update_generation_body import UpdateGenerationBody - - -class UpdateGenerationEvent(BaseEvent): - """ - Sunset warning: this is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types, including this one. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl; see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - """ - - body: UpdateGenerationBody - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/update_observation_event.py b/langfuse/api/ingestion/types/update_observation_event.py deleted file mode 100644 index 0f6f8786d..000000000 --- a/langfuse/api/ingestion/types/update_observation_event.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .base_event import BaseEvent -from .observation_body import ObservationBody - - -class UpdateObservationEvent(BaseEvent): - """ - Sunset warning: this is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types, including this one. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl; see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - """ - - body: ObservationBody - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/update_span_body.py b/langfuse/api/ingestion/types/update_span_body.py deleted file mode 100644 index f094b7cdb..000000000 --- a/langfuse/api/ingestion/types/update_span_body.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import datetime as dt -import typing - -import pydantic -import typing_extensions -from ...core.serialization import FieldMetadata -from .update_event_body import UpdateEventBody - - -class UpdateSpanBody(UpdateEventBody): - end_time: typing_extensions.Annotated[ - typing.Optional[dt.datetime], FieldMetadata(alias="endTime") - ] = None - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/update_span_event.py b/langfuse/api/ingestion/types/update_span_event.py deleted file mode 100644 index a2138ced6..000000000 --- a/langfuse/api/ingestion/types/update_span_event.py +++ /dev/null @@ -1,19 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -import pydantic -from .base_event import BaseEvent -from .update_span_body import UpdateSpanBody - - -class UpdateSpanEvent(BaseEvent): - """ - Sunset warning: this is the deprecated Langfuse v3 ingestion API. It is shut down on November 16, 2026, except for score events: from that date it accepts only `score-create` events and rejects all other event types, including this one. To write scores, prefer `POST /api/public/scores`; see the [Scores API docs](https://langfuse.com/docs/api-and-data-platform/features/scores-api). To write traces and observations, always prefer upgrading to the current Python and JS SDKs. If you use custom auto-instrumentation, send them to the OpenTelemetry endpoint (`POST /api/public/otel/v1/traces`), for example with curl; see the [OpenTelemetry integration docs](https://langfuse.com/integrations/native/opentelemetry). To read data back, use the v4 read APIs; see the [Observations API docs](https://langfuse.com/docs/api-and-data-platform/features/observations-api) and the [Metrics API docs](https://langfuse.com/docs/metrics/features/metrics-api). The only path to live data is OpenTelemetry ingestion combined with `GET /api/public/v2/observations` and `GET /api/public/v2/metrics`. All other public APIs may have data delays of several minutes. - """ - - body: UpdateSpanBody - - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow", frozen=True - ) diff --git a/langfuse/api/ingestion/types/usage_details.py b/langfuse/api/ingestion/types/usage_details.py deleted file mode 100644 index beb98cbd0..000000000 --- a/langfuse/api/ingestion/types/usage_details.py +++ /dev/null @@ -1,10 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -import typing - -from .open_ai_completion_usage_schema import OpenAiCompletionUsageSchema -from .open_ai_response_usage_schema import OpenAiResponseUsageSchema - -UsageDetails = typing.Union[ - typing.Dict[str, int], OpenAiCompletionUsageSchema, OpenAiResponseUsageSchema -] diff --git a/langfuse/api/scores/__init__.py b/langfuse/api/scores/__init__.py index a92174549..0fe558ea3 100644 --- a/langfuse/api/scores/__init__.py +++ b/langfuse/api/scores/__init__.py @@ -21,6 +21,7 @@ GetScoresV3Meta, GetScoresV3Response, NumericScoreV3, + ScoreBody, ScoreSubjectExperimentV3, ScoreSubjectObservationV3, ScoreSubjectSessionV3, @@ -53,6 +54,7 @@ "GetScoresV3Meta": ".types", "GetScoresV3Response": ".types", "NumericScoreV3": ".types", + "ScoreBody": ".types", "ScoreSubjectExperimentV3": ".types", "ScoreSubjectObservationV3": ".types", "ScoreSubjectSessionV3": ".types", @@ -114,6 +116,7 @@ def __dir__(): "GetScoresV3Meta", "GetScoresV3Response", "NumericScoreV3", + "ScoreBody", "ScoreSubjectExperimentV3", "ScoreSubjectObservationV3", "ScoreSubjectSessionV3", diff --git a/langfuse/api/scores/types/__init__.py b/langfuse/api/scores/types/__init__.py index d2578c4b5..9a2be8f5c 100644 --- a/langfuse/api/scores/types/__init__.py +++ b/langfuse/api/scores/types/__init__.py @@ -20,6 +20,7 @@ from .get_scores_v3meta import GetScoresV3Meta from .get_scores_v3response import GetScoresV3Response from .numeric_score_v3 import NumericScoreV3 + from .score_body import ScoreBody from .score_subject_experiment_v3 import ScoreSubjectExperimentV3 from .score_subject_observation_v3 import ScoreSubjectObservationV3 from .score_subject_session_v3 import ScoreSubjectSessionV3 @@ -55,6 +56,7 @@ "GetScoresV3Meta": ".get_scores_v3meta", "GetScoresV3Response": ".get_scores_v3response", "NumericScoreV3": ".numeric_score_v3", + "ScoreBody": ".score_body", "ScoreSubjectExperimentV3": ".score_subject_experiment_v3", "ScoreSubjectObservationV3": ".score_subject_observation_v3", "ScoreSubjectSessionV3": ".score_subject_session_v3", @@ -116,6 +118,7 @@ def __dir__(): "GetScoresV3Meta", "GetScoresV3Response", "NumericScoreV3", + "ScoreBody", "ScoreSubjectExperimentV3", "ScoreSubjectObservationV3", "ScoreSubjectSessionV3", diff --git a/langfuse/api/ingestion/types/score_body.py b/langfuse/api/scores/types/score_body.py similarity index 98% rename from langfuse/api/ingestion/types/score_body.py rename to langfuse/api/scores/types/score_body.py index d9a32b6a7..ec10ba7cf 100644 --- a/langfuse/api/ingestion/types/score_body.py +++ b/langfuse/api/scores/types/score_body.py @@ -14,7 +14,7 @@ class ScoreBody(UniversalBaseModel): """ Examples -------- - from langfuse.ingestion import ScoreBody + from langfuse.scores import ScoreBody ScoreBody( name="novelty",