From db7b2f1710fd9ef98f1fc792546afd19126b406d Mon Sep 17 00:00:00 2001 From: Hassieb Pakzad <68423100+hassiebp@users.noreply.github.com> Date: Mon, 24 Mar 2025 13:29:11 +0100 Subject: [PATCH] fix(cost-tracking): handle none values in OpenAI schema --- langfuse/api/README.md | 28 +- langfuse/api/__init__.py | 20 + langfuse/api/client.py | 10 + langfuse/api/reference.md | 606 +++++++++ langfuse/api/resources/__init__.py | 22 + .../resources/annotation_queues/__init__.py | 25 + .../api/resources/annotation_queues/client.py | 1148 +++++++++++++++++ .../annotation_queues/types/__init__.py | 23 + .../types/annotation_queue.py | 49 + .../types/annotation_queue_item.py | 55 + .../types/annotation_queue_object_type.py | 21 + .../types/annotation_queue_status.py | 21 + .../create_annotation_queue_item_request.py | 51 + .../delete_annotation_queue_item_response.py | 43 + .../types/paginated_annotation_queue_items.py | 45 + .../types/paginated_annotation_queues.py | 45 + .../update_annotation_queue_item_request.py | 43 + .../types/open_ai_completion_usage_schema.py | 8 +- .../types/open_ai_response_usage_schema.py | 6 +- 19 files changed, 2250 insertions(+), 19 deletions(-) create mode 100644 langfuse/api/resources/annotation_queues/__init__.py create mode 100644 langfuse/api/resources/annotation_queues/client.py create mode 100644 langfuse/api/resources/annotation_queues/types/__init__.py create mode 100644 langfuse/api/resources/annotation_queues/types/annotation_queue.py create mode 100644 langfuse/api/resources/annotation_queues/types/annotation_queue_item.py create mode 100644 langfuse/api/resources/annotation_queues/types/annotation_queue_object_type.py create mode 100644 langfuse/api/resources/annotation_queues/types/annotation_queue_status.py create mode 100644 langfuse/api/resources/annotation_queues/types/create_annotation_queue_item_request.py create mode 100644 langfuse/api/resources/annotation_queues/types/delete_annotation_queue_item_response.py create mode 100644 langfuse/api/resources/annotation_queues/types/paginated_annotation_queue_items.py create mode 100644 langfuse/api/resources/annotation_queues/types/paginated_annotation_queues.py create mode 100644 langfuse/api/resources/annotation_queues/types/update_annotation_queue_item_request.py diff --git a/langfuse/api/README.md b/langfuse/api/README.md index e1a87ffff..feb6512ef 100644 --- a/langfuse/api/README.md +++ b/langfuse/api/README.md @@ -16,7 +16,7 @@ pip install langfuse Instantiate and use the client with the following: ```python -from langfuse import CreateCommentRequest +from langfuse import AnnotationQueueObjectType, CreateAnnotationQueueItemRequest from langfuse.client import FernLangfuse client = FernLangfuse( @@ -27,12 +27,11 @@ client = FernLangfuse( password="YOUR_PASSWORD", base_url="https://yourhost.com/path/to/api", ) -client.comments.create( - request=CreateCommentRequest( - project_id="projectId", - object_type="objectType", +client.annotation_queues.create_queue_item( + queue_id="queueId", + request=CreateAnnotationQueueItemRequest( object_id="objectId", - content="content", + object_type=AnnotationQueueObjectType.TRACE, ), ) ``` @@ -44,7 +43,7 @@ The SDK also exports an `async` client so that you can make non-blocking calls t ```python import asyncio -from langfuse import CreateCommentRequest +from langfuse import AnnotationQueueObjectType, CreateAnnotationQueueItemRequest from langfuse.client import AsyncFernLangfuse client = AsyncFernLangfuse( @@ -58,12 +57,11 @@ client = AsyncFernLangfuse( async def main() -> None: - await client.comments.create( - request=CreateCommentRequest( - project_id="projectId", - object_type="objectType", + await client.annotation_queues.create_queue_item( + queue_id="queueId", + request=CreateAnnotationQueueItemRequest( object_id="objectId", - content="content", + object_type=AnnotationQueueObjectType.TRACE, ), ) @@ -80,7 +78,7 @@ will be thrown. from .api_error import ApiError try: - client.comments.create(...) + client.annotation_queues.create_queue_item(...) except ApiError as e: print(e.status_code) print(e.body) @@ -103,7 +101,7 @@ A request is deemed retriable when any of the following HTTP status codes is ret Use the `max_retries` request option to configure this behavior. ```python -client.comments.create(...,{ +client.annotation_queues.create_queue_item(...,{ max_retries=1 }) ``` @@ -120,7 +118,7 @@ client = FernLangfuse(..., { timeout=20.0 }, ) # Override timeout for a specific method -client.comments.create(...,{ +client.annotation_queues.create_queue_item(...,{ timeout_in_seconds=1 }) ``` diff --git a/langfuse/api/__init__.py b/langfuse/api/__init__.py index 71adf3728..d59e65d4c 100644 --- a/langfuse/api/__init__.py +++ b/langfuse/api/__init__.py @@ -2,6 +2,10 @@ from .resources import ( AccessDeniedError, + AnnotationQueue, + AnnotationQueueItem, + AnnotationQueueObjectType, + AnnotationQueueStatus, BaseEvent, BasePrompt, BaseScore, @@ -12,6 +16,7 @@ Comment, CommentObjectType, ConfigCategory, + CreateAnnotationQueueItemRequest, CreateChatPromptRequest, CreateCommentRequest, CreateCommentResponse, @@ -42,6 +47,7 @@ DatasetRunItem, DatasetRunWithItems, DatasetStatus, + DeleteAnnotationQueueItemResponse, DeleteDatasetItemResponse, DeleteDatasetRunResponse, DeleteTraceResponse, @@ -93,6 +99,8 @@ OpenAiResponseUsageSchema, OpenAiUsage, OptionalObservationBody, + PaginatedAnnotationQueueItems, + PaginatedAnnotationQueues, PaginatedDatasetItems, PaginatedDatasetRuns, PaginatedDatasets, @@ -130,6 +138,7 @@ TraceWithFullDetails, Traces, UnauthorizedError, + UpdateAnnotationQueueItemRequest, UpdateEventBody, UpdateGenerationBody, UpdateGenerationEvent, @@ -139,6 +148,7 @@ Usage, UsageByModel, UsageDetails, + annotation_queues, comments, commons, dataset_items, @@ -162,6 +172,10 @@ __all__ = [ "AccessDeniedError", + "AnnotationQueue", + "AnnotationQueueItem", + "AnnotationQueueObjectType", + "AnnotationQueueStatus", "BaseEvent", "BasePrompt", "BaseScore", @@ -172,6 +186,7 @@ "Comment", "CommentObjectType", "ConfigCategory", + "CreateAnnotationQueueItemRequest", "CreateChatPromptRequest", "CreateCommentRequest", "CreateCommentResponse", @@ -202,6 +217,7 @@ "DatasetRunItem", "DatasetRunWithItems", "DatasetStatus", + "DeleteAnnotationQueueItemResponse", "DeleteDatasetItemResponse", "DeleteDatasetRunResponse", "DeleteTraceResponse", @@ -253,6 +269,8 @@ "OpenAiResponseUsageSchema", "OpenAiUsage", "OptionalObservationBody", + "PaginatedAnnotationQueueItems", + "PaginatedAnnotationQueues", "PaginatedDatasetItems", "PaginatedDatasetRuns", "PaginatedDatasets", @@ -290,6 +308,7 @@ "TraceWithFullDetails", "Traces", "UnauthorizedError", + "UpdateAnnotationQueueItemRequest", "UpdateEventBody", "UpdateGenerationBody", "UpdateGenerationEvent", @@ -299,6 +318,7 @@ "Usage", "UsageByModel", "UsageDetails", + "annotation_queues", "comments", "commons", "dataset_items", diff --git a/langfuse/api/client.py b/langfuse/api/client.py index 932f5f3c2..77a09a416 100644 --- a/langfuse/api/client.py +++ b/langfuse/api/client.py @@ -5,6 +5,10 @@ import httpx from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .resources.annotation_queues.client import ( + AnnotationQueuesClient, + AsyncAnnotationQueuesClient, +) from .resources.comments.client import AsyncCommentsClient, CommentsClient from .resources.dataset_items.client import AsyncDatasetItemsClient, DatasetItemsClient from .resources.dataset_run_items.client import ( @@ -99,6 +103,9 @@ def __init__( else httpx.Client(timeout=_defaulted_timeout), timeout=_defaulted_timeout, ) + self.annotation_queues = AnnotationQueuesClient( + client_wrapper=self._client_wrapper + ) self.comments = CommentsClient(client_wrapper=self._client_wrapper) self.dataset_items = DatasetItemsClient(client_wrapper=self._client_wrapper) self.dataset_run_items = DatasetRunItemsClient( @@ -189,6 +196,9 @@ def __init__( else httpx.AsyncClient(timeout=_defaulted_timeout), timeout=_defaulted_timeout, ) + self.annotation_queues = AsyncAnnotationQueuesClient( + client_wrapper=self._client_wrapper + ) self.comments = AsyncCommentsClient(client_wrapper=self._client_wrapper) self.dataset_items = AsyncDatasetItemsClient( client_wrapper=self._client_wrapper diff --git a/langfuse/api/reference.md b/langfuse/api/reference.md index 77f2b2a58..c52f406fc 100644 --- a/langfuse/api/reference.md +++ b/langfuse/api/reference.md @@ -1,4 +1,610 @@ # Reference +## AnnotationQueues +
client.annotation_queues.list_queues(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get all annotation queues +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from langfuse.client import FernLangfuse + +client = FernLangfuse( + 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.annotation_queues.list_queues() + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**page:** `typing.Optional[int]` — page number, starts at 1 + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — limit of items per page + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.annotation_queues.get_queue(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get an annotation queue by ID +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from langfuse.client import FernLangfuse + +client = FernLangfuse( + 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.annotation_queues.get_queue( + queue_id="queueId", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**queue_id:** `str` — The unique identifier of the annotation queue + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.annotation_queues.list_queue_items(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get items for a specific annotation queue +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from langfuse.client import FernLangfuse + +client = FernLangfuse( + 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.annotation_queues.list_queue_items( + queue_id="queueId", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**queue_id:** `str` — The unique identifier of the annotation queue + +
+
+ +
+
+ +**status:** `typing.Optional[AnnotationQueueStatus]` — Filter by status + +
+
+ +
+
+ +**page:** `typing.Optional[int]` — page number, starts at 1 + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — limit of items per page + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.annotation_queues.get_queue_item(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get a specific item from an annotation queue +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from langfuse.client import FernLangfuse + +client = FernLangfuse( + 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.annotation_queues.get_queue_item( + queue_id="queueId", + item_id="itemId", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**queue_id:** `str` — The unique identifier of the annotation queue + +
+
+ +
+
+ +**item_id:** `str` — The unique identifier of the annotation queue item + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.annotation_queues.create_queue_item(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add an item to an annotation queue +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from langfuse import AnnotationQueueObjectType, CreateAnnotationQueueItemRequest +from langfuse.client import FernLangfuse + +client = FernLangfuse( + 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.annotation_queues.create_queue_item( + queue_id="queueId", + request=CreateAnnotationQueueItemRequest( + object_id="objectId", + object_type=AnnotationQueueObjectType.TRACE, + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**queue_id:** `str` — The unique identifier of the annotation queue + +
+
+ +
+
+ +**request:** `CreateAnnotationQueueItemRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.annotation_queues.update_queue_item(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an annotation queue item +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from langfuse import UpdateAnnotationQueueItemRequest +from langfuse.client import FernLangfuse + +client = FernLangfuse( + 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.annotation_queues.update_queue_item( + queue_id="queueId", + item_id="itemId", + request=UpdateAnnotationQueueItemRequest(), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**queue_id:** `str` — The unique identifier of the annotation queue + +
+
+ +
+
+ +**item_id:** `str` — The unique identifier of the annotation queue item + +
+
+ +
+
+ +**request:** `UpdateAnnotationQueueItemRequest` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.annotation_queues.delete_queue_item(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Remove an item from an annotation queue +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from langfuse.client import FernLangfuse + +client = FernLangfuse( + 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.annotation_queues.delete_queue_item( + queue_id="queueId", + item_id="itemId", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**queue_id:** `str` — The unique identifier of the annotation queue + +
+
+ +
+
+ +**item_id:** `str` — The unique identifier of the annotation queue item + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ ## Comments
client.comments.create(...)
diff --git a/langfuse/api/resources/__init__.py b/langfuse/api/resources/__init__.py index bc0dfbfef..b65a40b49 100644 --- a/langfuse/api/resources/__init__.py +++ b/langfuse/api/resources/__init__.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. from . import ( + annotation_queues, comments, commons, dataset_items, @@ -21,6 +22,17 @@ trace, utils, ) +from .annotation_queues import ( + AnnotationQueue, + AnnotationQueueItem, + AnnotationQueueObjectType, + AnnotationQueueStatus, + CreateAnnotationQueueItemRequest, + DeleteAnnotationQueueItemResponse, + PaginatedAnnotationQueueItems, + PaginatedAnnotationQueues, + UpdateAnnotationQueueItemRequest, +) from .comments import CreateCommentRequest, CreateCommentResponse, GetCommentsResponse from .commons import ( AccessDeniedError, @@ -165,6 +177,10 @@ __all__ = [ "AccessDeniedError", + "AnnotationQueue", + "AnnotationQueueItem", + "AnnotationQueueObjectType", + "AnnotationQueueStatus", "BaseEvent", "BasePrompt", "BaseScore", @@ -175,6 +191,7 @@ "Comment", "CommentObjectType", "ConfigCategory", + "CreateAnnotationQueueItemRequest", "CreateChatPromptRequest", "CreateCommentRequest", "CreateCommentResponse", @@ -205,6 +222,7 @@ "DatasetRunItem", "DatasetRunWithItems", "DatasetStatus", + "DeleteAnnotationQueueItemResponse", "DeleteDatasetItemResponse", "DeleteDatasetRunResponse", "DeleteTraceResponse", @@ -256,6 +274,8 @@ "OpenAiResponseUsageSchema", "OpenAiUsage", "OptionalObservationBody", + "PaginatedAnnotationQueueItems", + "PaginatedAnnotationQueues", "PaginatedDatasetItems", "PaginatedDatasetRuns", "PaginatedDatasets", @@ -293,6 +313,7 @@ "TraceWithFullDetails", "Traces", "UnauthorizedError", + "UpdateAnnotationQueueItemRequest", "UpdateEventBody", "UpdateGenerationBody", "UpdateGenerationEvent", @@ -302,6 +323,7 @@ "Usage", "UsageByModel", "UsageDetails", + "annotation_queues", "comments", "commons", "dataset_items", diff --git a/langfuse/api/resources/annotation_queues/__init__.py b/langfuse/api/resources/annotation_queues/__init__.py new file mode 100644 index 000000000..50f79e893 --- /dev/null +++ b/langfuse/api/resources/annotation_queues/__init__.py @@ -0,0 +1,25 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import ( + AnnotationQueue, + AnnotationQueueItem, + AnnotationQueueObjectType, + AnnotationQueueStatus, + CreateAnnotationQueueItemRequest, + DeleteAnnotationQueueItemResponse, + PaginatedAnnotationQueueItems, + PaginatedAnnotationQueues, + UpdateAnnotationQueueItemRequest, +) + +__all__ = [ + "AnnotationQueue", + "AnnotationQueueItem", + "AnnotationQueueObjectType", + "AnnotationQueueStatus", + "CreateAnnotationQueueItemRequest", + "DeleteAnnotationQueueItemResponse", + "PaginatedAnnotationQueueItems", + "PaginatedAnnotationQueues", + "UpdateAnnotationQueueItemRequest", +] diff --git a/langfuse/api/resources/annotation_queues/client.py b/langfuse/api/resources/annotation_queues/client.py new file mode 100644 index 000000000..bc1fd287f --- /dev/null +++ b/langfuse/api/resources/annotation_queues/client.py @@ -0,0 +1,1148 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +from json.decoder import JSONDecodeError + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.jsonable_encoder import jsonable_encoder +from ...core.pydantic_utilities import pydantic_v1 +from ...core.request_options import RequestOptions +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 .types.annotation_queue import AnnotationQueue +from .types.annotation_queue_item import AnnotationQueueItem +from .types.annotation_queue_status import AnnotationQueueStatus +from .types.create_annotation_queue_item_request import CreateAnnotationQueueItemRequest +from .types.delete_annotation_queue_item_response import ( + DeleteAnnotationQueueItemResponse, +) +from .types.paginated_annotation_queue_items import PaginatedAnnotationQueueItems +from .types.paginated_annotation_queues import PaginatedAnnotationQueues +from .types.update_annotation_queue_item_request import UpdateAnnotationQueueItemRequest + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class AnnotationQueuesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def list_queues( + self, + *, + page: typing.Optional[int] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> PaginatedAnnotationQueues: + """ + Get all annotation queues + + Parameters + ---------- + page : typing.Optional[int] + page number, starts at 1 + + limit : typing.Optional[int] + limit of items per page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PaginatedAnnotationQueues + + Examples + -------- + from langfuse.client import FernLangfuse + + client = FernLangfuse( + 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.annotation_queues.list_queues() + """ + _response = self._client_wrapper.httpx_client.request( + "api/public/annotation-queues", + method="GET", + params={"page": page, "limit": limit}, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as( + PaginatedAnnotationQueues, _response.json() + ) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def get_queue( + self, queue_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AnnotationQueue: + """ + Get an annotation queue by ID + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AnnotationQueue + + Examples + -------- + from langfuse.client import FernLangfuse + + client = FernLangfuse( + 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.annotation_queues.get_queue( + queue_id="queueId", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AnnotationQueue, _response.json()) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def list_queue_items( + self, + queue_id: str, + *, + status: typing.Optional[AnnotationQueueStatus] = None, + page: typing.Optional[int] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> PaginatedAnnotationQueueItems: + """ + Get items for a specific annotation queue + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + status : typing.Optional[AnnotationQueueStatus] + Filter by status + + page : typing.Optional[int] + page number, starts at 1 + + limit : typing.Optional[int] + limit of items per page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PaginatedAnnotationQueueItems + + Examples + -------- + from langfuse.client import FernLangfuse + + client = FernLangfuse( + 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.annotation_queues.list_queue_items( + queue_id="queueId", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}/items", + method="GET", + params={"status": status, "page": page, "limit": limit}, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as( + PaginatedAnnotationQueueItems, _response.json() + ) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def get_queue_item( + self, + queue_id: str, + item_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> AnnotationQueueItem: + """ + Get a specific item from an annotation queue + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + item_id : str + The unique identifier of the annotation queue item + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AnnotationQueueItem + + Examples + -------- + from langfuse.client import FernLangfuse + + client = FernLangfuse( + 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.annotation_queues.get_queue_item( + queue_id="queueId", + item_id="itemId", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}/items/{jsonable_encoder(item_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AnnotationQueueItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def create_queue_item( + self, + queue_id: str, + *, + request: CreateAnnotationQueueItemRequest, + request_options: typing.Optional[RequestOptions] = None, + ) -> AnnotationQueueItem: + """ + Add an item to an annotation queue + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + request : CreateAnnotationQueueItemRequest + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AnnotationQueueItem + + Examples + -------- + from langfuse import AnnotationQueueObjectType, CreateAnnotationQueueItemRequest + from langfuse.client import FernLangfuse + + client = FernLangfuse( + 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.annotation_queues.create_queue_item( + queue_id="queueId", + request=CreateAnnotationQueueItemRequest( + object_id="objectId", + object_type=AnnotationQueueObjectType.TRACE, + ), + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}/items", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AnnotationQueueItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def update_queue_item( + self, + queue_id: str, + item_id: str, + *, + request: UpdateAnnotationQueueItemRequest, + request_options: typing.Optional[RequestOptions] = None, + ) -> AnnotationQueueItem: + """ + Update an annotation queue item + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + item_id : str + The unique identifier of the annotation queue item + + request : UpdateAnnotationQueueItemRequest + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AnnotationQueueItem + + Examples + -------- + from langfuse import UpdateAnnotationQueueItemRequest + from langfuse.client import FernLangfuse + + client = FernLangfuse( + 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.annotation_queues.update_queue_item( + queue_id="queueId", + item_id="itemId", + request=UpdateAnnotationQueueItemRequest(), + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}/items/{jsonable_encoder(item_id)}", + method="PATCH", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AnnotationQueueItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def delete_queue_item( + self, + queue_id: str, + item_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> DeleteAnnotationQueueItemResponse: + """ + Remove an item from an annotation queue + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + item_id : str + The unique identifier of the annotation queue item + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteAnnotationQueueItemResponse + + Examples + -------- + from langfuse.client import FernLangfuse + + client = FernLangfuse( + 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.annotation_queues.delete_queue_item( + queue_id="queueId", + item_id="itemId", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}/items/{jsonable_encoder(item_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as( + DeleteAnnotationQueueItemResponse, _response.json() + ) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + +class AsyncAnnotationQueuesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def list_queues( + self, + *, + page: typing.Optional[int] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> PaginatedAnnotationQueues: + """ + Get all annotation queues + + Parameters + ---------- + page : typing.Optional[int] + page number, starts at 1 + + limit : typing.Optional[int] + limit of items per page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PaginatedAnnotationQueues + + Examples + -------- + import asyncio + + from langfuse.client import AsyncFernLangfuse + + client = AsyncFernLangfuse( + 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.annotation_queues.list_queues() + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + "api/public/annotation-queues", + method="GET", + params={"page": page, "limit": limit}, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as( + PaginatedAnnotationQueues, _response.json() + ) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def get_queue( + self, queue_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> AnnotationQueue: + """ + Get an annotation queue by ID + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AnnotationQueue + + Examples + -------- + import asyncio + + from langfuse.client import AsyncFernLangfuse + + client = AsyncFernLangfuse( + 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.annotation_queues.get_queue( + queue_id="queueId", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AnnotationQueue, _response.json()) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def list_queue_items( + self, + queue_id: str, + *, + status: typing.Optional[AnnotationQueueStatus] = None, + page: typing.Optional[int] = None, + limit: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> PaginatedAnnotationQueueItems: + """ + Get items for a specific annotation queue + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + status : typing.Optional[AnnotationQueueStatus] + Filter by status + + page : typing.Optional[int] + page number, starts at 1 + + limit : typing.Optional[int] + limit of items per page + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + PaginatedAnnotationQueueItems + + Examples + -------- + import asyncio + + from langfuse.client import AsyncFernLangfuse + + client = AsyncFernLangfuse( + 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.annotation_queues.list_queue_items( + queue_id="queueId", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}/items", + method="GET", + params={"status": status, "page": page, "limit": limit}, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as( + PaginatedAnnotationQueueItems, _response.json() + ) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def get_queue_item( + self, + queue_id: str, + item_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> AnnotationQueueItem: + """ + Get a specific item from an annotation queue + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + item_id : str + The unique identifier of the annotation queue item + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AnnotationQueueItem + + Examples + -------- + import asyncio + + from langfuse.client import AsyncFernLangfuse + + client = AsyncFernLangfuse( + 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.annotation_queues.get_queue_item( + queue_id="queueId", + item_id="itemId", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}/items/{jsonable_encoder(item_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AnnotationQueueItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def create_queue_item( + self, + queue_id: str, + *, + request: CreateAnnotationQueueItemRequest, + request_options: typing.Optional[RequestOptions] = None, + ) -> AnnotationQueueItem: + """ + Add an item to an annotation queue + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + request : CreateAnnotationQueueItemRequest + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AnnotationQueueItem + + Examples + -------- + import asyncio + + from langfuse import AnnotationQueueObjectType, CreateAnnotationQueueItemRequest + from langfuse.client import AsyncFernLangfuse + + client = AsyncFernLangfuse( + 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.annotation_queues.create_queue_item( + queue_id="queueId", + request=CreateAnnotationQueueItemRequest( + object_id="objectId", + object_type=AnnotationQueueObjectType.TRACE, + ), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}/items", + method="POST", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AnnotationQueueItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def update_queue_item( + self, + queue_id: str, + item_id: str, + *, + request: UpdateAnnotationQueueItemRequest, + request_options: typing.Optional[RequestOptions] = None, + ) -> AnnotationQueueItem: + """ + Update an annotation queue item + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + item_id : str + The unique identifier of the annotation queue item + + request : UpdateAnnotationQueueItemRequest + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AnnotationQueueItem + + Examples + -------- + import asyncio + + from langfuse import UpdateAnnotationQueueItemRequest + from langfuse.client import AsyncFernLangfuse + + client = AsyncFernLangfuse( + 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.annotation_queues.update_queue_item( + queue_id="queueId", + item_id="itemId", + request=UpdateAnnotationQueueItemRequest(), + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}/items/{jsonable_encoder(item_id)}", + method="PATCH", + json=request, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(AnnotationQueueItem, _response.json()) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def delete_queue_item( + self, + queue_id: str, + item_id: str, + *, + request_options: typing.Optional[RequestOptions] = None, + ) -> DeleteAnnotationQueueItemResponse: + """ + Remove an item from an annotation queue + + Parameters + ---------- + queue_id : str + The unique identifier of the annotation queue + + item_id : str + The unique identifier of the annotation queue item + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + DeleteAnnotationQueueItemResponse + + Examples + -------- + import asyncio + + from langfuse.client import AsyncFernLangfuse + + client = AsyncFernLangfuse( + 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.annotation_queues.delete_queue_item( + queue_id="queueId", + item_id="itemId", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"api/public/annotation-queues/{jsonable_encoder(queue_id)}/items/{jsonable_encoder(item_id)}", + method="DELETE", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as( + DeleteAnnotationQueueItemResponse, _response.json() + ) # type: ignore + if _response.status_code == 400: + raise Error(pydantic_v1.parse_obj_as(typing.Any, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 403: + raise AccessDeniedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 405: + raise MethodNotAllowedError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + if _response.status_code == 404: + raise NotFoundError( + pydantic_v1.parse_obj_as(typing.Any, _response.json()) + ) # type: ignore + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/langfuse/api/resources/annotation_queues/types/__init__.py b/langfuse/api/resources/annotation_queues/types/__init__.py new file mode 100644 index 000000000..110b991cf --- /dev/null +++ b/langfuse/api/resources/annotation_queues/types/__init__.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +from .annotation_queue import AnnotationQueue +from .annotation_queue_item import AnnotationQueueItem +from .annotation_queue_object_type import AnnotationQueueObjectType +from .annotation_queue_status import AnnotationQueueStatus +from .create_annotation_queue_item_request import CreateAnnotationQueueItemRequest +from .delete_annotation_queue_item_response import DeleteAnnotationQueueItemResponse +from .paginated_annotation_queue_items import PaginatedAnnotationQueueItems +from .paginated_annotation_queues import PaginatedAnnotationQueues +from .update_annotation_queue_item_request import UpdateAnnotationQueueItemRequest + +__all__ = [ + "AnnotationQueue", + "AnnotationQueueItem", + "AnnotationQueueObjectType", + "AnnotationQueueStatus", + "CreateAnnotationQueueItemRequest", + "DeleteAnnotationQueueItemResponse", + "PaginatedAnnotationQueueItems", + "PaginatedAnnotationQueues", + "UpdateAnnotationQueueItemRequest", +] diff --git a/langfuse/api/resources/annotation_queues/types/annotation_queue.py b/langfuse/api/resources/annotation_queues/types/annotation_queue.py new file mode 100644 index 000000000..c4cc23282 --- /dev/null +++ b/langfuse/api/resources/annotation_queues/types/annotation_queue.py @@ -0,0 +1,49 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class AnnotationQueue(pydantic_v1.BaseModel): + id: str + name: str + description: typing.Optional[str] = None + score_config_ids: typing.List[str] = pydantic_v1.Field(alias="scoreConfigIds") + created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") + updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) + + class Config: + frozen = True + smart_union = True + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/langfuse/api/resources/annotation_queues/types/annotation_queue_item.py b/langfuse/api/resources/annotation_queues/types/annotation_queue_item.py new file mode 100644 index 000000000..e88829a1f --- /dev/null +++ b/langfuse/api/resources/annotation_queues/types/annotation_queue_item.py @@ -0,0 +1,55 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .annotation_queue_object_type import AnnotationQueueObjectType +from .annotation_queue_status import AnnotationQueueStatus + + +class AnnotationQueueItem(pydantic_v1.BaseModel): + id: str + queue_id: str = pydantic_v1.Field(alias="queueId") + object_id: str = pydantic_v1.Field(alias="objectId") + object_type: AnnotationQueueObjectType = pydantic_v1.Field(alias="objectType") + status: AnnotationQueueStatus + completed_at: typing.Optional[dt.datetime] = pydantic_v1.Field( + alias="completedAt", default=None + ) + created_at: dt.datetime = pydantic_v1.Field(alias="createdAt") + updated_at: dt.datetime = pydantic_v1.Field(alias="updatedAt") + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) + + class Config: + frozen = True + smart_union = True + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/langfuse/api/resources/annotation_queues/types/annotation_queue_object_type.py b/langfuse/api/resources/annotation_queues/types/annotation_queue_object_type.py new file mode 100644 index 000000000..1bef33b55 --- /dev/null +++ b/langfuse/api/resources/annotation_queues/types/annotation_queue_object_type.py @@ -0,0 +1,21 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class AnnotationQueueObjectType(str, enum.Enum): + TRACE = "TRACE" + OBSERVATION = "OBSERVATION" + + def visit( + self, + trace: typing.Callable[[], T_Result], + observation: typing.Callable[[], T_Result], + ) -> T_Result: + if self is AnnotationQueueObjectType.TRACE: + return trace() + if self is AnnotationQueueObjectType.OBSERVATION: + return observation() diff --git a/langfuse/api/resources/annotation_queues/types/annotation_queue_status.py b/langfuse/api/resources/annotation_queues/types/annotation_queue_status.py new file mode 100644 index 000000000..cf075f38a --- /dev/null +++ b/langfuse/api/resources/annotation_queues/types/annotation_queue_status.py @@ -0,0 +1,21 @@ +# This file was auto-generated by Fern from our API Definition. + +import enum +import typing + +T_Result = typing.TypeVar("T_Result") + + +class AnnotationQueueStatus(str, enum.Enum): + PENDING = "PENDING" + COMPLETED = "COMPLETED" + + def visit( + self, + pending: typing.Callable[[], T_Result], + completed: typing.Callable[[], T_Result], + ) -> T_Result: + if self is AnnotationQueueStatus.PENDING: + return pending() + if self is AnnotationQueueStatus.COMPLETED: + return completed() diff --git a/langfuse/api/resources/annotation_queues/types/create_annotation_queue_item_request.py b/langfuse/api/resources/annotation_queues/types/create_annotation_queue_item_request.py new file mode 100644 index 000000000..cbf257f29 --- /dev/null +++ b/langfuse/api/resources/annotation_queues/types/create_annotation_queue_item_request.py @@ -0,0 +1,51 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .annotation_queue_object_type import AnnotationQueueObjectType +from .annotation_queue_status import AnnotationQueueStatus + + +class CreateAnnotationQueueItemRequest(pydantic_v1.BaseModel): + object_id: str = pydantic_v1.Field(alias="objectId") + object_type: AnnotationQueueObjectType = pydantic_v1.Field(alias="objectType") + status: typing.Optional[AnnotationQueueStatus] = pydantic_v1.Field(default=None) + """ + Defaults to PENDING for new queue items + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) + + class Config: + frozen = True + smart_union = True + allow_population_by_field_name = True + populate_by_name = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/langfuse/api/resources/annotation_queues/types/delete_annotation_queue_item_response.py b/langfuse/api/resources/annotation_queues/types/delete_annotation_queue_item_response.py new file mode 100644 index 000000000..a412c85b7 --- /dev/null +++ b/langfuse/api/resources/annotation_queues/types/delete_annotation_queue_item_response.py @@ -0,0 +1,43 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class DeleteAnnotationQueueItemResponse(pydantic_v1.BaseModel): + success: bool + message: str + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/langfuse/api/resources/annotation_queues/types/paginated_annotation_queue_items.py b/langfuse/api/resources/annotation_queues/types/paginated_annotation_queue_items.py new file mode 100644 index 000000000..587188d89 --- /dev/null +++ b/langfuse/api/resources/annotation_queues/types/paginated_annotation_queue_items.py @@ -0,0 +1,45 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...utils.resources.pagination.types.meta_response import MetaResponse +from .annotation_queue_item import AnnotationQueueItem + + +class PaginatedAnnotationQueueItems(pydantic_v1.BaseModel): + data: typing.List[AnnotationQueueItem] + meta: MetaResponse + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/langfuse/api/resources/annotation_queues/types/paginated_annotation_queues.py b/langfuse/api/resources/annotation_queues/types/paginated_annotation_queues.py new file mode 100644 index 000000000..aba338414 --- /dev/null +++ b/langfuse/api/resources/annotation_queues/types/paginated_annotation_queues.py @@ -0,0 +1,45 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...utils.resources.pagination.types.meta_response import MetaResponse +from .annotation_queue import AnnotationQueue + + +class PaginatedAnnotationQueues(pydantic_v1.BaseModel): + data: typing.List[AnnotationQueue] + meta: MetaResponse + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/langfuse/api/resources/annotation_queues/types/update_annotation_queue_item_request.py b/langfuse/api/resources/annotation_queues/types/update_annotation_queue_item_request.py new file mode 100644 index 000000000..3b1c130fe --- /dev/null +++ b/langfuse/api/resources/annotation_queues/types/update_annotation_queue_item_request.py @@ -0,0 +1,43 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ....core.datetime_utils import serialize_datetime +from ....core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .annotation_queue_status import AnnotationQueueStatus + + +class UpdateAnnotationQueueItemRequest(pydantic_v1.BaseModel): + status: typing.Optional[AnnotationQueueStatus] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, + **kwargs, + } + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/langfuse/api/resources/ingestion/types/open_ai_completion_usage_schema.py b/langfuse/api/resources/ingestion/types/open_ai_completion_usage_schema.py index 461c8eee4..368a7da03 100644 --- a/langfuse/api/resources/ingestion/types/open_ai_completion_usage_schema.py +++ b/langfuse/api/resources/ingestion/types/open_ai_completion_usage_schema.py @@ -15,8 +15,12 @@ class OpenAiCompletionUsageSchema(pydantic_v1.BaseModel): prompt_tokens: int completion_tokens: int total_tokens: int - prompt_tokens_details: typing.Optional[typing.Dict[str, int]] = None - completion_tokens_details: typing.Optional[typing.Dict[str, int]] = None + prompt_tokens_details: typing.Optional[typing.Dict[str, typing.Optional[int]]] = ( + None + ) + completion_tokens_details: typing.Optional[ + typing.Dict[str, typing.Optional[int]] + ] = None def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = { diff --git a/langfuse/api/resources/ingestion/types/open_ai_response_usage_schema.py b/langfuse/api/resources/ingestion/types/open_ai_response_usage_schema.py index 99b0bbfa0..0c68e6a7d 100644 --- a/langfuse/api/resources/ingestion/types/open_ai_response_usage_schema.py +++ b/langfuse/api/resources/ingestion/types/open_ai_response_usage_schema.py @@ -15,8 +15,10 @@ class OpenAiResponseUsageSchema(pydantic_v1.BaseModel): input_tokens: int output_tokens: int total_tokens: int - input_tokens_details: typing.Optional[typing.Dict[str, int]] = None - output_tokens_details: typing.Optional[typing.Dict[str, int]] = None + input_tokens_details: typing.Optional[typing.Dict[str, typing.Optional[int]]] = None + output_tokens_details: typing.Optional[typing.Dict[str, typing.Optional[int]]] = ( + None + ) def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {