annotations

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package annotations provides functionality for managing annotation queues and items in Langfuse.

This package implements queue-based annotation workflows where items (traces, observations) can be queued for manual annotation and scoring. Annotation queues can be configured with specific score configurations and assigned to users for processing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssignmentRequest

type AssignmentRequest struct {
	UserID string `json:"userId"`
}

AssignmentRequest represents the request for creating/deleting queue assignments.

type CreateAssignmentResponse

type CreateAssignmentResponse struct {
	UserID    string `json:"userId"`
	QueueID   string `json:"queueId"`
	ProjectID string `json:"projectId"`
}

CreateAssignmentResponse represents the response for creating a queue assignment.

type CreateItemRequest

type CreateItemRequest struct {
	ObjectID   string          `json:"objectId"`
	ObjectType QueueObjectType `json:"objectType"`
	Status     QueueStatus     `json:"status,omitempty"`
}

CreateItemRequest represents the request payload for creating an annotation queue item.

type CreateQueueRequest

type CreateQueueRequest struct {
	Name           string   `json:"name"`
	Description    string   `json:"description,omitempty"`
	ScoreConfigIDs []string `json:"scoreConfigIds"`
}

CreateQueueRequest represents the parameters for creating a new annotation queue.

Name is required. ScoreConfigIDs specify which score configurations are available for annotation within this queue.

type DeleteAssignmentResponse

type DeleteAssignmentResponse struct {
	Success bool `json:"success"`
}

DeleteAssignmentResponse represents the response for deleting a queue assignment.

type DeleteItemResponse

type DeleteItemResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

DeleteItemResponse represents the response for deleting an annotation queue item.

type Item

type Item struct {
	ID          string          `json:"id"`
	QueueID     string          `json:"queueId"`
	ObjectID    string          `json:"objectId"`
	ObjectType  QueueObjectType `json:"objectType"`
	Status      QueueStatus     `json:"status"`
	CompletedAt time.Time       `json:"completedAt,omitempty"`
	CreatedAt   time.Time       `json:"createdAt"`
	UpdatedAt   time.Time       `json:"updatedAt"`
}

Item represents an annotation queue item.

type ItemClient

type ItemClient struct {
	// contains filtered or unexported fields
}

ItemClient represents the annotation queue items API client. ItemClient provides methods for interacting with annotation queue items in Langfuse.

The client handles HTTP communication for item management operations including creating, retrieving, updating, and deleting items within annotation queues.

func NewItemClient

func NewItemClient(cli *resty.Client) *ItemClient

NewItemClient creates a new annotation queue item client with the provided HTTP client.

The resty client should be pre-configured with authentication and base URL.

func (*ItemClient) Create

func (c *ItemClient) Create(ctx context.Context, queueID string, createRequest *CreateItemRequest) (*Item, error)

Create adds an item to an annotation queue.

func (*ItemClient) Delete

func (c *ItemClient) Delete(ctx context.Context, queueID, itemID string) (*DeleteItemResponse, error)

Delete removes an item from an annotation queue.

func (*ItemClient) Get

func (c *ItemClient) Get(ctx context.Context, queueID, itemID string) (*Item, error)

Get retrieves a specific item from an annotation queue.

func (*ItemClient) List

func (c *ItemClient) List(ctx context.Context, queueID string, params ItemListParams) (*ListItems, error)

List retrieves items for a specific annotation queue.

func (*ItemClient) Update

func (c *ItemClient) Update(ctx context.Context, queueID, itemID string, updateRequest *UpdateItemRequest) (*Item, error)

Update updates an annotation queue item.

type ItemListParams

type ItemListParams struct {
	Status QueueStatus
	Page   int
	Limit  int
}

ItemListParams defines the query parameters for listing annotation queue items.

func (*ItemListParams) ToQueryString

func (query *ItemListParams) ToQueryString() string

ToQueryString converts the ItemListParams to a URL query string.

type ListItems

type ListItems struct {
	Metadata common.ListMetadata `json:"meta"`
	Data     []Item              `json:"data"`
}

ListItems represents the response from listing annotation queue items.

type ListQueues

type ListQueues struct {
	Metadata common.ListMetadata `json:"meta"`
	Data     []Queue             `json:"data"`
}

ListQueues represents the response from listing annotation queues.

type Queue

type Queue struct {
	ID             string    `json:"id"`
	Name           string    `json:"name"`
	Description    string    `json:"description,omitempty"`
	ScoreConfigIDs []string  `json:"scoreConfigIds"`
	CreatedAt      time.Time `json:"createdAt"`
	UpdatedAt      time.Time `json:"updatedAt"`
}

Queue represents an annotation queue for organizing items that need manual annotation.

Annotation queues contain items (traces or observations) that are pending annotation. They can be configured with specific score configurations and assigned to users.

type QueueClient

type QueueClient struct {
	// contains filtered or unexported fields
}

QueueClient provides methods for interacting with annotation queues in Langfuse.

The client handles HTTP communication for queue management operations including creating, retrieving, listing queues, and managing queue assignments.

func NewQueueClient

func NewQueueClient(cli *resty.Client) *QueueClient

NewQueueClient creates a new annotation queue client with the provided HTTP client.

The resty client should be pre-configured with authentication and base URL.

func (*QueueClient) Create

func (c *QueueClient) Create(ctx context.Context, createRequest *CreateQueueRequest) (*Queue, error)

Create creates a new annotation queue.

func (*QueueClient) CreateAssignment

func (c *QueueClient) CreateAssignment(ctx context.Context, queueID string, request *AssignmentRequest) (*CreateAssignmentResponse, error)

CreateAssignment creates an assignment for a user to an annotation queue.

func (*QueueClient) DeleteAssignment

func (c *QueueClient) DeleteAssignment(ctx context.Context, queueID string, request *AssignmentRequest) (*DeleteAssignmentResponse, error)

DeleteAssignment deletes an assignment for a user to an annotation queue.

func (*QueueClient) Get

func (c *QueueClient) Get(ctx context.Context, queueID string) (*Queue, error)

Get retrieves a specific annotation queue by ID.

func (*QueueClient) List

func (c *QueueClient) List(ctx context.Context, params QueueListParams) (*ListQueues, error)

List retrieves a list of annotation queues based on the provided parameters.

type QueueListParams

type QueueListParams struct {
	Page  int
	Limit int
}

QueueListParams defines the query parameters for listing annotation queues.

func (*QueueListParams) ToQueryString

func (query *QueueListParams) ToQueryString() string

ToQueryString converts the QueueListParams to a URL query string.

type QueueObjectType

type QueueObjectType string

QueueObjectType represents the type of object that can be queued for annotation.

Currently supports traces and observations as the object types that can be added to annotation queues.

const (
	ObjectTypeTrace       QueueObjectType = "TRACE"
	ObjectTypeObservation QueueObjectType = "OBSERVATION"
)

type QueueStatus

type QueueStatus string

QueueStatus represents the processing status of an item in an annotation queue.

Items start as PENDING when added to a queue and become COMPLETED when annotation work is finished.

const (
	StatusPending   QueueStatus = "PENDING"
	StatusCompleted QueueStatus = "COMPLETED"
)

type UpdateItemRequest

type UpdateItemRequest struct {
	Status QueueStatus `json:"status,omitempty"`
}

UpdateItemRequest represents the request payload for updating an annotation queue item.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL