datasets

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 5 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package datasets provides operations for managing Braintrust datasets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

API provides methods for interacting with datasets.

func New

func New(client *https.Client) *API

New creates a new datasets API client.

func (*API) Create

func (a *API) Create(ctx context.Context, params CreateParams) (*Dataset, error)

Create creates a new dataset.

func (*API) Delete

func (a *API) Delete(ctx context.Context, datasetID string) error

Delete deletes a dataset.

func (*API) Fetch

func (a *API) Fetch(ctx context.Context, datasetID string, cursor string, limit int) (*FetchResponse, error)

Fetch retrieves a single page of events from a dataset with optional cursor pagination.

func (*API) Insert

func (a *API) Insert(ctx context.Context, datasetID string, params InsertParams) error

Insert inserts events into a dataset.

func (*API) InsertEvents

func (a *API) InsertEvents(ctx context.Context, datasetID string, events []Event) error

InsertEvents is a convenience function that inserts events into a dataset. It wraps the events in InsertParams for you.

func (*API) Query

func (a *API) Query(ctx context.Context, params QueryParams) (*QueryResponse, error)

Query searches for datasets by name, version, or other criteria.

type CreateParams

type CreateParams struct {
	ProjectID   string                 `json:"project_id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

CreateParams contains parameters for creating a dataset.

type Dataset

type Dataset struct {
	ID          string                 `json:"id"`
	ProjectID   string                 `json:"project_id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description,omitempty"`
	Metadata    map[string]interface{} `json:"metadata,omitempty"`
}

Dataset represents a dataset resource from the Braintrust API.

type Event

type Event struct {
	// Core data fields
	ID       string      `json:"id,omitempty"`
	Input    interface{} `json:"input,omitempty"`
	Expected interface{} `json:"expected,omitempty"`
	Metadata interface{} `json:"metadata,omitempty"`
	Tags     []string    `json:"tags,omitempty"`

	// System fields (returned by API, typically not set on insert)
	XactID        string `json:"_xact_id,omitempty"`
	Created       string `json:"created,omitempty"`
	PaginationKey string `json:"_pagination_key,omitempty"`
	ProjectID     string `json:"project_id,omitempty"`
	DatasetID     string `json:"dataset_id,omitempty"`

	// Tracing fields
	SpanID      string   `json:"span_id,omitempty"`
	RootSpanID  string   `json:"root_span_id,omitempty"`
	SpanParents []string `json:"span_parents,omitempty"`
	IsRoot      *bool    `json:"is_root,omitempty"`
	ParentID    string   `json:"_parent_id,omitempty"` // Deprecated
	Origin      *Origin  `json:"origin,omitempty"`

	// Merge and deletion controls (for insert)
	IsMerge      *bool      `json:"_is_merge,omitempty"`
	MergePaths   [][]string `json:"_merge_paths,omitempty"`
	ObjectDelete *bool      `json:"_object_delete,omitempty"`
}

Event represents a single event/record in a dataset. Events contain input data, optional expected output, and metadata.

type FetchResponse

type FetchResponse struct {
	Events []json.RawMessage `json:"events"`
	Cursor string            `json:"cursor"`
}

FetchResponse represents a paginated response from the fetch endpoint.

type InsertParams

type InsertParams struct {
	Events []Event `json:"events"`
}

InsertParams contains parameters for inserting events into a dataset.

type Origin

type Origin struct {
	ObjectType string `json:"object_type,omitempty"`
	ObjectID   string `json:"object_id,omitempty"`
	ID         string `json:"id,omitempty"`
	Created    string `json:"created,omitempty"`
	XactID     string `json:"_xact_id,omitempty"`
}

Origin indicates the event was copied from another object. When an eval result is linked to a dataset row, the origin contains the dataset ID and the specific record ID, timestamp, and transaction ID.

type QueryParams

type QueryParams struct {
	// ID filters by dataset ID
	ID string

	// Name filters by dataset name (requires ProjectName or ProjectID)
	Name string

	// Version filters by dataset version
	Version string

	// ProjectID filters by project ID
	ProjectID string

	// ProjectName filters by project name
	ProjectName string

	// Limit limits the number of datasets returned
	Limit int

	// StartingAfter is a cursor for pagination (forward)
	StartingAfter string

	// EndingBefore is a cursor for pagination (backward)
	EndingBefore string
}

QueryParams contains parameters for querying datasets.

type QueryResponse

type QueryResponse struct {
	Objects []Dataset `json:"objects"`
}

QueryResponse represents the response from querying datasets.

Jump to

Keyboard shortcuts

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