Documentation
¶
Overview ¶
Package datasets provides operations for managing Braintrust datasets.
Index ¶
- type API
- func (a *API) Create(ctx context.Context, params CreateParams) (*Dataset, error)
- func (a *API) Delete(ctx context.Context, datasetID string) error
- func (a *API) Fetch(ctx context.Context, datasetID string, cursor string, limit int) (*FetchResponse, error)
- func (a *API) Insert(ctx context.Context, datasetID string, params InsertParams) error
- func (a *API) InsertEvents(ctx context.Context, datasetID string, events []Event) error
- func (a *API) Query(ctx context.Context, params QueryParams) (*QueryResponse, error)
- type CreateParams
- type Dataset
- type Event
- type FetchResponse
- type InsertParams
- type Origin
- type QueryParams
- type QueryResponse
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 (*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) InsertEvents ¶
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.