Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions langfuse/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
),
)
```
Expand All @@ -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(
Expand All @@ -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,
),
)

Expand All @@ -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)
Expand All @@ -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
})
```
Expand All @@ -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
})
```
Expand Down
20 changes: 20 additions & 0 deletions langfuse/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

from .resources import (
AccessDeniedError,
AnnotationQueue,
AnnotationQueueItem,
AnnotationQueueObjectType,
AnnotationQueueStatus,
BaseEvent,
BasePrompt,
BaseScore,
Expand All @@ -12,6 +16,7 @@
Comment,
CommentObjectType,
ConfigCategory,
CreateAnnotationQueueItemRequest,
CreateChatPromptRequest,
CreateCommentRequest,
CreateCommentResponse,
Expand Down Expand Up @@ -42,6 +47,7 @@
DatasetRunItem,
DatasetRunWithItems,
DatasetStatus,
DeleteAnnotationQueueItemResponse,
DeleteDatasetItemResponse,
DeleteDatasetRunResponse,
DeleteTraceResponse,
Expand Down Expand Up @@ -93,6 +99,8 @@
OpenAiResponseUsageSchema,
OpenAiUsage,
OptionalObservationBody,
PaginatedAnnotationQueueItems,
PaginatedAnnotationQueues,
PaginatedDatasetItems,
PaginatedDatasetRuns,
PaginatedDatasets,
Expand Down Expand Up @@ -130,6 +138,7 @@
TraceWithFullDetails,
Traces,
UnauthorizedError,
UpdateAnnotationQueueItemRequest,
UpdateEventBody,
UpdateGenerationBody,
UpdateGenerationEvent,
Expand All @@ -139,6 +148,7 @@
Usage,
UsageByModel,
UsageDetails,
annotation_queues,
comments,
commons,
dataset_items,
Expand All @@ -162,6 +172,10 @@

__all__ = [
"AccessDeniedError",
"AnnotationQueue",
"AnnotationQueueItem",
"AnnotationQueueObjectType",
"AnnotationQueueStatus",
"BaseEvent",
"BasePrompt",
"BaseScore",
Expand All @@ -172,6 +186,7 @@
"Comment",
"CommentObjectType",
"ConfigCategory",
"CreateAnnotationQueueItemRequest",
"CreateChatPromptRequest",
"CreateCommentRequest",
"CreateCommentResponse",
Expand Down Expand Up @@ -202,6 +217,7 @@
"DatasetRunItem",
"DatasetRunWithItems",
"DatasetStatus",
"DeleteAnnotationQueueItemResponse",
"DeleteDatasetItemResponse",
"DeleteDatasetRunResponse",
"DeleteTraceResponse",
Expand Down Expand Up @@ -253,6 +269,8 @@
"OpenAiResponseUsageSchema",
"OpenAiUsage",
"OptionalObservationBody",
"PaginatedAnnotationQueueItems",
"PaginatedAnnotationQueues",
"PaginatedDatasetItems",
"PaginatedDatasetRuns",
"PaginatedDatasets",
Expand Down Expand Up @@ -290,6 +308,7 @@
"TraceWithFullDetails",
"Traces",
"UnauthorizedError",
"UpdateAnnotationQueueItemRequest",
"UpdateEventBody",
"UpdateGenerationBody",
"UpdateGenerationEvent",
Expand All @@ -299,6 +318,7 @@
"Usage",
"UsageByModel",
"UsageDetails",
"annotation_queues",
"comments",
"commons",
"dataset_items",
Expand Down
10 changes: 10 additions & 0 deletions langfuse/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading