evaluations

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 21 Imported by: ? modules, 0 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 evaluations manages AI datasets, scorer definitions, and offline experiments through the acknowledged PostHog project API.

Use a personal API key to manage datasets and scorers. An ingestion key with offline_evaluation_ingestion:write can create runs, submit outcomes and close runs using previously saved dataset and scorer version IDs. All network calls take a context and return after acknowledgment. Use errors.As to inspect an APIError or recover the unfinished portion of a BulkError.

The client reads up to 128 MiB for a successful list page and 4 MiB for other responses. If a page exceeds the limit, request a smaller page.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status         int
	Code, Attr     string
	Detail, Errors any
	Response       Fields
	RetryAfter     *time.Duration
	Persistence    Persistence
	Submission     Fields
	// contains filtered or unexported fields
}

APIError retains server details for explicit inspection. Error omits server text, which can include submitted payloads. Submission enables exact creation replay.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) GoString

func (e *APIError) GoString() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

type BooleanConfig

type BooleanConfig struct {
	TrueLabel     *string        `json:"true_label"`
	FalseLabel    *string        `json:"false_label"`
	TrueIsFailure Optional[bool] `json:"true_is_failure"`
}

func (BooleanConfig) Kind

func (BooleanConfig) Kind() string

func (BooleanConfig) MarshalJSON

func (c BooleanConfig) MarshalJSON() ([]byte, error)

type BulkError

type BulkError struct {
	Completed      BulkReceipt
	FailedIndex    int
	PendingResults []Result
	FailedChunk    []byte
	Err            error
}

BulkError includes the failed chunk in PendingResults even if the server may already have committed it. Unwrap exposes the underlying API or context error.

func (*BulkError) Error

func (e *BulkError) Error() string

func (*BulkError) GoString

func (e *BulkError) GoString() string

func (*BulkError) Unwrap

func (e *BulkError) Unwrap() error

type BulkReceipt

type BulkReceipt struct{ Chunks []UploadReceipt }

type CategoricalConfig

type CategoricalConfig struct {
	Options       []CategoryOption              `json:"options"`
	SelectionMode string                        `json:"selection_mode"`
	MinSelections Optional[int]                 `json:"min_selections"`
	MaxSelections Optional[int]                 `json:"max_selections"`
	PassingRule   Optional[CategoryPassingRule] `json:"passing_rule"`
}

func (CategoricalConfig) Kind

func (CategoricalConfig) Kind() string

func (CategoricalConfig) MarshalJSON

func (c CategoricalConfig) MarshalJSON() ([]byte, error)

type CategoryOption

type CategoryOption struct {
	Key   string `json:"key"`
	Label string `json:"label"`
}

type CategoryPassingRule

type CategoryPassingRule struct {
	Categories []string `json:"categories"`
}

type Client

type Client struct {
	Datasets Datasets
	Scorers  Scorers
	// contains filtered or unexported fields
}
Example

Pin the dataset and scorer versions before executing cases. The caller supplies the application and evaluator; each acknowledged result links back to the exact dataset item version that produced it.

package main

import (
	"context"
	"fmt"
	"log"
	"os"
	"strings"

	"github.com/posthog/posthog-go/v2/ai/evaluations"
)

func main() {
	client, err := evaluations.NewClient(evaluations.Config{
		ProjectID: 42,
		SecretKey: os.Getenv("POSTHOG_PERSONAL_API_KEY"),
	})
	if err != nil {
		log.Print(err)
		return
	}
	defer client.Close()

	ctx := context.Background()
	snapshot, err := client.Datasets.Snapshot(ctx, os.Getenv("DATASET_ID"), nil)
	if err != nil {
		log.Print(err)
		return
	}
	scorer, err := client.Scorers.Get(ctx, os.Getenv("BOOLEAN_SCORER_ID"))
	if err != nil {
		log.Print(err)
		return
	}
	run, err := client.CreateExperiment(ctx, evaluations.Fields{
		"name": "Text normalization", "dataset_revision_id": snapshot.RevisionID(),
	})
	if err != nil {
		log.Print(err)
		return
	}
	err = snapshot.ForEach(ctx, 25, func(row evaluations.DatasetItem) error {
		input, inputOK := row.Input.(string)
		expected, expectedOK := row.ExpectedOutput.(string)
		if !inputOK || !expectedOK {
			return fmt.Errorf("dataset item %s requires text input and expected output", row.ID)
		}
		output := strings.TrimSpace(input)
		item, err := evaluations.ItemFromDataset(row, evaluations.Fields{"output": output})
		if err != nil {
			return err
		}
		result, err := evaluations.NewResult(item, scorer.CurrentVersionID, evaluations.Fields{"value": output == expected})
		if err != nil {
			return err
		}
		_, err = run.UploadResult(ctx, result)
		return err
	})
	if err != nil {
		log.Printf("Experiment %s is still open: %v", run.ID(), err)
		return
	}
	if _, err := run.Complete(ctx); err != nil {
		log.Print(err)
	}
}

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient configures project-scoped dataset, scorer, and experiment operations. It validates the configuration locally. Call Close to release its resources.

func (*Client) Close

func (c *Client) Close()

Close cancels in-flight requests and releases owned HTTP connections.

func (*Client) CreateExperiment

func (c *Client) CreateExperiment(ctx context.Context, fields Fields) (*Experiment, error)

CreateExperiment acknowledges a named run. Optional properties include id, started_at, run_source, expected_item_count, expected_result_count, suite_key, dataset_source, dataset_identifier, dataset_revision_identifier, dataset_revision_id, application_version, model_version and prompt_version. When reloading a saved submission into Fields, use json.Decoder.UseNumber to preserve integer counts above the safe float64 range.

func (*Client) ResumeExperiment

func (c *Client) ResumeExperiment(id string) (*Experiment, error)

ResumeExperiment opens a local handle to an existing run ID. The next request checks whether the run exists and the caller can access it.

type Composition

type Composition struct {
	Expression string             `json:"expression"`
	Inputs     []CompositionInput `json:"inputs"`
}

type CompositionInput

type CompositionInput struct {
	Alias           string `json:"alias"`
	ScorerVersionID string `json:"scorer_version_id"`
}

type Config

type Config struct {
	ProjectID  int
	SecretKey  string
	Host       string
	Timeout    time.Duration
	MaxRetries *int
	Transport  http.RoundTripper
}

Config configures one project. Timeout defaults to 15 seconds per attempt. MaxRetries defaults to three additional attempts. Set it to a pointer to zero to disable retries. Host may include a reverse-proxy path prefix. Use HTTPS for remote hosts. An explicit HTTP host sends the secret key in cleartext.

type CreateScorerOptions

type CreateScorerOptions struct {
	Calculation string
	Composition *Composition
	Description Optional[string]
	Tags        []string
}

CreateScorerOptions adds metadata and, for a composite scorer, its formula and pinned input versions. Calculation defaults to "reported".

func (CreateScorerOptions) MarshalJSON

func (o CreateScorerOptions) MarshalJSON() ([]byte, error)

type CreateVersionOptions

type CreateVersionOptions struct {
	BaseVersion *int
	Name        *string
	Description Optional[string]
	Composition *Composition
}

CreateVersionOptions can update metadata with the version. Set BaseVersion to the observed version number to reject a concurrent change.

func (CreateVersionOptions) MarshalJSON

func (o CreateVersionOptions) MarshalJSON() ([]byte, error)

type Dataset

type Dataset struct {
	DatasetAudit
	ID                string     `json:"id"`
	Name              string     `json:"name"`
	Description       string     `json:"description"`
	Metadata          Fields     `json:"metadata"`
	Tags              []string   `json:"tags"`
	Archived          bool       `json:"archived"`
	CurrentRevision   *int       `json:"current_revision"`
	CurrentRevisionID *string    `json:"current_revision_id"`
	UpdatedAt         *time.Time `json:"updated_at"`
}

type DatasetAudit

type DatasetAudit struct {
	TeamID    int       `json:"team_id"`
	CreatedAt time.Time `json:"created_at"`
	CreatedBy Fields    `json:"created_by"`
}

type DatasetItem

type DatasetItem struct {
	DatasetAudit
	ID                string     `json:"id"`
	DatasetID         string     `json:"dataset"`
	ClientItemID      *string    `json:"client_item_id"`
	Version           int        `json:"version"`
	VersionID         string     `json:"version_id"`
	DatasetRevision   int        `json:"dataset_revision"`
	DatasetRevisionID string     `json:"dataset_revision_id"`
	Archived          bool       `json:"archived"`
	Input             any        `json:"input"`
	ExpectedOutput    any        `json:"expected_output"`
	SourceOutput      any        `json:"source_output"`
	Metadata          Fields     `json:"metadata"`
	SourceTraceID     *string    `json:"source_trace_id"`
	SourceEventID     *string    `json:"source_event_id"`
	SourceTimestamp   *time.Time `json:"source_timestamp"`
	UpdatedAt         *time.Time `json:"updated_at"`
	VersionCreatedAt  time.Time  `json:"version_created_at"`
	VersionCreatedBy  Fields     `json:"version_created_by"`
}

type DatasetRevision

type DatasetRevision struct {
	DatasetAudit
	ID        string `json:"id"`
	DatasetID string `json:"dataset_id"`
	Revision  int    `json:"revision"`
}

type DatasetSnapshot

type DatasetSnapshot struct {
	Dataset Dataset
	// contains filtered or unexported fields
}

DatasetSnapshot pins item iteration to one revision. Dataset is the metadata observed when the snapshot was opened and may be edited locally.

func (*DatasetSnapshot) ForEach

func (s *DatasetSnapshot) ForEach(ctx context.Context, pageSize int, visit func(DatasetItem) error) error

ForEach fetches active item versions one page at a time. Returning an error from visit stops iteration. Each call starts again at the same pinned revision.

func (*DatasetSnapshot) Revision

func (s *DatasetSnapshot) Revision() int

func (*DatasetSnapshot) RevisionID

func (s *DatasetSnapshot) RevisionID() string

type Datasets

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

Datasets manages reusable cases and their immutable versions.

func (Datasets) Archive

func (d Datasets) Archive(ctx context.Context, id string) (Dataset, error)

Archive moves a dataset out of active listings and retains its history.

func (Datasets) ArchiveItem

func (d Datasets) ArchiveItem(ctx context.Context, id string, baseVersion int) (DatasetItem, error)

ArchiveItem archives the case if baseVersion is still current.

func (Datasets) Create

func (d Datasets) Create(ctx context.Context, fields Fields) (Dataset, error)

Create requires name and accepts description, metadata and tags.

func (Datasets) CreateItem

func (d Datasets) CreateItem(ctx context.Context, datasetID string, fields Fields) (DatasetItem, error)

CreateItem requires non-null input. It accepts expected_output, source_output, metadata, client_item_id, source_trace_id, source_event_id and source_timestamp. Supply a stable client_item_id to enable safe retries of this write.

func (Datasets) Get

func (d Datasets) Get(ctx context.Context, id string) (Dataset, error)

Get retrieves dataset metadata, including the current revision when one exists.

func (Datasets) GetItem

func (d Datasets) GetItem(ctx context.Context, id string, revision *int) (DatasetItem, error)

GetItem retrieves the case at a dataset revision. Use nil for its latest state.

func (Datasets) List

func (d Datasets) List(ctx context.Context, options ListOptions) (Page[Dataset], error)

List returns one page of datasets, ordered by creation time by default.

func (Datasets) ListItemVersions

func (d Datasets) ListItemVersions(ctx context.Context, id string, options PageOptions) (Page[DatasetItem], error)

ListItemVersions returns one page of historical versions for an individual case.

func (Datasets) ListItems

func (d Datasets) ListItems(ctx context.Context, id string, options ItemListOptions) (Page[DatasetItem], error)

ListItems returns one page of up to 25 cases from the selected dataset revision.

func (Datasets) ListRevisions

func (d Datasets) ListRevisions(ctx context.Context, id string, options PageOptions) (Page[DatasetRevision], error)

ListRevisions returns one page of the dataset's revision history.

func (Datasets) Restore

func (d Datasets) Restore(ctx context.Context, id string) (Dataset, error)

Restore makes an archived dataset active again.

func (Datasets) RestoreItem

func (d Datasets) RestoreItem(ctx context.Context, id string, baseVersion int, sourceVersion *int) (DatasetItem, error)

RestoreItem restores a case at its observed baseVersion. Supply sourceVersion to restore the content of a specific historical item version.

func (Datasets) Snapshot

func (d Datasets) Snapshot(ctx context.Context, id string, revision *int) (*DatasetSnapshot, error)

Snapshot pins a dataset revision for repeatable iteration. A nil revision selects the current revision when the snapshot is opened.

func (Datasets) Update

func (d Datasets) Update(ctx context.Context, id string, fields Fields) (Dataset, error)

Update replaces supplied metadata fields without advancing the dataset revision.

func (Datasets) UpdateItem

func (d Datasets) UpdateItem(ctx context.Context, id string, baseVersion int, fields Fields) (DatasetItem, error)

UpdateItem replaces supplied input, expected_output and metadata fields using the observed item version as a concurrency guard.

type Experiment

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

Experiment serializes operations on this handle, including multi-request uploads.

func (*Experiment) Complete

func (e *Experiment) Complete(ctx context.Context) (ExperimentReceipt, error)

Complete marks the run complete after the service verifies any expected counts. Individual cases can have failed scores in a completed run.

func (*Experiment) DeleteItem

func (e *Experiment) DeleteItem(ctx context.Context, id string, revision int64) error

DeleteItem removes the item, its scores, and their payloads at the observed revision.

func (*Experiment) DeleteItemPayload

func (e *Experiment) DeleteItemPayload(ctx context.Context, id string, revision int64) error

DeleteItemPayload removes stored item content and retains the item and its scores.

func (*Experiment) DeleteResult

func (e *Experiment) DeleteResult(ctx context.Context, id string, revision int64) error

DeleteResult removes the reported result, its payload, and dependent composite results.

func (*Experiment) DeleteResultPayload

func (e *Experiment) DeleteResultPayload(ctx context.Context, id string, revision int64) error

DeleteResultPayload removes stored result content and retains the score.

func (*Experiment) Fail

Fail marks the run failed and retains items and results already accepted.

func (*Experiment) GetItemRevision

func (e *Experiment) GetItemRevision(ctx context.Context, id string) (int64, error)

GetItemRevision reads the concurrency token for the item's next edit or deletion.

func (*Experiment) GetResultRevision

func (e *Experiment) GetResultRevision(ctx context.Context, id string) (int64, error)

GetResultRevision reads the concurrency token for the result's next edit or deletion.

func (*Experiment) GetTags

func (e *Experiment) GetTags(ctx context.Context) ([]string, error)

GetTags reads the current tags from the service.

func (*Experiment) ID

func (e *Experiment) ID() string

func (*Experiment) Receipt

func (e *Experiment) Receipt() *ExperimentReceipt

Receipt returns a detached copy of the last creation or lifecycle acknowledgment.

func (*Experiment) SetTags

func (e *Experiment) SetTags(ctx context.Context, tags []string) ([]string, error)

SetTags replaces all experiment tags. Pass an empty slice to clear them.

func (*Experiment) Submission

func (e *Experiment) Submission() Fields

Submission returns a detached copy of the original creation fields for replay. A locally resumed handle has no creation submission.

func (*Experiment) UpdateItem

func (e *Experiment) UpdateItem(ctx context.Context, id string, revision int64, changes Fields) (int64, error)

UpdateItem corrects case_key, trial, model_version or application_trace_id. An explicit nil clears a field.

func (*Experiment) UpdateItemPayload

func (e *Experiment) UpdateItemPayload(ctx context.Context, id string, revision int64, payload Fields) (int64, error)

UpdateItemPayload replaces the supplied input, output, expected_output, or metadata fields and returns the new revision. Omitted fields keep their values. A nil field value writes JSON null. Pass Fields{} to keep existing fields or create an empty payload within the retention window. A nil map is invalid. The patch and merged payload must each fit in 1 MiB of encoded JSON.

func (*Experiment) UpdateResult

func (e *Experiment) UpdateResult(ctx context.Context, id string, revision int64, changes Fields) (int64, error)

UpdateResult corrects the supplied status, value and/or error_code.

func (*Experiment) UpdateResultPayload

func (e *Experiment) UpdateResultPayload(ctx context.Context, id string, revision int64, payload Fields) (int64, error)

UpdateResultPayload replaces the supplied reasoning, error_message, or metadata fields and returns the new revision. Omitted fields keep their values. A nil field value writes JSON null. Pass Fields{} to keep existing fields or create an empty payload within the retention window. A nil map is invalid. The patch and merged payload must each fit in 256 KiB of encoded JSON.

func (*Experiment) UploadResult

func (e *Experiment) UploadResult(ctx context.Context, result Result) (UploadReceipt, error)

UploadResult submits one result and its attached item, if any, and waits for acknowledgment. Use UploadResults to send a composite with its inputs.

func (*Experiment) UploadResults

func (e *Experiment) UploadResults(ctx context.Context, input []Result) (BulkReceipt, error)

UploadResults validates the complete sequence before sending the first chunk. A composite and its supplied inputs stay together. Supply all pinned inputs when using an ingestion key. A BulkError contains independently replayable work.

type ExperimentReceipt

type ExperimentReceipt struct {
	ID                  string     `json:"id"`
	Status              string     `json:"status"`
	Created             bool       `json:"created"`
	StartedAt           time.Time  `json:"started_at"`
	CreatedAt           time.Time  `json:"created_at"`
	FinishedAt          *time.Time `json:"finished_at"`
	ExpectedItemCount   *int64     `json:"expected_item_count"`
	ExpectedResultCount *int64     `json:"expected_result_count"`
	AcceptedItemCount   int64      `json:"accepted_item_count"`
	AcceptedResultCount int64      `json:"accepted_result_count"`
}

type Fields

type Fields = map[string]any

Fields contains wire-format (snake_case) properties. A missing key omits the property. A present nil value sends JSON null. Returned JSON numbers use json.Number so integers in dataset content and saved declarations stay exact.

type Item

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

Item is an immutable execution declaration or a reference to an accepted execution.

func ItemFromDataset

func ItemFromDataset(row DatasetItem, fields Fields) (Item, error)

ItemFromDataset creates a fresh execution. Optional fields are output, id, case_key, trial, model_version and application_trace_id.

func ItemReference

func ItemReference(id string) (Item, error)

ItemReference refers to a previously accepted item without redeclaring its content.

func NewItem

func NewItem(fields Fields) (Item, error)

NewItem snapshots a declaration, generating its UUID if omitted. Supply payload fields individually or under "payload". Model and provenance fields use the wire names model_version, case_key, trial, application_trace_id, dataset_item_identifier, dataset_item_version_identifier, and dataset_item_version_id.

func RestoreItem

func RestoreItem(data []byte) (Item, error)

func (Item) ID

func (i Item) ID() string

func (Item) MarshalJSON

func (i Item) MarshalJSON() ([]byte, error)

MarshalJSON returns the declaration to save separately from its results.

type ItemListOptions

type ItemListOptions struct {
	PageOptions
	Revision *int
	Archived bool
}

ItemListOptions selects active or archived items at a dataset revision. A nil Revision reads the latest state.

type ItemReceipt

type ItemReceipt struct {
	ID         string    `json:"id"`
	Created    bool      `json:"created"`
	AcceptedAt time.Time `json:"accepted_at"`
}

type ListOptions

type ListOptions struct {
	PageOptions
	Search, OrderBy string
	Archived        bool
	Tags            []string
	TagMatch        string
}

ListOptions filters a dataset or scorer listing. Archived selects archived records. TagMatch accepts "any" (the default) or "all".

type NumericConfig

type NumericConfig struct {
	Min         Optional[float64]            `json:"min"`
	Max         Optional[float64]            `json:"max"`
	Step        Optional[float64]            `json:"step"`
	PassingRule Optional[NumericPassingRule] `json:"passing_rule"`
}

func (NumericConfig) Kind

func (NumericConfig) Kind() string

func (NumericConfig) MarshalJSON

func (c NumericConfig) MarshalJSON() ([]byte, error)

type NumericPassingRule

type NumericPassingRule struct {
	Operator  string  `json:"operator"`
	Threshold float64 `json:"threshold"`
}

type Optional

type Optional[T any] struct {
	Present bool
	Value   *T
}

Optional distinguishes an omitted property (zero value), explicit null, and a supplied value, including false or zero. A standalone JSON value cannot express omission, so an unset Optional marshals as null. Enclosing SDK configs and options omit unset properties when marshaling. For a custom JSON object, omit the key when Present is false.

func Null

func Null[T any]() Optional[T]

func Value

func Value[T any](v T) Optional[T]

func (Optional[T]) MarshalJSON

func (o Optional[T]) MarshalJSON() ([]byte, error)

func (*Optional[T]) UnmarshalJSON

func (o *Optional[T]) UnmarshalJSON(b []byte) error

type Page

type Page[T any] struct {
	Count          int64
	Results        []T
	NextOffset     *int
	Next, Previous *string
}

type PageOptions

type PageOptions struct{ Limit, Offset int }

PageOptions selects one page by limit and offset. A zero limit uses the endpoint's default. Use the returned NextOffset to fetch the next page.

type Persistence

type Persistence string
const (
	NotSent  Persistence = "not_sent"
	Rejected Persistence = "rejected"
	Unknown  Persistence = "unknown"
)

type Result

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

Result is an immutable reported outcome or request for a server-calculated score.

func NewResult

func NewResult(item Item, scorerVersionID string, fields Fields) (Result, error)

NewResult accepts status (default "ok"), value, error_code, evaluated_at, evaluator_trace_id and payload, or calculate=true for a composite scorer.

func RestoreResult

func RestoreResult(data []byte, attached *Item) (Result, error)

RestoreResult optionally reattaches the independently saved item declaration.

func (Result) ItemID

func (r Result) ItemID() string

func (Result) MarshalJSON

func (r Result) MarshalJSON() ([]byte, error)

func (Result) ScorerVersionID

func (r Result) ScorerVersionID() string

type ResultReceipt

type ResultReceipt struct {
	ItemReceipt
	ItemID          string  `json:"item_id"`
	ScorerVersionID string  `json:"scorer_version_id"`
	Status          *string `json:"status"`
	ErrorCode       *string `json:"error_code"`
}

type Scorer

type Scorer struct {
	Scoring
	ID                      string        `json:"id"`
	Name                    string        `json:"name"`
	Description             string        `json:"description"`
	Archived                bool          `json:"archived"`
	Tags                    []string      `json:"tags"`
	CurrentVersion          int           `json:"current_version"`
	CurrentVersionID        string        `json:"current_version_id"`
	Team                    int           `json:"team"`
	CreatedAt               time.Time     `json:"created_at"`
	UpdatedAt               time.Time     `json:"updated_at"`
	CreatedBy               Fields        `json:"created_by"`
	InputScorers            []ScorerInput `json:"input_scorers"`
	DependentCompositeCount int           `json:"dependent_composite_count"`
}

type ScorerConfig

type ScorerConfig interface {
	Kind() string
	json.Marshaler
}

ScorerConfig pins one of the three supported output kinds.

type ScorerInput

type ScorerInput struct {
	Alias           string       `json:"alias"`
	ScorerVersionID string       `json:"scorer_version_id"`
	DefinitionID    string       `json:"definition_id"`
	Name            string       `json:"name"`
	Kind            string       `json:"kind"`
	Config          ScorerConfig `json:"config"`
	Version         int          `json:"version"`
	LatestVersionID *string      `json:"latest_version_id"`
	LatestVersion   *int         `json:"latest_version"`
}

type ScorerListOptions

type ScorerListOptions struct {
	ListOptions
	Kind, Calculation, InputDefinitionID string
}

ScorerListOptions filters definitions by output kind, calculation, or input definition.

type ScorerVersion

type ScorerVersion struct {
	Scoring
	ID           string    `json:"id"`
	DefinitionID string    `json:"definition_id"`
	Version      int       `json:"version"`
	CreatedAt    time.Time `json:"created_at"`
	CreatedBy    Fields    `json:"created_by"`
}

type ScorerVersionPage

type ScorerVersionPage struct {
	Count      int64
	Results    []ScorerVersion
	NextCursor *string
}

type Scorers

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

func (Scorers) Create

func (s Scorers) Create(ctx context.Context, name string, config ScorerConfig, options CreateScorerOptions) (Scorer, error)

Create creates a scorer definition and its first version. Use the returned CurrentVersionID when reporting a result or pinning a composite input.

func (Scorers) CreateVersion

func (s Scorers) CreateVersion(ctx context.Context, id string, config ScorerConfig, options CreateVersionOptions) (Scorer, error)

CreateVersion appends an immutable configuration version and returns the updated definition. Existing results keep their original scorer version.

func (Scorers) Get

func (s Scorers) Get(ctx context.Context, id string) (Scorer, error)

Get retrieves a definition and its current scorer version.

func (Scorers) GetVersion

func (s Scorers) GetVersion(ctx context.Context, id, versionID string) (ScorerVersion, error)

GetVersion retrieves an immutable version by its definition ID and version UUID.

func (Scorers) List

func (s Scorers) List(ctx context.Context, options ScorerListOptions) (Page[Scorer], error)

List returns one page of matching scorer definitions.

func (Scorers) ListVersions

func (s Scorers) ListVersions(ctx context.Context, id string, options VersionListOptions) (ScorerVersionPage, error)

ListVersions returns one cursor-paginated page of a definition's versions.

func (Scorers) Update

func (s Scorers) Update(ctx context.Context, id string, fields Fields) (Scorer, error)

Update replaces the supplied metadata fields name, description, archived and tags.

func (Scorers) ValidateComposition

func (s Scorers) ValidateComposition(ctx context.Context, kind string, composition Composition, config ScorerConfig) (bool, error)

ValidateComposition checks a formula with read access. Pass nil config to validate its syntax and types without an output configuration.

type Scoring

type Scoring struct {
	Kind        string       `json:"kind"`
	Config      ScorerConfig `json:"config"`
	Calculation string       `json:"calculation"`
	Composition *Composition `json:"composition"`
}

type UploadReceipt

type UploadReceipt struct {
	Items   []ItemReceipt
	Results []ResultReceipt
}

type VersionListOptions

type VersionListOptions struct {
	Limit  int
	Cursor string
}

VersionListOptions selects a page of scorer versions. Use the previous page's NextCursor to continue.

Jump to

Keyboard shortcuts

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