Documentation ¶
Index ¶
- func Bool(value bool) param.Field[bool]
- func F[T any](value T) param.Field[T]
- func Float(value float64) param.Field[float64]
- func Int(value int64) param.Field[int64]
- func Null[T any]() param.Field[T]
- func Raw[T any](value any) param.Field[T]
- func String(value string) param.Field[string]
- type Client
- type Dataset
- type DatasetFeedbackParams
- type DatasetFeedbackParamsFeedback
- type DatasetFeedbackParamsFeedbackSource
- type DatasetFetchParams
- type DatasetFetchPostParams
- type DatasetFetchPostParamsFilter
- type DatasetFetchPostParamsFiltersType
- type DatasetFetchPostResponse
- type DatasetFetchPostResponseEvent
- type DatasetFetchResponse
- type DatasetFetchResponseEvent
- type DatasetInsertParams
- type DatasetInsertParamsEvent
- type DatasetInsertParamsEventsInsertDatasetEventMerge
- type DatasetInsertParamsEventsInsertDatasetEventReplace
- type DatasetInsertResponse
- type DatasetListParams
- type DatasetNewParams
- type DatasetReplaceParams
- type DatasetService
- func (r *DatasetService) Delete(ctx context.Context, datasetID string, opts ...option.RequestOption) (res *Dataset, err error)
- func (r *DatasetService) Feedback(ctx context.Context, datasetID string, body DatasetFeedbackParams, ...) (err error)
- func (r *DatasetService) Fetch(ctx context.Context, datasetID string, query DatasetFetchParams, ...) (res *DatasetFetchResponse, err error)
- func (r *DatasetService) FetchPost(ctx context.Context, datasetID string, body DatasetFetchPostParams, ...) (res *DatasetFetchPostResponse, err error)
- func (r *DatasetService) Get(ctx context.Context, datasetID string, opts ...option.RequestOption) (res *Dataset, err error)
- func (r *DatasetService) Insert(ctx context.Context, datasetID string, body DatasetInsertParams, ...) (res *DatasetInsertResponse, err error)
- func (r *DatasetService) List(ctx context.Context, query DatasetListParams, opts ...option.RequestOption) (res *shared.ListObjects[Dataset], err error)
- func (r *DatasetService) ListAutoPaging(ctx context.Context, query DatasetListParams, opts ...option.RequestOption) *shared.ListObjectsAutoPager[Dataset]
- func (r *DatasetService) New(ctx context.Context, body DatasetNewParams, opts ...option.RequestOption) (res *Dataset, err error)
- func (r *DatasetService) Replace(ctx context.Context, body DatasetReplaceParams, opts ...option.RequestOption) (res *Dataset, err error)
- func (r *DatasetService) Update(ctx context.Context, datasetID string, body DatasetUpdateParams, ...) (res *Dataset, err error)
- type DatasetUpdateParams
- type Error
- type Experiment
- type ExperimentFeedbackParams
- type ExperimentFeedbackParamsFeedback
- type ExperimentFeedbackParamsFeedbackSource
- type ExperimentFetchParams
- type ExperimentFetchPostParams
- type ExperimentFetchPostParamsFilter
- type ExperimentFetchPostParamsFiltersType
- type ExperimentFetchPostResponse
- type ExperimentFetchPostResponseEvent
- type ExperimentFetchPostResponseEventsContext
- type ExperimentFetchPostResponseEventsMetrics
- type ExperimentFetchPostResponseEventsSpanAttributes
- type ExperimentFetchPostResponseEventsSpanAttributesType
- type ExperimentFetchResponse
- type ExperimentFetchResponseEvent
- type ExperimentFetchResponseEventsContext
- type ExperimentFetchResponseEventsMetrics
- type ExperimentFetchResponseEventsSpanAttributes
- type ExperimentFetchResponseEventsSpanAttributesType
- type ExperimentInsertParams
- type ExperimentInsertParamsEvent
- type ExperimentInsertParamsEventsInsertExperimentEventMerge
- type ExperimentInsertParamsEventsInsertExperimentEventMergeContext
- type ExperimentInsertParamsEventsInsertExperimentEventMergeMetrics
- type ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributes
- type ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesType
- type ExperimentInsertParamsEventsInsertExperimentEventReplace
- type ExperimentInsertParamsEventsInsertExperimentEventReplaceContext
- type ExperimentInsertParamsEventsInsertExperimentEventReplaceMetrics
- type ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributes
- type ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesType
- type ExperimentInsertResponse
- type ExperimentListParams
- type ExperimentNewParams
- type ExperimentNewParamsRepoInfo
- type ExperimentReplaceParams
- type ExperimentReplaceParamsRepoInfo
- type ExperimentRepoInfo
- type ExperimentService
- func (r *ExperimentService) Delete(ctx context.Context, experimentID string, opts ...option.RequestOption) (res *Experiment, err error)
- func (r *ExperimentService) Feedback(ctx context.Context, experimentID string, body ExperimentFeedbackParams, ...) (err error)
- func (r *ExperimentService) Fetch(ctx context.Context, experimentID string, query ExperimentFetchParams, ...) (res *ExperimentFetchResponse, err error)
- func (r *ExperimentService) FetchPost(ctx context.Context, experimentID string, body ExperimentFetchPostParams, ...) (res *ExperimentFetchPostResponse, err error)
- func (r *ExperimentService) Get(ctx context.Context, experimentID string, opts ...option.RequestOption) (res *Experiment, err error)
- func (r *ExperimentService) Insert(ctx context.Context, experimentID string, body ExperimentInsertParams, ...) (res *ExperimentInsertResponse, err error)
- func (r *ExperimentService) List(ctx context.Context, query ExperimentListParams, opts ...option.RequestOption) (res *shared.ListObjects[Experiment], err error)
- func (r *ExperimentService) ListAutoPaging(ctx context.Context, query ExperimentListParams, opts ...option.RequestOption) *shared.ListObjectsAutoPager[Experiment]
- func (r *ExperimentService) New(ctx context.Context, body ExperimentNewParams, opts ...option.RequestOption) (res *Experiment, err error)
- func (r *ExperimentService) Replace(ctx context.Context, body ExperimentReplaceParams, ...) (res *Experiment, err error)
- func (r *ExperimentService) Update(ctx context.Context, experimentID string, body ExperimentUpdateParams, ...) (res *Experiment, err error)
- type ExperimentUpdateParams
- type ExperimentUpdateParamsRepoInfo
- type Project
- type ProjectListParams
- type ProjectLogFeedbackParams
- type ProjectLogFeedbackParamsFeedback
- type ProjectLogFeedbackParamsFeedbackSource
- type ProjectLogFetchParams
- type ProjectLogFetchPostParams
- type ProjectLogFetchPostParamsFilter
- type ProjectLogFetchPostParamsFiltersType
- type ProjectLogFetchPostResponse
- type ProjectLogFetchPostResponseEvent
- type ProjectLogFetchPostResponseEventsContext
- type ProjectLogFetchPostResponseEventsLogID
- type ProjectLogFetchPostResponseEventsMetrics
- type ProjectLogFetchPostResponseEventsSpanAttributes
- type ProjectLogFetchPostResponseEventsSpanAttributesType
- type ProjectLogFetchResponse
- type ProjectLogFetchResponseEvent
- type ProjectLogFetchResponseEventsContext
- type ProjectLogFetchResponseEventsLogID
- type ProjectLogFetchResponseEventsMetrics
- type ProjectLogFetchResponseEventsSpanAttributes
- type ProjectLogFetchResponseEventsSpanAttributesType
- type ProjectLogInsertParams
- type ProjectLogInsertParamsEvent
- type ProjectLogInsertParamsEventsInsertProjectLogsEventMerge
- type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeContext
- type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeMetrics
- type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributes
- type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesType
- type ProjectLogInsertParamsEventsInsertProjectLogsEventReplace
- type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceContext
- type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceMetrics
- type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributes
- type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesType
- type ProjectLogInsertResponse
- type ProjectLogService
- func (r *ProjectLogService) Feedback(ctx context.Context, projectID string, body ProjectLogFeedbackParams, ...) (err error)
- func (r *ProjectLogService) Fetch(ctx context.Context, projectID string, query ProjectLogFetchParams, ...) (res *ProjectLogFetchResponse, err error)
- func (r *ProjectLogService) FetchPost(ctx context.Context, projectID string, body ProjectLogFetchPostParams, ...) (res *ProjectLogFetchPostResponse, err error)
- func (r *ProjectLogService) Insert(ctx context.Context, projectID string, body ProjectLogInsertParams, ...) (res *ProjectLogInsertResponse, err error)
- type ProjectNewParams
- type ProjectReplaceParams
- type ProjectService
- func (r *ProjectService) Delete(ctx context.Context, projectID string, opts ...option.RequestOption) (res *Project, err error)
- func (r *ProjectService) Get(ctx context.Context, projectID string, opts ...option.RequestOption) (res *Project, err error)
- func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) (res *shared.ListObjects[Project], err error)
- func (r *ProjectService) ListAutoPaging(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) *shared.ListObjectsAutoPager[Project]
- func (r *ProjectService) New(ctx context.Context, body ProjectNewParams, opts ...option.RequestOption) (res *Project, err error)
- func (r *ProjectService) Replace(ctx context.Context, body ProjectReplaceParams, opts ...option.RequestOption) (res *Project, err error)
- func (r *ProjectService) Update(ctx context.Context, projectID string, body ProjectUpdateParams, ...) (res *Project, err error)
- type ProjectUpdateParams
- type TopLevelService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func F ¶
F is a param field helper used to initialize a param.Field generic struct. This helps specify null, zero values, and overrides, as well as normal values. You can read more about this in our README.
func Int ¶
Int is a param field helper which helps specify integers. This is particularly helpful when specifying integer constants for fields.
func Raw ¶
Raw is a param field helper for specifying values for fields when the type you are looking to send is different from the type that is specified in the SDK. For example, if the type of the field is an integer, but you want to send a float, you could do that by setting the corresponding field with Raw[int](0.5).
Types ¶
type Client ¶
type Client struct { Options []option.RequestOption TopLevel *TopLevelService Project *ProjectService Experiment *ExperimentService Dataset *DatasetService }
Client creates a struct with services and top level methods that help with interacting with the braintrust API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r *Client)
NewClient generates a new client with the default option read from the environment (BRAINTRUST_API_KEY). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
type Dataset ¶
type Dataset struct { // Unique identifier for the dataset ID string `json:"id,required" format:"uuid"` // Name of the dataset. Within a project, dataset names are unique Name string `json:"name,required"` // Date of dataset creation Created time.Time `json:"created,nullable" format:"date-time"` // Date of dataset deletion, or null if the dataset is still active DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` // Textual description of the dataset Description string `json:"description,nullable"` // Unique identifier for the project that the dataset belongs under ProjectID string `json:"project_id,nullable" format:"uuid"` // Identifies the user who created the dataset UserID string `json:"user_id,nullable" format:"uuid"` JSON datasetJSON `json:"-"` }
func (*Dataset) UnmarshalJSON ¶
type DatasetFeedbackParams ¶
type DatasetFeedbackParams struct { // A list of dataset feedback items Feedback param.Field[[]DatasetFeedbackParamsFeedback] `json:"feedback,required"` }
func (DatasetFeedbackParams) MarshalJSON ¶
func (r DatasetFeedbackParams) MarshalJSON() (data []byte, err error)
type DatasetFeedbackParamsFeedback ¶
type DatasetFeedbackParamsFeedback struct { // The id of the dataset event to log feedback for. This is the row `id` returned // by `POST /v1/dataset/{dataset_id}/insert` ID param.Field[string] `json:"id,required"` // An optional comment string to log about the dataset event Comment param.Field[string] `json:"comment"` // A dictionary with additional data about the feedback. If you have a `user_id`, // you can log it here and access it in the Braintrust UI. Metadata param.Field[map[string]interface{}] `json:"metadata"` // The source of the feedback. Must be one of "external" (default), "app", or "api" Source param.Field[DatasetFeedbackParamsFeedbackSource] `json:"source"` }
func (DatasetFeedbackParamsFeedback) MarshalJSON ¶
func (r DatasetFeedbackParamsFeedback) MarshalJSON() (data []byte, err error)
type DatasetFeedbackParamsFeedbackSource ¶
type DatasetFeedbackParamsFeedbackSource string
The source of the feedback. Must be one of "external" (default), "app", or "api"
const ( DatasetFeedbackParamsFeedbackSourceApp DatasetFeedbackParamsFeedbackSource = "app" DatasetFeedbackParamsFeedbackSourceAPI DatasetFeedbackParamsFeedbackSource = "api" DatasetFeedbackParamsFeedbackSourceExternal DatasetFeedbackParamsFeedbackSource = "external" )
type DatasetFetchParams ¶
type DatasetFetchParams struct { // Fetch queries may be paginated if the total result size is expected to be large // (e.g. project_logs which accumulate over a long time). Note that fetch queries // only support pagination in descending time order (from latest to earliest // `_xact_id`. Furthermore, later pages may return rows which showed up in earlier // pages, except with an earlier `_xact_id`. This happens because pagination occurs // over the whole version history of the event log. You will most likely want to // exclude any such duplicate, outdated rows (by `id`) from your combined result // set. // // The `limit` parameter controls the number of full traces to return. So you may // end up with more individual rows than the specified limit if you are fetching // events containing traces. Limit param.Field[int64] `query:"limit"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_root_span_id` as the maximum of the `root_span_id` field over all rows. See // the documentation for `limit` for an overview of paginating fetch queries. MaxRootSpanID param.Field[string] `query:"max_root_span_id"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_xact_id` as the maximum of the `_xact_id` field over all rows. See the // documentation for `limit` for an overview of paginating fetch queries. MaxXactID param.Field[int64] `query:"max_xact_id"` // You may specify a version id to retrieve a snapshot of the events from a past // time. The version id is essentially a filter on the latest event transaction id. // You can use the `max_xact_id` returned by a past fetch as the version to // reproduce that exact fetch. Version param.Field[int64] `query:"version"` }
func (DatasetFetchParams) URLQuery ¶
func (r DatasetFetchParams) URLQuery() (v url.Values)
URLQuery serializes DatasetFetchParams's query parameters as `url.Values`.
type DatasetFetchPostParams ¶
type DatasetFetchPostParams struct { // A list of filters on the events to fetch. Currently, only path-lookup type // filters are supported, but we may add more in the future Filters param.Field[[]DatasetFetchPostParamsFilter] `json:"filters"` // Fetch queries may be paginated if the total result size is expected to be large // (e.g. project_logs which accumulate over a long time). Note that fetch queries // only support pagination in descending time order (from latest to earliest // `_xact_id`. Furthermore, later pages may return rows which showed up in earlier // pages, except with an earlier `_xact_id`. This happens because pagination occurs // over the whole version history of the event log. You will most likely want to // exclude any such duplicate, outdated rows (by `id`) from your combined result // set. // // The `limit` parameter controls the number of full traces to return. So you may // end up with more individual rows than the specified limit if you are fetching // events containing traces. Limit param.Field[int64] `json:"limit"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_root_span_id` as the maximum of the `root_span_id` field over all rows. See // the documentation for `limit` for an overview of paginating fetch queries. MaxRootSpanID param.Field[string] `json:"max_root_span_id"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_xact_id` as the maximum of the `_xact_id` field over all rows. See the // documentation for `limit` for an overview of paginating fetch queries. MaxXactID param.Field[int64] `json:"max_xact_id"` // You may specify a version id to retrieve a snapshot of the events from a past // time. The version id is essentially a filter on the latest event transaction id. // You can use the `max_xact_id` returned by a past fetch as the version to // reproduce that exact fetch. Version param.Field[int64] `json:"version"` }
func (DatasetFetchPostParams) MarshalJSON ¶
func (r DatasetFetchPostParams) MarshalJSON() (data []byte, err error)
type DatasetFetchPostParamsFilter ¶
type DatasetFetchPostParamsFilter struct { // List of fields describing the path to the value to be checked against. For // instance, if you wish to filter on the value of `c` in // `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` Path param.Field[[]string] `json:"path,required"` // Denotes the type of filter as a path-lookup filter Type param.Field[DatasetFetchPostParamsFiltersType] `json:"type,required"` // The value to compare equality-wise against the event value at the specified // `path`. The value must be a "primitive", that is, any JSON-serializable object // except for objects and arrays. For instance, if you wish to filter on the value // of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass // `value="hello"` Value param.Field[interface{}] `json:"value"` }
A path-lookup filter describes an equality comparison against a specific sub-field in the event row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"`
func (DatasetFetchPostParamsFilter) MarshalJSON ¶
func (r DatasetFetchPostParamsFilter) MarshalJSON() (data []byte, err error)
type DatasetFetchPostParamsFiltersType ¶
type DatasetFetchPostParamsFiltersType string
Denotes the type of filter as a path-lookup filter
const (
DatasetFetchPostParamsFiltersTypePathLookup DatasetFetchPostParamsFiltersType = "path_lookup"
)
type DatasetFetchPostResponse ¶
type DatasetFetchPostResponse struct { // A list of fetched events Events []DatasetFetchPostResponseEvent `json:"events,required"` JSON datasetFetchPostResponseJSON `json:"-"` }
func (*DatasetFetchPostResponse) UnmarshalJSON ¶
func (r *DatasetFetchPostResponse) UnmarshalJSON(data []byte) (err error)
type DatasetFetchPostResponseEvent ¶
type DatasetFetchPostResponseEvent struct { // A unique identifier for the dataset event. If you don't provide one, BrainTrust // will generate one for you ID string `json:"id,required"` // The transaction id of an event is unique to the network operation that processed // the event insertion. Transaction ids are monotonically increasing over time and // can be used to retrieve a versioned snapshot of the dataset (see the `version` // parameter) XactID int64 `json:"_xact_id,required"` // Unique identifier for the dataset DatasetID string `json:"dataset_id,required" format:"uuid"` // The `span_id` of the root of the trace this dataset event belongs to RootSpanID string `json:"root_span_id,required"` // A unique identifier used to link different dataset events together as part of a // full trace. See the // [tracing guide](https://www.braintrustdata.com/docs/guides/tracing) for full // details on tracing SpanID string `json:"span_id,required"` // The timestamp the dataset event was created Created time.Time `json:"created,nullable" format:"date-time"` // The argument that uniquely define an input case (an arbitrary, JSON serializable // object) Input interface{} `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata map[string]interface{} `json:"metadata,nullable"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object) Output interface{} `json:"output"` // Unique identifier for the project that the dataset belongs under ProjectID string `json:"project_id,nullable" format:"uuid"` JSON datasetFetchPostResponseEventJSON `json:"-"` }
func (*DatasetFetchPostResponseEvent) UnmarshalJSON ¶
func (r *DatasetFetchPostResponseEvent) UnmarshalJSON(data []byte) (err error)
type DatasetFetchResponse ¶
type DatasetFetchResponse struct { // A list of fetched events Events []DatasetFetchResponseEvent `json:"events,required"` JSON datasetFetchResponseJSON `json:"-"` }
func (*DatasetFetchResponse) UnmarshalJSON ¶
func (r *DatasetFetchResponse) UnmarshalJSON(data []byte) (err error)
type DatasetFetchResponseEvent ¶
type DatasetFetchResponseEvent struct { // A unique identifier for the dataset event. If you don't provide one, BrainTrust // will generate one for you ID string `json:"id,required"` // The transaction id of an event is unique to the network operation that processed // the event insertion. Transaction ids are monotonically increasing over time and // can be used to retrieve a versioned snapshot of the dataset (see the `version` // parameter) XactID int64 `json:"_xact_id,required"` // Unique identifier for the dataset DatasetID string `json:"dataset_id,required" format:"uuid"` // The `span_id` of the root of the trace this dataset event belongs to RootSpanID string `json:"root_span_id,required"` // A unique identifier used to link different dataset events together as part of a // full trace. See the // [tracing guide](https://www.braintrustdata.com/docs/guides/tracing) for full // details on tracing SpanID string `json:"span_id,required"` // The timestamp the dataset event was created Created time.Time `json:"created,nullable" format:"date-time"` // The argument that uniquely define an input case (an arbitrary, JSON serializable // object) Input interface{} `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata map[string]interface{} `json:"metadata,nullable"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object) Output interface{} `json:"output"` // Unique identifier for the project that the dataset belongs under ProjectID string `json:"project_id,nullable" format:"uuid"` JSON datasetFetchResponseEventJSON `json:"-"` }
func (*DatasetFetchResponseEvent) UnmarshalJSON ¶
func (r *DatasetFetchResponseEvent) UnmarshalJSON(data []byte) (err error)
type DatasetInsertParams ¶
type DatasetInsertParams struct { // A list of dataset events to insert Events param.Field[[]DatasetInsertParamsEvent] `json:"events,required"` }
func (DatasetInsertParams) MarshalJSON ¶
func (r DatasetInsertParams) MarshalJSON() (data []byte, err error)
type DatasetInsertParamsEvent ¶
type DatasetInsertParamsEvent interface {
// contains filtered or unexported methods
}
Satisfied by DatasetInsertParamsEventsInsertDatasetEventReplace, DatasetInsertParamsEventsInsertDatasetEventMerge.
type DatasetInsertParamsEventsInsertDatasetEventMerge ¶
type DatasetInsertParamsEventsInsertDatasetEventMerge struct { // The `_is_merge` field controls how the row is merged with any existing row with // the same id in the DB. By default (or when set to `false`), the existing row is // completely replaced by the new row. When set to `true`, the new row is // deep-merged into the existing row // // For example, say there is an existing row in the DB // `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as // `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row // will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the // new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be // `{"id": "foo", "input": {"b": 11, "c": 20}}` IsMerge param.Field[bool] `json:"_is_merge,required"` // A unique identifier for the dataset event. If you don't provide one, BrainTrust // will generate one for you ID param.Field[string] `json:"id"` // The `_merge_paths` field allows controlling the depth of the merge. It can only // be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, // where each path is a list of field names. The deep merge will not descend below // any of the specified merge paths. // // For example, say there is an existing row in the DB // `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. // If we merge a new row as // `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, // the new row will be // `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. // In this case, due to the merge paths, we have replaced `input.a` and `output`, // but have still deep-merged `input` and `input.c`. MergePaths param.Field[[][]string] `json:"_merge_paths"` // Pass `_object_delete=true` to mark the dataset event deleted. Deleted events // will not show up in subsequent fetches for this dataset ObjectDelete param.Field[bool] `json:"_object_delete"` // The argument that uniquely define an input case (an arbitrary, JSON serializable // object) Input param.Field[interface{}] `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata param.Field[map[string]interface{}] `json:"metadata"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object) Output param.Field[interface{}] `json:"output"` }
func (DatasetInsertParamsEventsInsertDatasetEventMerge) MarshalJSON ¶
func (r DatasetInsertParamsEventsInsertDatasetEventMerge) MarshalJSON() (data []byte, err error)
type DatasetInsertParamsEventsInsertDatasetEventReplace ¶
type DatasetInsertParamsEventsInsertDatasetEventReplace struct { // A unique identifier for the dataset event. If you don't provide one, BrainTrust // will generate one for you ID param.Field[string] `json:"id"` // The `_is_merge` field controls how the row is merged with any existing row with // the same id in the DB. By default (or when set to `false`), the existing row is // completely replaced by the new row. When set to `true`, the new row is // deep-merged into the existing row // // For example, say there is an existing row in the DB // `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as // `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row // will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the // new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be // `{"id": "foo", "input": {"b": 11, "c": 20}}` IsMerge param.Field[bool] `json:"_is_merge"` // Pass `_object_delete=true` to mark the dataset event deleted. Deleted events // will not show up in subsequent fetches for this dataset ObjectDelete param.Field[bool] `json:"_object_delete"` // Use the `_parent_id` field to create this row as a subspan of an existing row. // It cannot be specified alongside `_is_merge=true`. Tracking hierarchical // relationships are important for tracing (see the // [guide](https://www.braintrustdata.com/docs/guides/tracing) for full details). // // For example, say we have logged a row // `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. // We can create a sub-span of the parent row by logging // `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. // In the webapp, only the root span row `"abc"` will show up in the summary view. // You can view the full trace hierarchy (in this case, the `"llm_call"` row) by // clicking on the "abc" row. ParentID param.Field[string] `json:"_parent_id"` // The argument that uniquely define an input case (an arbitrary, JSON serializable // object) Input param.Field[interface{}] `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata param.Field[map[string]interface{}] `json:"metadata"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object) Output param.Field[interface{}] `json:"output"` }
func (DatasetInsertParamsEventsInsertDatasetEventReplace) MarshalJSON ¶
func (r DatasetInsertParamsEventsInsertDatasetEventReplace) MarshalJSON() (data []byte, err error)
type DatasetInsertResponse ¶
type DatasetInsertResponse struct { // The ids of all rows that were inserted, aligning one-to-one with the rows // provided as input RowIDs []string `json:"row_ids,required"` JSON datasetInsertResponseJSON `json:"-"` }
func (*DatasetInsertResponse) UnmarshalJSON ¶
func (r *DatasetInsertResponse) UnmarshalJSON(data []byte) (err error)
type DatasetListParams ¶
type DatasetListParams struct { // Name of the dataset to search for DatasetName param.Field[string] `query:"dataset_name"` // A cursor for pagination. For example, if the initial item in the last page you // fetched had an id of `foo`, pass `ending_before=foo` to fetch the previous page. // Note: you may only pass one of `starting_after` and `ending_before` EndingBefore param.Field[string] `query:"ending_before" format:"uuid"` // Limit the number of objects to return Limit param.Field[int64] `query:"limit"` // Filter search results to within a particular organization OrgName param.Field[string] `query:"org_name"` // Name of the project to search for ProjectName param.Field[string] `query:"project_name"` // A cursor for pagination. For example, if the final item in the last page you // fetched had an id of `foo`, pass `starting_after=foo` to fetch the next page. // Note: you may only pass one of `starting_after` and `ending_before` StartingAfter param.Field[string] `query:"starting_after" format:"uuid"` }
func (DatasetListParams) URLQuery ¶
func (r DatasetListParams) URLQuery() (v url.Values)
URLQuery serializes DatasetListParams's query parameters as `url.Values`.
type DatasetNewParams ¶
type DatasetNewParams struct { // Name of the dataset. Within a project, dataset names are unique Name param.Field[string] `json:"name,required"` // Textual description of the dataset Description param.Field[string] `json:"description"` // Unique identifier for the project that the dataset belongs under ProjectID param.Field[string] `json:"project_id" format:"uuid"` }
func (DatasetNewParams) MarshalJSON ¶
func (r DatasetNewParams) MarshalJSON() (data []byte, err error)
type DatasetReplaceParams ¶
type DatasetReplaceParams struct { // Name of the dataset. Within a project, dataset names are unique Name param.Field[string] `json:"name,required"` // Textual description of the dataset Description param.Field[string] `json:"description"` // Unique identifier for the project that the dataset belongs under ProjectID param.Field[string] `json:"project_id" format:"uuid"` }
func (DatasetReplaceParams) MarshalJSON ¶
func (r DatasetReplaceParams) MarshalJSON() (data []byte, err error)
type DatasetService ¶
type DatasetService struct {
Options []option.RequestOption
}
DatasetService contains methods and other services that help with interacting with the braintrust API. Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewDatasetService method instead.
func NewDatasetService ¶
func NewDatasetService(opts ...option.RequestOption) (r *DatasetService)
NewDatasetService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*DatasetService) Delete ¶
func (r *DatasetService) Delete(ctx context.Context, datasetID string, opts ...option.RequestOption) (res *Dataset, err error)
Delete a dataset object by its id
func (*DatasetService) Feedback ¶
func (r *DatasetService) Feedback(ctx context.Context, datasetID string, body DatasetFeedbackParams, opts ...option.RequestOption) (err error)
Log feedback for a set of dataset events
func (*DatasetService) Fetch ¶
func (r *DatasetService) Fetch(ctx context.Context, datasetID string, query DatasetFetchParams, opts ...option.RequestOption) (res *DatasetFetchResponse, err error)
Fetch the events in a dataset. Equivalent to the POST form of the same path, but with the parameters in the URL query rather than in the request body
func (*DatasetService) FetchPost ¶
func (r *DatasetService) FetchPost(ctx context.Context, datasetID string, body DatasetFetchPostParams, opts ...option.RequestOption) (res *DatasetFetchPostResponse, err error)
Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the parameters in the request body rather than in the URL query
func (*DatasetService) Get ¶
func (r *DatasetService) Get(ctx context.Context, datasetID string, opts ...option.RequestOption) (res *Dataset, err error)
Get a dataset object by its id
func (*DatasetService) Insert ¶
func (r *DatasetService) Insert(ctx context.Context, datasetID string, body DatasetInsertParams, opts ...option.RequestOption) (res *DatasetInsertResponse, err error)
Insert a set of events into the dataset
func (*DatasetService) List ¶
func (r *DatasetService) List(ctx context.Context, query DatasetListParams, opts ...option.RequestOption) (res *shared.ListObjects[Dataset], err error)
List out all datasets. The datasets are sorted by creation date, with the most recently-created datasets coming first
func (*DatasetService) ListAutoPaging ¶
func (r *DatasetService) ListAutoPaging(ctx context.Context, query DatasetListParams, opts ...option.RequestOption) *shared.ListObjectsAutoPager[Dataset]
List out all datasets. The datasets are sorted by creation date, with the most recently-created datasets coming first
func (*DatasetService) New ¶
func (r *DatasetService) New(ctx context.Context, body DatasetNewParams, opts ...option.RequestOption) (res *Dataset, err error)
Create a new dataset. If there is an existing dataset in the project with the same name as the one specified in the request, will return the existing dataset unmodified
func (*DatasetService) Replace ¶
func (r *DatasetService) Replace(ctx context.Context, body DatasetReplaceParams, opts ...option.RequestOption) (res *Dataset, err error)
Create or replace a new dataset. If there is an existing dataset in the project with the same name as the one specified in the request, will replace the existing dataset with the provided fields
func (*DatasetService) Update ¶
func (r *DatasetService) Update(ctx context.Context, datasetID string, body DatasetUpdateParams, opts ...option.RequestOption) (res *Dataset, err error)
Partially update a dataset object. Specify the fields to update in the payload. Any object-type fields will be deep-merged with existing content. Currently we do not support removing fields or setting them to null. As a workaround, you may retrieve the full object with `GET /dataset/{id}` and then replace it with `PUT /dataset`.
type DatasetUpdateParams ¶
type DatasetUpdateParams struct { // Name of the dataset. Within a project, dataset names are unique Name param.Field[string] `json:"name,required"` // Textual description of the dataset Description param.Field[string] `json:"description"` }
func (DatasetUpdateParams) MarshalJSON ¶
func (r DatasetUpdateParams) MarshalJSON() (data []byte, err error)
type Experiment ¶
type Experiment struct { // Unique identifier for the experiment ID string `json:"id,required" format:"uuid"` // Name of the experiment. Within a project, experiment names are unique Name string `json:"name,required"` // Unique identifier for the project that the experiment belongs under ProjectID string `json:"project_id,required" format:"uuid"` // Whether or not the experiment is public. Public experiments can be viewed by // anybody inside or outside the organization Public bool `json:"public,required"` // Id of default base experiment to compare against when viewing this experiment BaseExpID string `json:"base_exp_id,nullable" format:"uuid"` // Commit, taken directly from `repo_info.commit` Commit string `json:"commit,nullable"` // Date of experiment creation Created time.Time `json:"created,nullable" format:"date-time"` // Identifier of the linked dataset, or null if the experiment is not linked to a // dataset DatasetID string `json:"dataset_id,nullable" format:"uuid"` // Version number of the linked dataset the experiment was run against. This can be // used to reproduce the experiment after the dataset has been modified. DatasetVersion string `json:"dataset_version,nullable"` // Date of experiment deletion, or null if the experiment is still active DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` // Textual description of the experiment Description string `json:"description,nullable"` // User-controlled metadata about the experiment Metadata map[string]interface{} `json:"metadata,nullable"` // Metadata about the state of the repo when the experiment was created RepoInfo ExperimentRepoInfo `json:"repo_info,nullable"` // Identifies the user who created the experiment UserID string `json:"user_id,nullable" format:"uuid"` JSON experimentJSON `json:"-"` }
func (*Experiment) UnmarshalJSON ¶
func (r *Experiment) UnmarshalJSON(data []byte) (err error)
type ExperimentFeedbackParams ¶
type ExperimentFeedbackParams struct { // A list of experiment feedback items Feedback param.Field[[]ExperimentFeedbackParamsFeedback] `json:"feedback,required"` }
func (ExperimentFeedbackParams) MarshalJSON ¶
func (r ExperimentFeedbackParams) MarshalJSON() (data []byte, err error)
type ExperimentFeedbackParamsFeedback ¶
type ExperimentFeedbackParamsFeedback struct { // The id of the experiment event to log feedback for. This is the row `id` // returned by `POST /v1/experiment/{experiment_id}/insert` ID param.Field[string] `json:"id,required"` // An optional comment string to log about the experiment event Comment param.Field[string] `json:"comment"` // The ground truth value (an arbitrary, JSON serializable object) that you'd // compare to `output` to determine if your `output` value is correct or not Expected param.Field[interface{}] `json:"expected"` // A dictionary with additional data about the feedback. If you have a `user_id`, // you can log it here and access it in the Braintrust UI. Metadata param.Field[map[string]interface{}] `json:"metadata"` // A dictionary of numeric values (between 0 and 1) to log. These scores will be // merged into the existing scores for the experiment event Scores param.Field[map[string]float64] `json:"scores"` // The source of the feedback. Must be one of "external" (default), "app", or "api" Source param.Field[ExperimentFeedbackParamsFeedbackSource] `json:"source"` }
func (ExperimentFeedbackParamsFeedback) MarshalJSON ¶
func (r ExperimentFeedbackParamsFeedback) MarshalJSON() (data []byte, err error)
type ExperimentFeedbackParamsFeedbackSource ¶
type ExperimentFeedbackParamsFeedbackSource string
The source of the feedback. Must be one of "external" (default), "app", or "api"
const ( ExperimentFeedbackParamsFeedbackSourceApp ExperimentFeedbackParamsFeedbackSource = "app" ExperimentFeedbackParamsFeedbackSourceAPI ExperimentFeedbackParamsFeedbackSource = "api" ExperimentFeedbackParamsFeedbackSourceExternal ExperimentFeedbackParamsFeedbackSource = "external" )
type ExperimentFetchParams ¶
type ExperimentFetchParams struct { // Fetch queries may be paginated if the total result size is expected to be large // (e.g. project_logs which accumulate over a long time). Note that fetch queries // only support pagination in descending time order (from latest to earliest // `_xact_id`. Furthermore, later pages may return rows which showed up in earlier // pages, except with an earlier `_xact_id`. This happens because pagination occurs // over the whole version history of the event log. You will most likely want to // exclude any such duplicate, outdated rows (by `id`) from your combined result // set. // // The `limit` parameter controls the number of full traces to return. So you may // end up with more individual rows than the specified limit if you are fetching // events containing traces. Limit param.Field[int64] `query:"limit"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_root_span_id` as the maximum of the `root_span_id` field over all rows. See // the documentation for `limit` for an overview of paginating fetch queries. MaxRootSpanID param.Field[string] `query:"max_root_span_id"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_xact_id` as the maximum of the `_xact_id` field over all rows. See the // documentation for `limit` for an overview of paginating fetch queries. MaxXactID param.Field[int64] `query:"max_xact_id"` // You may specify a version id to retrieve a snapshot of the events from a past // time. The version id is essentially a filter on the latest event transaction id. // You can use the `max_xact_id` returned by a past fetch as the version to // reproduce that exact fetch. Version param.Field[int64] `query:"version"` }
func (ExperimentFetchParams) URLQuery ¶
func (r ExperimentFetchParams) URLQuery() (v url.Values)
URLQuery serializes ExperimentFetchParams's query parameters as `url.Values`.
type ExperimentFetchPostParams ¶
type ExperimentFetchPostParams struct { // A list of filters on the events to fetch. Currently, only path-lookup type // filters are supported, but we may add more in the future Filters param.Field[[]ExperimentFetchPostParamsFilter] `json:"filters"` // Fetch queries may be paginated if the total result size is expected to be large // (e.g. project_logs which accumulate over a long time). Note that fetch queries // only support pagination in descending time order (from latest to earliest // `_xact_id`. Furthermore, later pages may return rows which showed up in earlier // pages, except with an earlier `_xact_id`. This happens because pagination occurs // over the whole version history of the event log. You will most likely want to // exclude any such duplicate, outdated rows (by `id`) from your combined result // set. // // The `limit` parameter controls the number of full traces to return. So you may // end up with more individual rows than the specified limit if you are fetching // events containing traces. Limit param.Field[int64] `json:"limit"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_root_span_id` as the maximum of the `root_span_id` field over all rows. See // the documentation for `limit` for an overview of paginating fetch queries. MaxRootSpanID param.Field[string] `json:"max_root_span_id"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_xact_id` as the maximum of the `_xact_id` field over all rows. See the // documentation for `limit` for an overview of paginating fetch queries. MaxXactID param.Field[int64] `json:"max_xact_id"` // You may specify a version id to retrieve a snapshot of the events from a past // time. The version id is essentially a filter on the latest event transaction id. // You can use the `max_xact_id` returned by a past fetch as the version to // reproduce that exact fetch. Version param.Field[int64] `json:"version"` }
func (ExperimentFetchPostParams) MarshalJSON ¶
func (r ExperimentFetchPostParams) MarshalJSON() (data []byte, err error)
type ExperimentFetchPostParamsFilter ¶
type ExperimentFetchPostParamsFilter struct { // List of fields describing the path to the value to be checked against. For // instance, if you wish to filter on the value of `c` in // `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` Path param.Field[[]string] `json:"path,required"` // Denotes the type of filter as a path-lookup filter Type param.Field[ExperimentFetchPostParamsFiltersType] `json:"type,required"` // The value to compare equality-wise against the event value at the specified // `path`. The value must be a "primitive", that is, any JSON-serializable object // except for objects and arrays. For instance, if you wish to filter on the value // of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass // `value="hello"` Value param.Field[interface{}] `json:"value"` }
A path-lookup filter describes an equality comparison against a specific sub-field in the event row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"`
func (ExperimentFetchPostParamsFilter) MarshalJSON ¶
func (r ExperimentFetchPostParamsFilter) MarshalJSON() (data []byte, err error)
type ExperimentFetchPostParamsFiltersType ¶
type ExperimentFetchPostParamsFiltersType string
Denotes the type of filter as a path-lookup filter
const (
ExperimentFetchPostParamsFiltersTypePathLookup ExperimentFetchPostParamsFiltersType = "path_lookup"
)
type ExperimentFetchPostResponse ¶
type ExperimentFetchPostResponse struct { // A list of fetched events Events []ExperimentFetchPostResponseEvent `json:"events,required"` JSON experimentFetchPostResponseJSON `json:"-"` }
func (*ExperimentFetchPostResponse) UnmarshalJSON ¶
func (r *ExperimentFetchPostResponse) UnmarshalJSON(data []byte) (err error)
type ExperimentFetchPostResponseEvent ¶
type ExperimentFetchPostResponseEvent struct { // A unique identifier for the experiment event. If you don't provide one, // BrainTrust will generate one for you ID string `json:"id,required"` // The transaction id of an event is unique to the network operation that processed // the event insertion. Transaction ids are monotonically increasing over time and // can be used to retrieve a versioned snapshot of the experiment (see the // `version` parameter) XactID int64 `json:"_xact_id,required"` // Unique identifier for the experiment ExperimentID string `json:"experiment_id,required" format:"uuid"` // Unique identifier for the project that the experiment belongs under ProjectID string `json:"project_id,required" format:"uuid"` // The `span_id` of the root of the trace this experiment event belongs to RootSpanID string `json:"root_span_id,required"` // A unique identifier used to link different experiment events together as part of // a full trace. See the // [tracing guide](https://www.braintrustdata.com/docs/guides/tracing) for full // details on tracing SpanID string `json:"span_id,required"` // Context is additional information about the code that produced the experiment // event. It is essentially the textual counterpart to `metrics`. Use the // `caller_*` attributes to track the location in code which produced the // experiment event Context ExperimentFetchPostResponseEventsContext `json:"context,nullable"` // The timestamp the experiment event was created Created time.Time `json:"created,nullable" format:"date-time"` // If the experiment is associated to a dataset, this is the event-level dataset id // this experiment event is tied to DatasetRecordID string `json:"dataset_record_id,nullable"` // The ground truth value (an arbitrary, JSON serializable object) that you'd // compare to `output` to determine if your `output` value is correct or not. // Braintrust currently does not compare `output` to `expected` for you, since // there are so many different ways to do that correctly. Instead, these values are // just used to help you navigate your experiments while digging into analyses. // However, we may later use these values to re-score outputs or fine-tune your // models Expected interface{} `json:"expected"` // The arguments that uniquely define a test case (an arbitrary, JSON serializable // object). Later on, Braintrust will use the `input` to know whether two test // cases are the same between experiments, so they should not contain // experiment-specific state. A simple rule of thumb is that if you run the same // experiment twice, the `input` should be identical Input interface{} `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata map[string]interface{} `json:"metadata,nullable"` // Metrics are numerical measurements tracking the execution of the code that // produced the experiment event. Use "start" and "end" to track the time span over // which the experiment event was produced Metrics ExperimentFetchPostResponseEventsMetrics `json:"metrics,nullable"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object), that allows you to determine whether the result is correct // or not. For example, in an app that generates SQL queries, the `output` should // be the _result_ of the SQL query generated by the model, not the query itself, // because there may be multiple valid queries that answer a single question Output interface{} `json:"output"` // A dictionary of numeric values (between 0 and 1) to log. The scores should give // you a variety of signals that help you determine how accurate the outputs are // compared to what you expect and diagnose failures. For example, a summarization // app might have one score that tells you how accurate the summary is, and another // that measures the word similarity between the generated and grouth truth // summary. The word similarity score could help you determine whether the // summarization was covering similar concepts or not. You can use these scores to // help you sort, filter, and compare experiments Scores map[string]float64 `json:"scores,nullable"` // Human-identifying attributes of the span, such as name, type, etc. SpanAttributes ExperimentFetchPostResponseEventsSpanAttributes `json:"span_attributes,nullable"` // An array of the parent `span_ids` of this experiment event. This should be empty // for the root span of a trace, and should most often contain just one parent // element for subspans SpanParents []string `json:"span_parents,nullable"` JSON experimentFetchPostResponseEventJSON `json:"-"` }
func (*ExperimentFetchPostResponseEvent) UnmarshalJSON ¶
func (r *ExperimentFetchPostResponseEvent) UnmarshalJSON(data []byte) (err error)
type ExperimentFetchPostResponseEventsContext ¶
type ExperimentFetchPostResponseEventsContext struct { // Name of the file in code where the experiment event was created CallerFilename string `json:"caller_filename,nullable"` // The function in code which created the experiment event CallerFunctionname string `json:"caller_functionname,nullable"` // Line of code where the experiment event was created CallerLineno int64 `json:"caller_lineno,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON experimentFetchPostResponseEventsContextJSON `json:"-"` }
Context is additional information about the code that produced the experiment event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the location in code which produced the experiment event
func (*ExperimentFetchPostResponseEventsContext) UnmarshalJSON ¶
func (r *ExperimentFetchPostResponseEventsContext) UnmarshalJSON(data []byte) (err error)
type ExperimentFetchPostResponseEventsMetrics ¶
type ExperimentFetchPostResponseEventsMetrics struct { // A unix timestamp recording when the section of code which produced the // experiment event finished End float64 `json:"end,nullable"` // A unix timestamp recording when the section of code which produced the // experiment event started Start float64 `json:"start,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON experimentFetchPostResponseEventsMetricsJSON `json:"-"` }
Metrics are numerical measurements tracking the execution of the code that produced the experiment event. Use "start" and "end" to track the time span over which the experiment event was produced
func (*ExperimentFetchPostResponseEventsMetrics) UnmarshalJSON ¶
func (r *ExperimentFetchPostResponseEventsMetrics) UnmarshalJSON(data []byte) (err error)
type ExperimentFetchPostResponseEventsSpanAttributes ¶
type ExperimentFetchPostResponseEventsSpanAttributes struct { // Name of the span, for display purposes only Name string `json:"name,nullable"` // Type of the span, for display purposes only Type ExperimentFetchPostResponseEventsSpanAttributesType `json:"type,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON experimentFetchPostResponseEventsSpanAttributesJSON `json:"-"` }
Human-identifying attributes of the span, such as name, type, etc.
func (*ExperimentFetchPostResponseEventsSpanAttributes) UnmarshalJSON ¶
func (r *ExperimentFetchPostResponseEventsSpanAttributes) UnmarshalJSON(data []byte) (err error)
type ExperimentFetchPostResponseEventsSpanAttributesType ¶
type ExperimentFetchPostResponseEventsSpanAttributesType string
Type of the span, for display purposes only
const ( ExperimentFetchPostResponseEventsSpanAttributesTypeLlm ExperimentFetchPostResponseEventsSpanAttributesType = "llm" ExperimentFetchPostResponseEventsSpanAttributesTypeScore ExperimentFetchPostResponseEventsSpanAttributesType = "score" ExperimentFetchPostResponseEventsSpanAttributesTypeFunction ExperimentFetchPostResponseEventsSpanAttributesType = "function" ExperimentFetchPostResponseEventsSpanAttributesTypeEval ExperimentFetchPostResponseEventsSpanAttributesType = "eval" ExperimentFetchPostResponseEventsSpanAttributesTypeTask ExperimentFetchPostResponseEventsSpanAttributesType = "task" ExperimentFetchPostResponseEventsSpanAttributesTypeTool ExperimentFetchPostResponseEventsSpanAttributesType = "tool" )
type ExperimentFetchResponse ¶
type ExperimentFetchResponse struct { // A list of fetched events Events []ExperimentFetchResponseEvent `json:"events,required"` JSON experimentFetchResponseJSON `json:"-"` }
func (*ExperimentFetchResponse) UnmarshalJSON ¶
func (r *ExperimentFetchResponse) UnmarshalJSON(data []byte) (err error)
type ExperimentFetchResponseEvent ¶
type ExperimentFetchResponseEvent struct { // A unique identifier for the experiment event. If you don't provide one, // BrainTrust will generate one for you ID string `json:"id,required"` // The transaction id of an event is unique to the network operation that processed // the event insertion. Transaction ids are monotonically increasing over time and // can be used to retrieve a versioned snapshot of the experiment (see the // `version` parameter) XactID int64 `json:"_xact_id,required"` // Unique identifier for the experiment ExperimentID string `json:"experiment_id,required" format:"uuid"` // Unique identifier for the project that the experiment belongs under ProjectID string `json:"project_id,required" format:"uuid"` // The `span_id` of the root of the trace this experiment event belongs to RootSpanID string `json:"root_span_id,required"` // A unique identifier used to link different experiment events together as part of // a full trace. See the // [tracing guide](https://www.braintrustdata.com/docs/guides/tracing) for full // details on tracing SpanID string `json:"span_id,required"` // Context is additional information about the code that produced the experiment // event. It is essentially the textual counterpart to `metrics`. Use the // `caller_*` attributes to track the location in code which produced the // experiment event Context ExperimentFetchResponseEventsContext `json:"context,nullable"` // The timestamp the experiment event was created Created time.Time `json:"created,nullable" format:"date-time"` // If the experiment is associated to a dataset, this is the event-level dataset id // this experiment event is tied to DatasetRecordID string `json:"dataset_record_id,nullable"` // The ground truth value (an arbitrary, JSON serializable object) that you'd // compare to `output` to determine if your `output` value is correct or not. // Braintrust currently does not compare `output` to `expected` for you, since // there are so many different ways to do that correctly. Instead, these values are // just used to help you navigate your experiments while digging into analyses. // However, we may later use these values to re-score outputs or fine-tune your // models Expected interface{} `json:"expected"` // The arguments that uniquely define a test case (an arbitrary, JSON serializable // object). Later on, Braintrust will use the `input` to know whether two test // cases are the same between experiments, so they should not contain // experiment-specific state. A simple rule of thumb is that if you run the same // experiment twice, the `input` should be identical Input interface{} `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata map[string]interface{} `json:"metadata,nullable"` // Metrics are numerical measurements tracking the execution of the code that // produced the experiment event. Use "start" and "end" to track the time span over // which the experiment event was produced Metrics ExperimentFetchResponseEventsMetrics `json:"metrics,nullable"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object), that allows you to determine whether the result is correct // or not. For example, in an app that generates SQL queries, the `output` should // be the _result_ of the SQL query generated by the model, not the query itself, // because there may be multiple valid queries that answer a single question Output interface{} `json:"output"` // A dictionary of numeric values (between 0 and 1) to log. The scores should give // you a variety of signals that help you determine how accurate the outputs are // compared to what you expect and diagnose failures. For example, a summarization // app might have one score that tells you how accurate the summary is, and another // that measures the word similarity between the generated and grouth truth // summary. The word similarity score could help you determine whether the // summarization was covering similar concepts or not. You can use these scores to // help you sort, filter, and compare experiments Scores map[string]float64 `json:"scores,nullable"` // Human-identifying attributes of the span, such as name, type, etc. SpanAttributes ExperimentFetchResponseEventsSpanAttributes `json:"span_attributes,nullable"` // An array of the parent `span_ids` of this experiment event. This should be empty // for the root span of a trace, and should most often contain just one parent // element for subspans SpanParents []string `json:"span_parents,nullable"` JSON experimentFetchResponseEventJSON `json:"-"` }
func (*ExperimentFetchResponseEvent) UnmarshalJSON ¶
func (r *ExperimentFetchResponseEvent) UnmarshalJSON(data []byte) (err error)
type ExperimentFetchResponseEventsContext ¶
type ExperimentFetchResponseEventsContext struct { // Name of the file in code where the experiment event was created CallerFilename string `json:"caller_filename,nullable"` // The function in code which created the experiment event CallerFunctionname string `json:"caller_functionname,nullable"` // Line of code where the experiment event was created CallerLineno int64 `json:"caller_lineno,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON experimentFetchResponseEventsContextJSON `json:"-"` }
Context is additional information about the code that produced the experiment event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the location in code which produced the experiment event
func (*ExperimentFetchResponseEventsContext) UnmarshalJSON ¶
func (r *ExperimentFetchResponseEventsContext) UnmarshalJSON(data []byte) (err error)
type ExperimentFetchResponseEventsMetrics ¶
type ExperimentFetchResponseEventsMetrics struct { // A unix timestamp recording when the section of code which produced the // experiment event finished End float64 `json:"end,nullable"` // A unix timestamp recording when the section of code which produced the // experiment event started Start float64 `json:"start,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON experimentFetchResponseEventsMetricsJSON `json:"-"` }
Metrics are numerical measurements tracking the execution of the code that produced the experiment event. Use "start" and "end" to track the time span over which the experiment event was produced
func (*ExperimentFetchResponseEventsMetrics) UnmarshalJSON ¶
func (r *ExperimentFetchResponseEventsMetrics) UnmarshalJSON(data []byte) (err error)
type ExperimentFetchResponseEventsSpanAttributes ¶
type ExperimentFetchResponseEventsSpanAttributes struct { // Name of the span, for display purposes only Name string `json:"name,nullable"` // Type of the span, for display purposes only Type ExperimentFetchResponseEventsSpanAttributesType `json:"type,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON experimentFetchResponseEventsSpanAttributesJSON `json:"-"` }
Human-identifying attributes of the span, such as name, type, etc.
func (*ExperimentFetchResponseEventsSpanAttributes) UnmarshalJSON ¶
func (r *ExperimentFetchResponseEventsSpanAttributes) UnmarshalJSON(data []byte) (err error)
type ExperimentFetchResponseEventsSpanAttributesType ¶
type ExperimentFetchResponseEventsSpanAttributesType string
Type of the span, for display purposes only
const ( ExperimentFetchResponseEventsSpanAttributesTypeLlm ExperimentFetchResponseEventsSpanAttributesType = "llm" ExperimentFetchResponseEventsSpanAttributesTypeScore ExperimentFetchResponseEventsSpanAttributesType = "score" ExperimentFetchResponseEventsSpanAttributesTypeFunction ExperimentFetchResponseEventsSpanAttributesType = "function" ExperimentFetchResponseEventsSpanAttributesTypeEval ExperimentFetchResponseEventsSpanAttributesType = "eval" ExperimentFetchResponseEventsSpanAttributesTypeTask ExperimentFetchResponseEventsSpanAttributesType = "task" ExperimentFetchResponseEventsSpanAttributesTypeTool ExperimentFetchResponseEventsSpanAttributesType = "tool" )
type ExperimentInsertParams ¶
type ExperimentInsertParams struct { // A list of experiment events to insert Events param.Field[[]ExperimentInsertParamsEvent] `json:"events,required"` }
func (ExperimentInsertParams) MarshalJSON ¶
func (r ExperimentInsertParams) MarshalJSON() (data []byte, err error)
type ExperimentInsertParamsEvent ¶
type ExperimentInsertParamsEvent interface {
// contains filtered or unexported methods
}
Satisfied by ExperimentInsertParamsEventsInsertExperimentEventReplace, ExperimentInsertParamsEventsInsertExperimentEventMerge.
type ExperimentInsertParamsEventsInsertExperimentEventMerge ¶
type ExperimentInsertParamsEventsInsertExperimentEventMerge struct { // The `_is_merge` field controls how the row is merged with any existing row with // the same id in the DB. By default (or when set to `false`), the existing row is // completely replaced by the new row. When set to `true`, the new row is // deep-merged into the existing row // // For example, say there is an existing row in the DB // `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as // `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row // will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the // new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be // `{"id": "foo", "input": {"b": 11, "c": 20}}` IsMerge param.Field[bool] `json:"_is_merge,required"` // A unique identifier for the experiment event. If you don't provide one, // BrainTrust will generate one for you ID param.Field[string] `json:"id"` // The `_merge_paths` field allows controlling the depth of the merge. It can only // be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, // where each path is a list of field names. The deep merge will not descend below // any of the specified merge paths. // // For example, say there is an existing row in the DB // `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. // If we merge a new row as // `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, // the new row will be // `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. // In this case, due to the merge paths, we have replaced `input.a` and `output`, // but have still deep-merged `input` and `input.c`. MergePaths param.Field[[][]string] `json:"_merge_paths"` // Pass `_object_delete=true` to mark the experiment event deleted. Deleted events // will not show up in subsequent fetches for this experiment ObjectDelete param.Field[bool] `json:"_object_delete"` // Context is additional information about the code that produced the experiment // event. It is essentially the textual counterpart to `metrics`. Use the // `caller_*` attributes to track the location in code which produced the // experiment event Context param.Field[ExperimentInsertParamsEventsInsertExperimentEventMergeContext] `json:"context"` // If the experiment is associated to a dataset, this is the event-level dataset id // this experiment event is tied to DatasetRecordID param.Field[string] `json:"dataset_record_id"` // The ground truth value (an arbitrary, JSON serializable object) that you'd // compare to `output` to determine if your `output` value is correct or not. // Braintrust currently does not compare `output` to `expected` for you, since // there are so many different ways to do that correctly. Instead, these values are // just used to help you navigate your experiments while digging into analyses. // However, we may later use these values to re-score outputs or fine-tune your // models Expected param.Field[interface{}] `json:"expected"` // The arguments that uniquely define a test case (an arbitrary, JSON serializable // object). Later on, Braintrust will use the `input` to know whether two test // cases are the same between experiments, so they should not contain // experiment-specific state. A simple rule of thumb is that if you run the same // experiment twice, the `input` should be identical Input param.Field[interface{}] `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata param.Field[map[string]interface{}] `json:"metadata"` // Metrics are numerical measurements tracking the execution of the code that // produced the experiment event. Use "start" and "end" to track the time span over // which the experiment event was produced Metrics param.Field[ExperimentInsertParamsEventsInsertExperimentEventMergeMetrics] `json:"metrics"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object), that allows you to determine whether the result is correct // or not. For example, in an app that generates SQL queries, the `output` should // be the _result_ of the SQL query generated by the model, not the query itself, // because there may be multiple valid queries that answer a single question Output param.Field[interface{}] `json:"output"` // A dictionary of numeric values (between 0 and 1) to log. The scores should give // you a variety of signals that help you determine how accurate the outputs are // compared to what you expect and diagnose failures. For example, a summarization // app might have one score that tells you how accurate the summary is, and another // that measures the word similarity between the generated and grouth truth // summary. The word similarity score could help you determine whether the // summarization was covering similar concepts or not. You can use these scores to // help you sort, filter, and compare experiments Scores param.Field[map[string]float64] `json:"scores"` // Human-identifying attributes of the span, such as name, type, etc. SpanAttributes param.Field[ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributes] `json:"span_attributes"` }
func (ExperimentInsertParamsEventsInsertExperimentEventMerge) MarshalJSON ¶
func (r ExperimentInsertParamsEventsInsertExperimentEventMerge) MarshalJSON() (data []byte, err error)
type ExperimentInsertParamsEventsInsertExperimentEventMergeContext ¶
type ExperimentInsertParamsEventsInsertExperimentEventMergeContext struct { // Name of the file in code where the experiment event was created CallerFilename param.Field[string] `json:"caller_filename"` // The function in code which created the experiment event CallerFunctionname param.Field[string] `json:"caller_functionname"` // Line of code where the experiment event was created CallerLineno param.Field[int64] `json:"caller_lineno"` ExtraFields map[string]interface{} `json:"-,extras"` }
Context is additional information about the code that produced the experiment event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the location in code which produced the experiment event
func (ExperimentInsertParamsEventsInsertExperimentEventMergeContext) MarshalJSON ¶
func (r ExperimentInsertParamsEventsInsertExperimentEventMergeContext) MarshalJSON() (data []byte, err error)
type ExperimentInsertParamsEventsInsertExperimentEventMergeMetrics ¶
type ExperimentInsertParamsEventsInsertExperimentEventMergeMetrics struct { // A unix timestamp recording when the section of code which produced the // experiment event finished End param.Field[float64] `json:"end"` // A unix timestamp recording when the section of code which produced the // experiment event started Start param.Field[float64] `json:"start"` ExtraFields map[string]interface{} `json:"-,extras"` }
Metrics are numerical measurements tracking the execution of the code that produced the experiment event. Use "start" and "end" to track the time span over which the experiment event was produced
func (ExperimentInsertParamsEventsInsertExperimentEventMergeMetrics) MarshalJSON ¶
func (r ExperimentInsertParamsEventsInsertExperimentEventMergeMetrics) MarshalJSON() (data []byte, err error)
type ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributes ¶
type ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributes struct { // Name of the span, for display purposes only Name param.Field[string] `json:"name"` // Type of the span, for display purposes only Type param.Field[ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesType] `json:"type"` ExtraFields map[string]interface{} `json:"-,extras"` }
Human-identifying attributes of the span, such as name, type, etc.
func (ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributes) MarshalJSON ¶
func (r ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributes) MarshalJSON() (data []byte, err error)
type ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesType ¶
type ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesType string
Type of the span, for display purposes only
const ( ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesTypeLlm ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesType = "llm" ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesTypeScore ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesType = "score" ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesTypeFunction ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesType = "function" ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesTypeEval ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesType = "eval" ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesTypeTask ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesType = "task" ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesTypeTool ExperimentInsertParamsEventsInsertExperimentEventMergeSpanAttributesType = "tool" )
type ExperimentInsertParamsEventsInsertExperimentEventReplace ¶
type ExperimentInsertParamsEventsInsertExperimentEventReplace struct { // A unique identifier for the experiment event. If you don't provide one, // BrainTrust will generate one for you ID param.Field[string] `json:"id"` // The `_is_merge` field controls how the row is merged with any existing row with // the same id in the DB. By default (or when set to `false`), the existing row is // completely replaced by the new row. When set to `true`, the new row is // deep-merged into the existing row // // For example, say there is an existing row in the DB // `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as // `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row // will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the // new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be // `{"id": "foo", "input": {"b": 11, "c": 20}}` IsMerge param.Field[bool] `json:"_is_merge"` // Pass `_object_delete=true` to mark the experiment event deleted. Deleted events // will not show up in subsequent fetches for this experiment ObjectDelete param.Field[bool] `json:"_object_delete"` // Use the `_parent_id` field to create this row as a subspan of an existing row. // It cannot be specified alongside `_is_merge=true`. Tracking hierarchical // relationships are important for tracing (see the // [guide](https://www.braintrustdata.com/docs/guides/tracing) for full details). // // For example, say we have logged a row // `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. // We can create a sub-span of the parent row by logging // `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. // In the webapp, only the root span row `"abc"` will show up in the summary view. // You can view the full trace hierarchy (in this case, the `"llm_call"` row) by // clicking on the "abc" row. ParentID param.Field[string] `json:"_parent_id"` // Context is additional information about the code that produced the experiment // event. It is essentially the textual counterpart to `metrics`. Use the // `caller_*` attributes to track the location in code which produced the // experiment event Context param.Field[ExperimentInsertParamsEventsInsertExperimentEventReplaceContext] `json:"context"` // If the experiment is associated to a dataset, this is the event-level dataset id // this experiment event is tied to DatasetRecordID param.Field[string] `json:"dataset_record_id"` // The ground truth value (an arbitrary, JSON serializable object) that you'd // compare to `output` to determine if your `output` value is correct or not. // Braintrust currently does not compare `output` to `expected` for you, since // there are so many different ways to do that correctly. Instead, these values are // just used to help you navigate your experiments while digging into analyses. // However, we may later use these values to re-score outputs or fine-tune your // models Expected param.Field[interface{}] `json:"expected"` // The arguments that uniquely define a test case (an arbitrary, JSON serializable // object). Later on, Braintrust will use the `input` to know whether two test // cases are the same between experiments, so they should not contain // experiment-specific state. A simple rule of thumb is that if you run the same // experiment twice, the `input` should be identical Input param.Field[interface{}] `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata param.Field[map[string]interface{}] `json:"metadata"` // Metrics are numerical measurements tracking the execution of the code that // produced the experiment event. Use "start" and "end" to track the time span over // which the experiment event was produced Metrics param.Field[ExperimentInsertParamsEventsInsertExperimentEventReplaceMetrics] `json:"metrics"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object), that allows you to determine whether the result is correct // or not. For example, in an app that generates SQL queries, the `output` should // be the _result_ of the SQL query generated by the model, not the query itself, // because there may be multiple valid queries that answer a single question Output param.Field[interface{}] `json:"output"` // A dictionary of numeric values (between 0 and 1) to log. The scores should give // you a variety of signals that help you determine how accurate the outputs are // compared to what you expect and diagnose failures. For example, a summarization // app might have one score that tells you how accurate the summary is, and another // that measures the word similarity between the generated and grouth truth // summary. The word similarity score could help you determine whether the // summarization was covering similar concepts or not. You can use these scores to // help you sort, filter, and compare experiments Scores param.Field[map[string]float64] `json:"scores"` // Human-identifying attributes of the span, such as name, type, etc. SpanAttributes param.Field[ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributes] `json:"span_attributes"` }
func (ExperimentInsertParamsEventsInsertExperimentEventReplace) MarshalJSON ¶
func (r ExperimentInsertParamsEventsInsertExperimentEventReplace) MarshalJSON() (data []byte, err error)
type ExperimentInsertParamsEventsInsertExperimentEventReplaceContext ¶
type ExperimentInsertParamsEventsInsertExperimentEventReplaceContext struct { // Name of the file in code where the experiment event was created CallerFilename param.Field[string] `json:"caller_filename"` // The function in code which created the experiment event CallerFunctionname param.Field[string] `json:"caller_functionname"` // Line of code where the experiment event was created CallerLineno param.Field[int64] `json:"caller_lineno"` ExtraFields map[string]interface{} `json:"-,extras"` }
Context is additional information about the code that produced the experiment event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the location in code which produced the experiment event
func (ExperimentInsertParamsEventsInsertExperimentEventReplaceContext) MarshalJSON ¶
func (r ExperimentInsertParamsEventsInsertExperimentEventReplaceContext) MarshalJSON() (data []byte, err error)
type ExperimentInsertParamsEventsInsertExperimentEventReplaceMetrics ¶
type ExperimentInsertParamsEventsInsertExperimentEventReplaceMetrics struct { // A unix timestamp recording when the section of code which produced the // experiment event finished End param.Field[float64] `json:"end"` // A unix timestamp recording when the section of code which produced the // experiment event started Start param.Field[float64] `json:"start"` ExtraFields map[string]interface{} `json:"-,extras"` }
Metrics are numerical measurements tracking the execution of the code that produced the experiment event. Use "start" and "end" to track the time span over which the experiment event was produced
func (ExperimentInsertParamsEventsInsertExperimentEventReplaceMetrics) MarshalJSON ¶
func (r ExperimentInsertParamsEventsInsertExperimentEventReplaceMetrics) MarshalJSON() (data []byte, err error)
type ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributes ¶
type ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributes struct { // Name of the span, for display purposes only Name param.Field[string] `json:"name"` // Type of the span, for display purposes only Type param.Field[ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesType] `json:"type"` ExtraFields map[string]interface{} `json:"-,extras"` }
Human-identifying attributes of the span, such as name, type, etc.
func (ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributes) MarshalJSON ¶
func (r ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributes) MarshalJSON() (data []byte, err error)
type ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesType ¶
type ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesType string
Type of the span, for display purposes only
const ( ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesTypeLlm ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesType = "llm" ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesTypeScore ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesType = "score" ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesTypeFunction ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesType = "function" ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesTypeEval ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesType = "eval" ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesTypeTask ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesType = "task" ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesTypeTool ExperimentInsertParamsEventsInsertExperimentEventReplaceSpanAttributesType = "tool" )
type ExperimentInsertResponse ¶
type ExperimentInsertResponse struct { // The ids of all rows that were inserted, aligning one-to-one with the rows // provided as input RowIDs []string `json:"row_ids,required"` JSON experimentInsertResponseJSON `json:"-"` }
func (*ExperimentInsertResponse) UnmarshalJSON ¶
func (r *ExperimentInsertResponse) UnmarshalJSON(data []byte) (err error)
type ExperimentListParams ¶
type ExperimentListParams struct { // A cursor for pagination. For example, if the initial item in the last page you // fetched had an id of `foo`, pass `ending_before=foo` to fetch the previous page. // Note: you may only pass one of `starting_after` and `ending_before` EndingBefore param.Field[string] `query:"ending_before" format:"uuid"` // Name of the experiment to search for ExperimentName param.Field[string] `query:"experiment_name"` // Limit the number of objects to return Limit param.Field[int64] `query:"limit"` // Filter search results to within a particular organization OrgName param.Field[string] `query:"org_name"` // Name of the project to search for ProjectName param.Field[string] `query:"project_name"` // A cursor for pagination. For example, if the final item in the last page you // fetched had an id of `foo`, pass `starting_after=foo` to fetch the next page. // Note: you may only pass one of `starting_after` and `ending_before` StartingAfter param.Field[string] `query:"starting_after" format:"uuid"` }
func (ExperimentListParams) URLQuery ¶
func (r ExperimentListParams) URLQuery() (v url.Values)
URLQuery serializes ExperimentListParams's query parameters as `url.Values`.
type ExperimentNewParams ¶
type ExperimentNewParams struct { // Unique identifier for the project that the experiment belongs under ProjectID param.Field[string] `json:"project_id,required" format:"uuid"` // Id of default base experiment to compare against when viewing this experiment BaseExpID param.Field[string] `json:"base_exp_id" format:"uuid"` // Identifier of the linked dataset, or null if the experiment is not linked to a // dataset DatasetID param.Field[string] `json:"dataset_id" format:"uuid"` // Version number of the linked dataset the experiment was run against. This can be // used to reproduce the experiment after the dataset has been modified. DatasetVersion param.Field[string] `json:"dataset_version"` // Textual description of the experiment Description param.Field[string] `json:"description"` // User-controlled metadata about the experiment Metadata param.Field[map[string]interface{}] `json:"metadata"` // Name of the experiment. Within a project, experiment names are unique Name param.Field[string] `json:"name"` // Whether or not the experiment is public. Public experiments can be viewed by // anybody inside or outside the organization Public param.Field[bool] `json:"public"` // Metadata about the state of the repo when the experiment was created RepoInfo param.Field[ExperimentNewParamsRepoInfo] `json:"repo_info"` }
func (ExperimentNewParams) MarshalJSON ¶
func (r ExperimentNewParams) MarshalJSON() (data []byte, err error)
type ExperimentNewParamsRepoInfo ¶
type ExperimentNewParamsRepoInfo struct { // Email of the author of the most recent commit AuthorEmail param.Field[string] `json:"author_email"` // Name of the author of the most recent commit AuthorName param.Field[string] `json:"author_name"` // Name of the branch the most recent commit belongs to Branch param.Field[string] `json:"branch"` // SHA of most recent commit Commit param.Field[string] `json:"commit"` // Most recent commit message CommitMessage param.Field[string] `json:"commit_message"` // Time of the most recent commit CommitTime param.Field[string] `json:"commit_time"` // Whether or not the repo had uncommitted changes when snapshotted Dirty param.Field[bool] `json:"dirty"` // If the repo was dirty when run, this includes the diff between the current state // of the repo and the most recent commit. GitDiff param.Field[string] `json:"git_diff"` // Name of the tag on the most recent commit Tag param.Field[string] `json:"tag"` }
Metadata about the state of the repo when the experiment was created
func (ExperimentNewParamsRepoInfo) MarshalJSON ¶
func (r ExperimentNewParamsRepoInfo) MarshalJSON() (data []byte, err error)
type ExperimentReplaceParams ¶
type ExperimentReplaceParams struct { // Unique identifier for the project that the experiment belongs under ProjectID param.Field[string] `json:"project_id,required" format:"uuid"` // Id of default base experiment to compare against when viewing this experiment BaseExpID param.Field[string] `json:"base_exp_id" format:"uuid"` // Identifier of the linked dataset, or null if the experiment is not linked to a // dataset DatasetID param.Field[string] `json:"dataset_id" format:"uuid"` // Version number of the linked dataset the experiment was run against. This can be // used to reproduce the experiment after the dataset has been modified. DatasetVersion param.Field[string] `json:"dataset_version"` // Textual description of the experiment Description param.Field[string] `json:"description"` // User-controlled metadata about the experiment Metadata param.Field[map[string]interface{}] `json:"metadata"` // Name of the experiment. Within a project, experiment names are unique Name param.Field[string] `json:"name"` // Whether or not the experiment is public. Public experiments can be viewed by // anybody inside or outside the organization Public param.Field[bool] `json:"public"` // Metadata about the state of the repo when the experiment was created RepoInfo param.Field[ExperimentReplaceParamsRepoInfo] `json:"repo_info"` }
func (ExperimentReplaceParams) MarshalJSON ¶
func (r ExperimentReplaceParams) MarshalJSON() (data []byte, err error)
type ExperimentReplaceParamsRepoInfo ¶
type ExperimentReplaceParamsRepoInfo struct { // Email of the author of the most recent commit AuthorEmail param.Field[string] `json:"author_email"` // Name of the author of the most recent commit AuthorName param.Field[string] `json:"author_name"` // Name of the branch the most recent commit belongs to Branch param.Field[string] `json:"branch"` // SHA of most recent commit Commit param.Field[string] `json:"commit"` // Most recent commit message CommitMessage param.Field[string] `json:"commit_message"` // Time of the most recent commit CommitTime param.Field[string] `json:"commit_time"` // Whether or not the repo had uncommitted changes when snapshotted Dirty param.Field[bool] `json:"dirty"` // If the repo was dirty when run, this includes the diff between the current state // of the repo and the most recent commit. GitDiff param.Field[string] `json:"git_diff"` // Name of the tag on the most recent commit Tag param.Field[string] `json:"tag"` }
Metadata about the state of the repo when the experiment was created
func (ExperimentReplaceParamsRepoInfo) MarshalJSON ¶
func (r ExperimentReplaceParamsRepoInfo) MarshalJSON() (data []byte, err error)
type ExperimentRepoInfo ¶
type ExperimentRepoInfo struct { // Email of the author of the most recent commit AuthorEmail string `json:"author_email,nullable"` // Name of the author of the most recent commit AuthorName string `json:"author_name,nullable"` // Name of the branch the most recent commit belongs to Branch string `json:"branch,nullable"` // SHA of most recent commit Commit string `json:"commit,nullable"` // Most recent commit message CommitMessage string `json:"commit_message,nullable"` // Time of the most recent commit CommitTime string `json:"commit_time,nullable"` // Whether or not the repo had uncommitted changes when snapshotted Dirty bool `json:"dirty,nullable"` // If the repo was dirty when run, this includes the diff between the current state // of the repo and the most recent commit. GitDiff string `json:"git_diff,nullable"` // Name of the tag on the most recent commit Tag string `json:"tag,nullable"` JSON experimentRepoInfoJSON `json:"-"` }
Metadata about the state of the repo when the experiment was created
func (*ExperimentRepoInfo) UnmarshalJSON ¶
func (r *ExperimentRepoInfo) UnmarshalJSON(data []byte) (err error)
type ExperimentService ¶
type ExperimentService struct {
Options []option.RequestOption
}
ExperimentService contains methods and other services that help with interacting with the braintrust API. Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewExperimentService method instead.
func NewExperimentService ¶
func NewExperimentService(opts ...option.RequestOption) (r *ExperimentService)
NewExperimentService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*ExperimentService) Delete ¶
func (r *ExperimentService) Delete(ctx context.Context, experimentID string, opts ...option.RequestOption) (res *Experiment, err error)
Delete an experiment object by its id
func (*ExperimentService) Feedback ¶
func (r *ExperimentService) Feedback(ctx context.Context, experimentID string, body ExperimentFeedbackParams, opts ...option.RequestOption) (err error)
Log feedback for a set of experiment events
func (*ExperimentService) Fetch ¶
func (r *ExperimentService) Fetch(ctx context.Context, experimentID string, query ExperimentFetchParams, opts ...option.RequestOption) (res *ExperimentFetchResponse, err error)
Fetch the events in an experiment. Equivalent to the POST form of the same path, but with the parameters in the URL query rather than in the request body
func (*ExperimentService) FetchPost ¶
func (r *ExperimentService) FetchPost(ctx context.Context, experimentID string, body ExperimentFetchPostParams, opts ...option.RequestOption) (res *ExperimentFetchPostResponse, err error)
Fetch the events in an experiment. Equivalent to the GET form of the same path, but with the parameters in the request body rather than in the URL query
func (*ExperimentService) Get ¶
func (r *ExperimentService) Get(ctx context.Context, experimentID string, opts ...option.RequestOption) (res *Experiment, err error)
Get an experiment object by its id
func (*ExperimentService) Insert ¶
func (r *ExperimentService) Insert(ctx context.Context, experimentID string, body ExperimentInsertParams, opts ...option.RequestOption) (res *ExperimentInsertResponse, err error)
Insert a set of events into the experiment
func (*ExperimentService) List ¶
func (r *ExperimentService) List(ctx context.Context, query ExperimentListParams, opts ...option.RequestOption) (res *shared.ListObjects[Experiment], err error)
List out all experiments. The experiments are sorted by creation date, with the most recently-created experiments coming first
func (*ExperimentService) ListAutoPaging ¶
func (r *ExperimentService) ListAutoPaging(ctx context.Context, query ExperimentListParams, opts ...option.RequestOption) *shared.ListObjectsAutoPager[Experiment]
List out all experiments. The experiments are sorted by creation date, with the most recently-created experiments coming first
func (*ExperimentService) New ¶
func (r *ExperimentService) New(ctx context.Context, body ExperimentNewParams, opts ...option.RequestOption) (res *Experiment, err error)
Create a new experiment. If there is an existing experiment in the project with the same name as the one specified in the request, will create a new experiment from `name`, suffixed with a unique identifier
func (*ExperimentService) Replace ¶
func (r *ExperimentService) Replace(ctx context.Context, body ExperimentReplaceParams, opts ...option.RequestOption) (res *Experiment, err error)
Create or replace a new experiment. If there is an existing experiment in the project with the same name as the one specified in the request, will replace the existing experiment with the provided fields
func (*ExperimentService) Update ¶
func (r *ExperimentService) Update(ctx context.Context, experimentID string, body ExperimentUpdateParams, opts ...option.RequestOption) (res *Experiment, err error)
Partially update an experiment object. Specify the fields to update in the payload. Any object-type fields will be deep-merged with existing content. Currently we do not support removing fields or setting them to null. As a workaround, you may retrieve the full object with `GET /experiment/{id}` and then replace it with `PUT /experiment`.
type ExperimentUpdateParams ¶
type ExperimentUpdateParams struct { // Id of default base experiment to compare against when viewing this experiment BaseExpID param.Field[string] `json:"base_exp_id" format:"uuid"` // Identifier of the linked dataset, or null if the experiment is not linked to a // dataset DatasetID param.Field[string] `json:"dataset_id" format:"uuid"` // Version number of the linked dataset the experiment was run against. This can be // used to reproduce the experiment after the dataset has been modified. DatasetVersion param.Field[string] `json:"dataset_version"` // Textual description of the experiment Description param.Field[string] `json:"description"` // User-controlled metadata about the experiment Metadata param.Field[map[string]interface{}] `json:"metadata"` // Name of the experiment. Within a project, experiment names are unique Name param.Field[string] `json:"name"` // Whether or not the experiment is public. Public experiments can be viewed by // anybody inside or outside the organization Public param.Field[bool] `json:"public"` // Metadata about the state of the repo when the experiment was created RepoInfo param.Field[ExperimentUpdateParamsRepoInfo] `json:"repo_info"` }
func (ExperimentUpdateParams) MarshalJSON ¶
func (r ExperimentUpdateParams) MarshalJSON() (data []byte, err error)
type ExperimentUpdateParamsRepoInfo ¶
type ExperimentUpdateParamsRepoInfo struct { // Email of the author of the most recent commit AuthorEmail param.Field[string] `json:"author_email"` // Name of the author of the most recent commit AuthorName param.Field[string] `json:"author_name"` // Name of the branch the most recent commit belongs to Branch param.Field[string] `json:"branch"` // SHA of most recent commit Commit param.Field[string] `json:"commit"` // Most recent commit message CommitMessage param.Field[string] `json:"commit_message"` // Time of the most recent commit CommitTime param.Field[string] `json:"commit_time"` // Whether or not the repo had uncommitted changes when snapshotted Dirty param.Field[bool] `json:"dirty"` // If the repo was dirty when run, this includes the diff between the current state // of the repo and the most recent commit. GitDiff param.Field[string] `json:"git_diff"` // Name of the tag on the most recent commit Tag param.Field[string] `json:"tag"` }
Metadata about the state of the repo when the experiment was created
func (ExperimentUpdateParamsRepoInfo) MarshalJSON ¶
func (r ExperimentUpdateParamsRepoInfo) MarshalJSON() (data []byte, err error)
type Project ¶
type Project struct { // Unique identifier for the project ID string `json:"id,required" format:"uuid"` // Name of the project Name string `json:"name,required"` // Unique id for the organization that the project belongs under OrgID string `json:"org_id,required" format:"uuid"` // Date of project creation Created time.Time `json:"created,nullable" format:"date-time"` // Date of project deletion, or null if the project is still active DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` // Identifies the user who created the project UserID string `json:"user_id,nullable" format:"uuid"` JSON projectJSON `json:"-"` }
func (*Project) UnmarshalJSON ¶
type ProjectListParams ¶
type ProjectListParams struct { // A cursor for pagination. For example, if the initial item in the last page you // fetched had an id of `foo`, pass `ending_before=foo` to fetch the previous page. // Note: you may only pass one of `starting_after` and `ending_before` EndingBefore param.Field[string] `query:"ending_before" format:"uuid"` // Limit the number of objects to return Limit param.Field[int64] `query:"limit"` // Filter search results to within a particular organization OrgName param.Field[string] `query:"org_name"` // Name of the project to search for ProjectName param.Field[string] `query:"project_name"` // A cursor for pagination. For example, if the final item in the last page you // fetched had an id of `foo`, pass `starting_after=foo` to fetch the next page. // Note: you may only pass one of `starting_after` and `ending_before` StartingAfter param.Field[string] `query:"starting_after" format:"uuid"` }
func (ProjectListParams) URLQuery ¶
func (r ProjectListParams) URLQuery() (v url.Values)
URLQuery serializes ProjectListParams's query parameters as `url.Values`.
type ProjectLogFeedbackParams ¶
type ProjectLogFeedbackParams struct { // A list of project logs feedback items Feedback param.Field[[]ProjectLogFeedbackParamsFeedback] `json:"feedback,required"` }
func (ProjectLogFeedbackParams) MarshalJSON ¶
func (r ProjectLogFeedbackParams) MarshalJSON() (data []byte, err error)
type ProjectLogFeedbackParamsFeedback ¶
type ProjectLogFeedbackParamsFeedback struct { // The id of the project logs event to log feedback for. This is the row `id` // returned by `POST /v1/project_logs/{project_id}/insert` ID param.Field[string] `json:"id,required"` // An optional comment string to log about the project logs event Comment param.Field[string] `json:"comment"` // The ground truth value (an arbitrary, JSON serializable object) that you'd // compare to `output` to determine if your `output` value is correct or not Expected param.Field[interface{}] `json:"expected"` // A dictionary with additional data about the feedback. If you have a `user_id`, // you can log it here and access it in the Braintrust UI. Metadata param.Field[map[string]interface{}] `json:"metadata"` // A dictionary of numeric values (between 0 and 1) to log. These scores will be // merged into the existing scores for the project logs event Scores param.Field[map[string]float64] `json:"scores"` // The source of the feedback. Must be one of "external" (default), "app", or "api" Source param.Field[ProjectLogFeedbackParamsFeedbackSource] `json:"source"` }
func (ProjectLogFeedbackParamsFeedback) MarshalJSON ¶
func (r ProjectLogFeedbackParamsFeedback) MarshalJSON() (data []byte, err error)
type ProjectLogFeedbackParamsFeedbackSource ¶
type ProjectLogFeedbackParamsFeedbackSource string
The source of the feedback. Must be one of "external" (default), "app", or "api"
const ( ProjectLogFeedbackParamsFeedbackSourceApp ProjectLogFeedbackParamsFeedbackSource = "app" ProjectLogFeedbackParamsFeedbackSourceAPI ProjectLogFeedbackParamsFeedbackSource = "api" ProjectLogFeedbackParamsFeedbackSourceExternal ProjectLogFeedbackParamsFeedbackSource = "external" )
type ProjectLogFetchParams ¶
type ProjectLogFetchParams struct { // Fetch queries may be paginated if the total result size is expected to be large // (e.g. project_logs which accumulate over a long time). Note that fetch queries // only support pagination in descending time order (from latest to earliest // `_xact_id`. Furthermore, later pages may return rows which showed up in earlier // pages, except with an earlier `_xact_id`. This happens because pagination occurs // over the whole version history of the event log. You will most likely want to // exclude any such duplicate, outdated rows (by `id`) from your combined result // set. // // The `limit` parameter controls the number of full traces to return. So you may // end up with more individual rows than the specified limit if you are fetching // events containing traces. Limit param.Field[int64] `query:"limit"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_root_span_id` as the maximum of the `root_span_id` field over all rows. See // the documentation for `limit` for an overview of paginating fetch queries. MaxRootSpanID param.Field[string] `query:"max_root_span_id"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_xact_id` as the maximum of the `_xact_id` field over all rows. See the // documentation for `limit` for an overview of paginating fetch queries. MaxXactID param.Field[int64] `query:"max_xact_id"` // You may specify a version id to retrieve a snapshot of the events from a past // time. The version id is essentially a filter on the latest event transaction id. // You can use the `max_xact_id` returned by a past fetch as the version to // reproduce that exact fetch. Version param.Field[int64] `query:"version"` }
func (ProjectLogFetchParams) URLQuery ¶
func (r ProjectLogFetchParams) URLQuery() (v url.Values)
URLQuery serializes ProjectLogFetchParams's query parameters as `url.Values`.
type ProjectLogFetchPostParams ¶
type ProjectLogFetchPostParams struct { // A list of filters on the events to fetch. Currently, only path-lookup type // filters are supported, but we may add more in the future Filters param.Field[[]ProjectLogFetchPostParamsFilter] `json:"filters"` // Fetch queries may be paginated if the total result size is expected to be large // (e.g. project_logs which accumulate over a long time). Note that fetch queries // only support pagination in descending time order (from latest to earliest // `_xact_id`. Furthermore, later pages may return rows which showed up in earlier // pages, except with an earlier `_xact_id`. This happens because pagination occurs // over the whole version history of the event log. You will most likely want to // exclude any such duplicate, outdated rows (by `id`) from your combined result // set. // // The `limit` parameter controls the number of full traces to return. So you may // end up with more individual rows than the specified limit if you are fetching // events containing traces. Limit param.Field[int64] `json:"limit"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_root_span_id` as the maximum of the `root_span_id` field over all rows. See // the documentation for `limit` for an overview of paginating fetch queries. MaxRootSpanID param.Field[string] `json:"max_root_span_id"` // Together, `max_xact_id` and `max_root_span_id` form a cursor for paginating // event fetches. Given a previous fetch with a list of rows, you can determine // `max_xact_id` as the maximum of the `_xact_id` field over all rows. See the // documentation for `limit` for an overview of paginating fetch queries. MaxXactID param.Field[int64] `json:"max_xact_id"` // You may specify a version id to retrieve a snapshot of the events from a past // time. The version id is essentially a filter on the latest event transaction id. // You can use the `max_xact_id` returned by a past fetch as the version to // reproduce that exact fetch. Version param.Field[int64] `json:"version"` }
func (ProjectLogFetchPostParams) MarshalJSON ¶
func (r ProjectLogFetchPostParams) MarshalJSON() (data []byte, err error)
type ProjectLogFetchPostParamsFilter ¶
type ProjectLogFetchPostParamsFilter struct { // List of fields describing the path to the value to be checked against. For // instance, if you wish to filter on the value of `c` in // `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` Path param.Field[[]string] `json:"path,required"` // Denotes the type of filter as a path-lookup filter Type param.Field[ProjectLogFetchPostParamsFiltersType] `json:"type,required"` // The value to compare equality-wise against the event value at the specified // `path`. The value must be a "primitive", that is, any JSON-serializable object // except for objects and arrays. For instance, if you wish to filter on the value // of "input.a.b.c" in the object `{"input": {"a": {"b": {"c": "hello"}}}}`, pass // `value="hello"` Value param.Field[interface{}] `json:"value"` }
A path-lookup filter describes an equality comparison against a specific sub-field in the event row. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]` and `value="hello"`
func (ProjectLogFetchPostParamsFilter) MarshalJSON ¶
func (r ProjectLogFetchPostParamsFilter) MarshalJSON() (data []byte, err error)
type ProjectLogFetchPostParamsFiltersType ¶
type ProjectLogFetchPostParamsFiltersType string
Denotes the type of filter as a path-lookup filter
const (
ProjectLogFetchPostParamsFiltersTypePathLookup ProjectLogFetchPostParamsFiltersType = "path_lookup"
)
type ProjectLogFetchPostResponse ¶
type ProjectLogFetchPostResponse struct { // A list of fetched events Events []ProjectLogFetchPostResponseEvent `json:"events,required"` JSON projectLogFetchPostResponseJSON `json:"-"` }
func (*ProjectLogFetchPostResponse) UnmarshalJSON ¶
func (r *ProjectLogFetchPostResponse) UnmarshalJSON(data []byte) (err error)
type ProjectLogFetchPostResponseEvent ¶
type ProjectLogFetchPostResponseEvent struct { // A unique identifier for the project logs event. If you don't provide one, // BrainTrust will generate one for you ID string `json:"id,required"` // The transaction id of an event is unique to the network operation that processed // the event insertion. Transaction ids are monotonically increasing over time and // can be used to retrieve a versioned snapshot of the project logs (see the // `version` parameter) XactID int64 `json:"_xact_id,required"` // A literal 'g' which identifies the log as a project log LogID ProjectLogFetchPostResponseEventsLogID `json:"log_id,required"` // Unique id for the organization that the project belongs under OrgID string `json:"org_id,required" format:"uuid"` // Unique identifier for the project ProjectID string `json:"project_id,required" format:"uuid"` // The `span_id` of the root of the trace this project logs event belongs to RootSpanID string `json:"root_span_id,required"` // A unique identifier used to link different project logs events together as part // of a full trace. See the // [tracing guide](https://www.braintrustdata.com/docs/guides/tracing) for full // details on tracing SpanID string `json:"span_id,required"` // Context is additional information about the code that produced the project logs // event. It is essentially the textual counterpart to `metrics`. Use the // `caller_*` attributes to track the location in code which produced the project // logs event Context ProjectLogFetchPostResponseEventsContext `json:"context,nullable"` // The timestamp the project logs event was created Created time.Time `json:"created,nullable" format:"date-time"` // The ground truth value (an arbitrary, JSON serializable object) that you'd // compare to `output` to determine if your `output` value is correct or not. // Braintrust currently does not compare `output` to `expected` for you, since // there are so many different ways to do that correctly. Instead, these values are // just used to help you navigate while digging into analyses. However, we may // later use these values to re-score outputs or fine-tune your models. Expected interface{} `json:"expected"` // The arguments that uniquely define a user input(an arbitrary, JSON serializable // object). Input interface{} `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata map[string]interface{} `json:"metadata,nullable"` // Metrics are numerical measurements tracking the execution of the code that // produced the project logs event. Use "start" and "end" to track the time span // over which the project logs event was produced Metrics ProjectLogFetchPostResponseEventsMetrics `json:"metrics,nullable"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object), that allows you to determine whether the result is correct // or not. For example, in an app that generates SQL queries, the `output` should // be the _result_ of the SQL query generated by the model, not the query itself, // because there may be multiple valid queries that answer a single question. Output interface{} `json:"output"` // A dictionary of numeric values (between 0 and 1) to log. The scores should give // you a variety of signals that help you determine how accurate the outputs are // compared to what you expect and diagnose failures. For example, a summarization // app might have one score that tells you how accurate the summary is, and another // that measures the word similarity between the generated and grouth truth // summary. The word similarity score could help you determine whether the // summarization was covering similar concepts or not. You can use these scores to // help you sort, filter, and compare logs. Scores map[string]float64 `json:"scores,nullable"` // Human-identifying attributes of the span, such as name, type, etc. SpanAttributes ProjectLogFetchPostResponseEventsSpanAttributes `json:"span_attributes,nullable"` // An array of the parent `span_ids` of this project logs event. This should be // empty for the root span of a trace, and should most often contain just one // parent element for subspans SpanParents []string `json:"span_parents,nullable"` JSON projectLogFetchPostResponseEventJSON `json:"-"` }
func (*ProjectLogFetchPostResponseEvent) UnmarshalJSON ¶
func (r *ProjectLogFetchPostResponseEvent) UnmarshalJSON(data []byte) (err error)
type ProjectLogFetchPostResponseEventsContext ¶
type ProjectLogFetchPostResponseEventsContext struct { // Name of the file in code where the project logs event was created CallerFilename string `json:"caller_filename,nullable"` // The function in code which created the project logs event CallerFunctionname string `json:"caller_functionname,nullable"` // Line of code where the project logs event was created CallerLineno int64 `json:"caller_lineno,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON projectLogFetchPostResponseEventsContextJSON `json:"-"` }
Context is additional information about the code that produced the project logs event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the location in code which produced the project logs event
func (*ProjectLogFetchPostResponseEventsContext) UnmarshalJSON ¶
func (r *ProjectLogFetchPostResponseEventsContext) UnmarshalJSON(data []byte) (err error)
type ProjectLogFetchPostResponseEventsLogID ¶
type ProjectLogFetchPostResponseEventsLogID string
A literal 'g' which identifies the log as a project log
const (
ProjectLogFetchPostResponseEventsLogIDG ProjectLogFetchPostResponseEventsLogID = "g"
)
type ProjectLogFetchPostResponseEventsMetrics ¶
type ProjectLogFetchPostResponseEventsMetrics struct { // A unix timestamp recording when the section of code which produced the project // logs event finished End float64 `json:"end,nullable"` // A unix timestamp recording when the section of code which produced the project // logs event started Start float64 `json:"start,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON projectLogFetchPostResponseEventsMetricsJSON `json:"-"` }
Metrics are numerical measurements tracking the execution of the code that produced the project logs event. Use "start" and "end" to track the time span over which the project logs event was produced
func (*ProjectLogFetchPostResponseEventsMetrics) UnmarshalJSON ¶
func (r *ProjectLogFetchPostResponseEventsMetrics) UnmarshalJSON(data []byte) (err error)
type ProjectLogFetchPostResponseEventsSpanAttributes ¶
type ProjectLogFetchPostResponseEventsSpanAttributes struct { // Name of the span, for display purposes only Name string `json:"name,nullable"` // Type of the span, for display purposes only Type ProjectLogFetchPostResponseEventsSpanAttributesType `json:"type,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON projectLogFetchPostResponseEventsSpanAttributesJSON `json:"-"` }
Human-identifying attributes of the span, such as name, type, etc.
func (*ProjectLogFetchPostResponseEventsSpanAttributes) UnmarshalJSON ¶
func (r *ProjectLogFetchPostResponseEventsSpanAttributes) UnmarshalJSON(data []byte) (err error)
type ProjectLogFetchPostResponseEventsSpanAttributesType ¶
type ProjectLogFetchPostResponseEventsSpanAttributesType string
Type of the span, for display purposes only
const ( ProjectLogFetchPostResponseEventsSpanAttributesTypeLlm ProjectLogFetchPostResponseEventsSpanAttributesType = "llm" ProjectLogFetchPostResponseEventsSpanAttributesTypeScore ProjectLogFetchPostResponseEventsSpanAttributesType = "score" ProjectLogFetchPostResponseEventsSpanAttributesTypeFunction ProjectLogFetchPostResponseEventsSpanAttributesType = "function" ProjectLogFetchPostResponseEventsSpanAttributesTypeEval ProjectLogFetchPostResponseEventsSpanAttributesType = "eval" ProjectLogFetchPostResponseEventsSpanAttributesTypeTask ProjectLogFetchPostResponseEventsSpanAttributesType = "task" ProjectLogFetchPostResponseEventsSpanAttributesTypeTool ProjectLogFetchPostResponseEventsSpanAttributesType = "tool" )
type ProjectLogFetchResponse ¶
type ProjectLogFetchResponse struct { // A list of fetched events Events []ProjectLogFetchResponseEvent `json:"events,required"` JSON projectLogFetchResponseJSON `json:"-"` }
func (*ProjectLogFetchResponse) UnmarshalJSON ¶
func (r *ProjectLogFetchResponse) UnmarshalJSON(data []byte) (err error)
type ProjectLogFetchResponseEvent ¶
type ProjectLogFetchResponseEvent struct { // A unique identifier for the project logs event. If you don't provide one, // BrainTrust will generate one for you ID string `json:"id,required"` // The transaction id of an event is unique to the network operation that processed // the event insertion. Transaction ids are monotonically increasing over time and // can be used to retrieve a versioned snapshot of the project logs (see the // `version` parameter) XactID int64 `json:"_xact_id,required"` // A literal 'g' which identifies the log as a project log LogID ProjectLogFetchResponseEventsLogID `json:"log_id,required"` // Unique id for the organization that the project belongs under OrgID string `json:"org_id,required" format:"uuid"` // Unique identifier for the project ProjectID string `json:"project_id,required" format:"uuid"` // The `span_id` of the root of the trace this project logs event belongs to RootSpanID string `json:"root_span_id,required"` // A unique identifier used to link different project logs events together as part // of a full trace. See the // [tracing guide](https://www.braintrustdata.com/docs/guides/tracing) for full // details on tracing SpanID string `json:"span_id,required"` // Context is additional information about the code that produced the project logs // event. It is essentially the textual counterpart to `metrics`. Use the // `caller_*` attributes to track the location in code which produced the project // logs event Context ProjectLogFetchResponseEventsContext `json:"context,nullable"` // The timestamp the project logs event was created Created time.Time `json:"created,nullable" format:"date-time"` // The ground truth value (an arbitrary, JSON serializable object) that you'd // compare to `output` to determine if your `output` value is correct or not. // Braintrust currently does not compare `output` to `expected` for you, since // there are so many different ways to do that correctly. Instead, these values are // just used to help you navigate while digging into analyses. However, we may // later use these values to re-score outputs or fine-tune your models. Expected interface{} `json:"expected"` // The arguments that uniquely define a user input(an arbitrary, JSON serializable // object). Input interface{} `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata map[string]interface{} `json:"metadata,nullable"` // Metrics are numerical measurements tracking the execution of the code that // produced the project logs event. Use "start" and "end" to track the time span // over which the project logs event was produced Metrics ProjectLogFetchResponseEventsMetrics `json:"metrics,nullable"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object), that allows you to determine whether the result is correct // or not. For example, in an app that generates SQL queries, the `output` should // be the _result_ of the SQL query generated by the model, not the query itself, // because there may be multiple valid queries that answer a single question. Output interface{} `json:"output"` // A dictionary of numeric values (between 0 and 1) to log. The scores should give // you a variety of signals that help you determine how accurate the outputs are // compared to what you expect and diagnose failures. For example, a summarization // app might have one score that tells you how accurate the summary is, and another // that measures the word similarity between the generated and grouth truth // summary. The word similarity score could help you determine whether the // summarization was covering similar concepts or not. You can use these scores to // help you sort, filter, and compare logs. Scores map[string]float64 `json:"scores,nullable"` // Human-identifying attributes of the span, such as name, type, etc. SpanAttributes ProjectLogFetchResponseEventsSpanAttributes `json:"span_attributes,nullable"` // An array of the parent `span_ids` of this project logs event. This should be // empty for the root span of a trace, and should most often contain just one // parent element for subspans SpanParents []string `json:"span_parents,nullable"` JSON projectLogFetchResponseEventJSON `json:"-"` }
func (*ProjectLogFetchResponseEvent) UnmarshalJSON ¶
func (r *ProjectLogFetchResponseEvent) UnmarshalJSON(data []byte) (err error)
type ProjectLogFetchResponseEventsContext ¶
type ProjectLogFetchResponseEventsContext struct { // Name of the file in code where the project logs event was created CallerFilename string `json:"caller_filename,nullable"` // The function in code which created the project logs event CallerFunctionname string `json:"caller_functionname,nullable"` // Line of code where the project logs event was created CallerLineno int64 `json:"caller_lineno,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON projectLogFetchResponseEventsContextJSON `json:"-"` }
Context is additional information about the code that produced the project logs event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the location in code which produced the project logs event
func (*ProjectLogFetchResponseEventsContext) UnmarshalJSON ¶
func (r *ProjectLogFetchResponseEventsContext) UnmarshalJSON(data []byte) (err error)
type ProjectLogFetchResponseEventsLogID ¶
type ProjectLogFetchResponseEventsLogID string
A literal 'g' which identifies the log as a project log
const (
ProjectLogFetchResponseEventsLogIDG ProjectLogFetchResponseEventsLogID = "g"
)
type ProjectLogFetchResponseEventsMetrics ¶
type ProjectLogFetchResponseEventsMetrics struct { // A unix timestamp recording when the section of code which produced the project // logs event finished End float64 `json:"end,nullable"` // A unix timestamp recording when the section of code which produced the project // logs event started Start float64 `json:"start,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON projectLogFetchResponseEventsMetricsJSON `json:"-"` }
Metrics are numerical measurements tracking the execution of the code that produced the project logs event. Use "start" and "end" to track the time span over which the project logs event was produced
func (*ProjectLogFetchResponseEventsMetrics) UnmarshalJSON ¶
func (r *ProjectLogFetchResponseEventsMetrics) UnmarshalJSON(data []byte) (err error)
type ProjectLogFetchResponseEventsSpanAttributes ¶
type ProjectLogFetchResponseEventsSpanAttributes struct { // Name of the span, for display purposes only Name string `json:"name,nullable"` // Type of the span, for display purposes only Type ProjectLogFetchResponseEventsSpanAttributesType `json:"type,nullable"` ExtraFields map[string]interface{} `json:"-,extras"` JSON projectLogFetchResponseEventsSpanAttributesJSON `json:"-"` }
Human-identifying attributes of the span, such as name, type, etc.
func (*ProjectLogFetchResponseEventsSpanAttributes) UnmarshalJSON ¶
func (r *ProjectLogFetchResponseEventsSpanAttributes) UnmarshalJSON(data []byte) (err error)
type ProjectLogFetchResponseEventsSpanAttributesType ¶
type ProjectLogFetchResponseEventsSpanAttributesType string
Type of the span, for display purposes only
const ( ProjectLogFetchResponseEventsSpanAttributesTypeLlm ProjectLogFetchResponseEventsSpanAttributesType = "llm" ProjectLogFetchResponseEventsSpanAttributesTypeScore ProjectLogFetchResponseEventsSpanAttributesType = "score" ProjectLogFetchResponseEventsSpanAttributesTypeFunction ProjectLogFetchResponseEventsSpanAttributesType = "function" ProjectLogFetchResponseEventsSpanAttributesTypeEval ProjectLogFetchResponseEventsSpanAttributesType = "eval" ProjectLogFetchResponseEventsSpanAttributesTypeTask ProjectLogFetchResponseEventsSpanAttributesType = "task" ProjectLogFetchResponseEventsSpanAttributesTypeTool ProjectLogFetchResponseEventsSpanAttributesType = "tool" )
type ProjectLogInsertParams ¶
type ProjectLogInsertParams struct { // A list of project logs events to insert Events param.Field[[]ProjectLogInsertParamsEvent] `json:"events,required"` }
func (ProjectLogInsertParams) MarshalJSON ¶
func (r ProjectLogInsertParams) MarshalJSON() (data []byte, err error)
type ProjectLogInsertParamsEvent ¶
type ProjectLogInsertParamsEvent interface {
// contains filtered or unexported methods
}
Satisfied by ProjectLogInsertParamsEventsInsertProjectLogsEventReplace, ProjectLogInsertParamsEventsInsertProjectLogsEventMerge.
type ProjectLogInsertParamsEventsInsertProjectLogsEventMerge ¶
type ProjectLogInsertParamsEventsInsertProjectLogsEventMerge struct { // The `_is_merge` field controls how the row is merged with any existing row with // the same id in the DB. By default (or when set to `false`), the existing row is // completely replaced by the new row. When set to `true`, the new row is // deep-merged into the existing row // // For example, say there is an existing row in the DB // `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as // `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row // will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the // new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be // `{"id": "foo", "input": {"b": 11, "c": 20}}` IsMerge param.Field[bool] `json:"_is_merge,required"` // A unique identifier for the project logs event. If you don't provide one, // BrainTrust will generate one for you ID param.Field[string] `json:"id"` // The `_merge_paths` field allows controlling the depth of the merge. It can only // be specified alongside `_is_merge=true`. `_merge_paths` is a list of paths, // where each path is a list of field names. The deep merge will not descend below // any of the specified merge paths. // // For example, say there is an existing row in the DB // `{"id": "foo", "input": {"a": {"b": 10}, "c": {"d": 20}}, "output": {"a": 20}}`. // If we merge a new row as // `{"_is_merge": true, "_merge_paths": [["input", "a"], ["output"]], "input": {"a": {"q": 30}, "c": {"e": 30}, "bar": "baz"}, "output": {"d": 40}}`, // the new row will be // `{"id": "foo": "input": {"a": {"q": 30}, "c": {"d": 20, "e": 30}, "bar": "baz"}, "output": {"d": 40}}`. // In this case, due to the merge paths, we have replaced `input.a` and `output`, // but have still deep-merged `input` and `input.c`. MergePaths param.Field[[][]string] `json:"_merge_paths"` // Pass `_object_delete=true` to mark the project logs event deleted. Deleted // events will not show up in subsequent fetches for this project logs ObjectDelete param.Field[bool] `json:"_object_delete"` // Context is additional information about the code that produced the project logs // event. It is essentially the textual counterpart to `metrics`. Use the // `caller_*` attributes to track the location in code which produced the project // logs event Context param.Field[ProjectLogInsertParamsEventsInsertProjectLogsEventMergeContext] `json:"context"` // The ground truth value (an arbitrary, JSON serializable object) that you'd // compare to `output` to determine if your `output` value is correct or not. // Braintrust currently does not compare `output` to `expected` for you, since // there are so many different ways to do that correctly. Instead, these values are // just used to help you navigate while digging into analyses. However, we may // later use these values to re-score outputs or fine-tune your models. Expected param.Field[interface{}] `json:"expected"` // The arguments that uniquely define a user input(an arbitrary, JSON serializable // object). Input param.Field[interface{}] `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata param.Field[map[string]interface{}] `json:"metadata"` // Metrics are numerical measurements tracking the execution of the code that // produced the project logs event. Use "start" and "end" to track the time span // over which the project logs event was produced Metrics param.Field[ProjectLogInsertParamsEventsInsertProjectLogsEventMergeMetrics] `json:"metrics"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object), that allows you to determine whether the result is correct // or not. For example, in an app that generates SQL queries, the `output` should // be the _result_ of the SQL query generated by the model, not the query itself, // because there may be multiple valid queries that answer a single question. Output param.Field[interface{}] `json:"output"` // A dictionary of numeric values (between 0 and 1) to log. The scores should give // you a variety of signals that help you determine how accurate the outputs are // compared to what you expect and diagnose failures. For example, a summarization // app might have one score that tells you how accurate the summary is, and another // that measures the word similarity between the generated and grouth truth // summary. The word similarity score could help you determine whether the // summarization was covering similar concepts or not. You can use these scores to // help you sort, filter, and compare logs. Scores param.Field[map[string]float64] `json:"scores"` // Human-identifying attributes of the span, such as name, type, etc. SpanAttributes param.Field[ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributes] `json:"span_attributes"` }
func (ProjectLogInsertParamsEventsInsertProjectLogsEventMerge) MarshalJSON ¶
func (r ProjectLogInsertParamsEventsInsertProjectLogsEventMerge) MarshalJSON() (data []byte, err error)
type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeContext ¶
type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeContext struct { // Name of the file in code where the project logs event was created CallerFilename param.Field[string] `json:"caller_filename"` // The function in code which created the project logs event CallerFunctionname param.Field[string] `json:"caller_functionname"` // Line of code where the project logs event was created CallerLineno param.Field[int64] `json:"caller_lineno"` ExtraFields map[string]interface{} `json:"-,extras"` }
Context is additional information about the code that produced the project logs event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the location in code which produced the project logs event
func (ProjectLogInsertParamsEventsInsertProjectLogsEventMergeContext) MarshalJSON ¶
func (r ProjectLogInsertParamsEventsInsertProjectLogsEventMergeContext) MarshalJSON() (data []byte, err error)
type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeMetrics ¶
type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeMetrics struct { // A unix timestamp recording when the section of code which produced the project // logs event finished End param.Field[float64] `json:"end"` // A unix timestamp recording when the section of code which produced the project // logs event started Start param.Field[float64] `json:"start"` ExtraFields map[string]interface{} `json:"-,extras"` }
Metrics are numerical measurements tracking the execution of the code that produced the project logs event. Use "start" and "end" to track the time span over which the project logs event was produced
func (ProjectLogInsertParamsEventsInsertProjectLogsEventMergeMetrics) MarshalJSON ¶
func (r ProjectLogInsertParamsEventsInsertProjectLogsEventMergeMetrics) MarshalJSON() (data []byte, err error)
type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributes ¶
type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributes struct { // Name of the span, for display purposes only Name param.Field[string] `json:"name"` // Type of the span, for display purposes only Type param.Field[ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesType] `json:"type"` ExtraFields map[string]interface{} `json:"-,extras"` }
Human-identifying attributes of the span, such as name, type, etc.
func (ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributes) MarshalJSON ¶
func (r ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributes) MarshalJSON() (data []byte, err error)
type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesType ¶
type ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesType string
Type of the span, for display purposes only
const ( ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesTypeLlm ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesType = "llm" ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesTypeScore ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesType = "score" ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesTypeFunction ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesType = "function" ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesTypeEval ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesType = "eval" ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesTypeTask ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesType = "task" ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesTypeTool ProjectLogInsertParamsEventsInsertProjectLogsEventMergeSpanAttributesType = "tool" )
type ProjectLogInsertParamsEventsInsertProjectLogsEventReplace ¶
type ProjectLogInsertParamsEventsInsertProjectLogsEventReplace struct { // A unique identifier for the project logs event. If you don't provide one, // BrainTrust will generate one for you ID param.Field[string] `json:"id"` // The `_is_merge` field controls how the row is merged with any existing row with // the same id in the DB. By default (or when set to `false`), the existing row is // completely replaced by the new row. When set to `true`, the new row is // deep-merged into the existing row // // For example, say there is an existing row in the DB // `{"id": "foo", "input": {"a": 5, "b": 10}}`. If we merge a new row as // `{"_is_merge": true, "id": "foo", "input": {"b": 11, "c": 20}}`, the new row // will be `{"id": "foo", "input": {"a": 5, "b": 11, "c": 20}}`. If we replace the // new row as `{"id": "foo", "input": {"b": 11, "c": 20}}`, the new row will be // `{"id": "foo", "input": {"b": 11, "c": 20}}` IsMerge param.Field[bool] `json:"_is_merge"` // Pass `_object_delete=true` to mark the project logs event deleted. Deleted // events will not show up in subsequent fetches for this project logs ObjectDelete param.Field[bool] `json:"_object_delete"` // Use the `_parent_id` field to create this row as a subspan of an existing row. // It cannot be specified alongside `_is_merge=true`. Tracking hierarchical // relationships are important for tracing (see the // [guide](https://www.braintrustdata.com/docs/guides/tracing) for full details). // // For example, say we have logged a row // `{"id": "abc", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}`. // We can create a sub-span of the parent row by logging // `{"_parent_id": "abc", "id": "llm_call", "input": {"prompt": "What comes after foo?"}, "output": "bar", "metrics": {"tokens": 1}}`. // In the webapp, only the root span row `"abc"` will show up in the summary view. // You can view the full trace hierarchy (in this case, the `"llm_call"` row) by // clicking on the "abc" row. ParentID param.Field[string] `json:"_parent_id"` // Context is additional information about the code that produced the project logs // event. It is essentially the textual counterpart to `metrics`. Use the // `caller_*` attributes to track the location in code which produced the project // logs event Context param.Field[ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceContext] `json:"context"` // The ground truth value (an arbitrary, JSON serializable object) that you'd // compare to `output` to determine if your `output` value is correct or not. // Braintrust currently does not compare `output` to `expected` for you, since // there are so many different ways to do that correctly. Instead, these values are // just used to help you navigate while digging into analyses. However, we may // later use these values to re-score outputs or fine-tune your models. Expected param.Field[interface{}] `json:"expected"` // The arguments that uniquely define a user input(an arbitrary, JSON serializable // object). Input param.Field[interface{}] `json:"input"` // A dictionary with additional data about the test example, model outputs, or just // about anything else that's relevant, that you can use to help find and analyze // examples later. For example, you could log the `prompt`, example's `id`, or // anything else that would be useful to slice/dice later. The values in `metadata` // can be any JSON-serializable type, but its keys must be strings Metadata param.Field[map[string]interface{}] `json:"metadata"` // Metrics are numerical measurements tracking the execution of the code that // produced the project logs event. Use "start" and "end" to track the time span // over which the project logs event was produced Metrics param.Field[ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceMetrics] `json:"metrics"` // The output of your application, including post-processing (an arbitrary, JSON // serializable object), that allows you to determine whether the result is correct // or not. For example, in an app that generates SQL queries, the `output` should // be the _result_ of the SQL query generated by the model, not the query itself, // because there may be multiple valid queries that answer a single question. Output param.Field[interface{}] `json:"output"` // A dictionary of numeric values (between 0 and 1) to log. The scores should give // you a variety of signals that help you determine how accurate the outputs are // compared to what you expect and diagnose failures. For example, a summarization // app might have one score that tells you how accurate the summary is, and another // that measures the word similarity between the generated and grouth truth // summary. The word similarity score could help you determine whether the // summarization was covering similar concepts or not. You can use these scores to // help you sort, filter, and compare logs. Scores param.Field[map[string]float64] `json:"scores"` // Human-identifying attributes of the span, such as name, type, etc. SpanAttributes param.Field[ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributes] `json:"span_attributes"` }
func (ProjectLogInsertParamsEventsInsertProjectLogsEventReplace) MarshalJSON ¶
func (r ProjectLogInsertParamsEventsInsertProjectLogsEventReplace) MarshalJSON() (data []byte, err error)
type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceContext ¶
type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceContext struct { // Name of the file in code where the project logs event was created CallerFilename param.Field[string] `json:"caller_filename"` // The function in code which created the project logs event CallerFunctionname param.Field[string] `json:"caller_functionname"` // Line of code where the project logs event was created CallerLineno param.Field[int64] `json:"caller_lineno"` ExtraFields map[string]interface{} `json:"-,extras"` }
Context is additional information about the code that produced the project logs event. It is essentially the textual counterpart to `metrics`. Use the `caller_*` attributes to track the location in code which produced the project logs event
func (ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceContext) MarshalJSON ¶
func (r ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceContext) MarshalJSON() (data []byte, err error)
type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceMetrics ¶
type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceMetrics struct { // A unix timestamp recording when the section of code which produced the project // logs event finished End param.Field[float64] `json:"end"` // A unix timestamp recording when the section of code which produced the project // logs event started Start param.Field[float64] `json:"start"` ExtraFields map[string]interface{} `json:"-,extras"` }
Metrics are numerical measurements tracking the execution of the code that produced the project logs event. Use "start" and "end" to track the time span over which the project logs event was produced
func (ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceMetrics) MarshalJSON ¶
func (r ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceMetrics) MarshalJSON() (data []byte, err error)
type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributes ¶
type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributes struct { // Name of the span, for display purposes only Name param.Field[string] `json:"name"` // Type of the span, for display purposes only Type param.Field[ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesType] `json:"type"` ExtraFields map[string]interface{} `json:"-,extras"` }
Human-identifying attributes of the span, such as name, type, etc.
func (ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributes) MarshalJSON ¶
func (r ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributes) MarshalJSON() (data []byte, err error)
type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesType ¶
type ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesType string
Type of the span, for display purposes only
const ( ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesTypeLlm ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesType = "llm" ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesTypeScore ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesType = "score" ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesTypeFunction ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesType = "function" ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesTypeEval ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesType = "eval" ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesTypeTask ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesType = "task" ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesTypeTool ProjectLogInsertParamsEventsInsertProjectLogsEventReplaceSpanAttributesType = "tool" )
type ProjectLogInsertResponse ¶
type ProjectLogInsertResponse struct { // The ids of all rows that were inserted, aligning one-to-one with the rows // provided as input RowIDs []string `json:"row_ids,required"` JSON projectLogInsertResponseJSON `json:"-"` }
func (*ProjectLogInsertResponse) UnmarshalJSON ¶
func (r *ProjectLogInsertResponse) UnmarshalJSON(data []byte) (err error)
type ProjectLogService ¶
type ProjectLogService struct {
Options []option.RequestOption
}
ProjectLogService contains methods and other services that help with interacting with the braintrust API. Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewProjectLogService method instead.
func NewProjectLogService ¶
func NewProjectLogService(opts ...option.RequestOption) (r *ProjectLogService)
NewProjectLogService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*ProjectLogService) Feedback ¶
func (r *ProjectLogService) Feedback(ctx context.Context, projectID string, body ProjectLogFeedbackParams, opts ...option.RequestOption) (err error)
Log feedback for a set of project logs events
func (*ProjectLogService) Fetch ¶
func (r *ProjectLogService) Fetch(ctx context.Context, projectID string, query ProjectLogFetchParams, opts ...option.RequestOption) (res *ProjectLogFetchResponse, err error)
Fetch the events in a project logs. Equivalent to the POST form of the same path, but with the parameters in the URL query rather than in the request body
func (*ProjectLogService) FetchPost ¶
func (r *ProjectLogService) FetchPost(ctx context.Context, projectID string, body ProjectLogFetchPostParams, opts ...option.RequestOption) (res *ProjectLogFetchPostResponse, err error)
Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the parameters in the request body rather than in the URL query
func (*ProjectLogService) Insert ¶
func (r *ProjectLogService) Insert(ctx context.Context, projectID string, body ProjectLogInsertParams, opts ...option.RequestOption) (res *ProjectLogInsertResponse, err error)
Insert a set of events into the project logs
type ProjectNewParams ¶
type ProjectNewParams struct { // Name of the project Name param.Field[string] `json:"name,required"` // For nearly all users, this parameter should be unnecessary. But in the rare case // that your API key belongs to multiple organizations, you may specify the name of // the organization the project belongs in. OrgName param.Field[string] `json:"org_name"` }
func (ProjectNewParams) MarshalJSON ¶
func (r ProjectNewParams) MarshalJSON() (data []byte, err error)
type ProjectReplaceParams ¶
type ProjectReplaceParams struct { // Name of the project Name param.Field[string] `json:"name,required"` // For nearly all users, this parameter should be unnecessary. But in the rare case // that your API key belongs to multiple organizations, you may specify the name of // the organization the project belongs in. OrgName param.Field[string] `json:"org_name"` }
func (ProjectReplaceParams) MarshalJSON ¶
func (r ProjectReplaceParams) MarshalJSON() (data []byte, err error)
type ProjectService ¶
type ProjectService struct { Options []option.RequestOption Logs *ProjectLogService }
ProjectService contains methods and other services that help with interacting with the braintrust API. Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewProjectService method instead.
func NewProjectService ¶
func NewProjectService(opts ...option.RequestOption) (r *ProjectService)
NewProjectService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*ProjectService) Delete ¶
func (r *ProjectService) Delete(ctx context.Context, projectID string, opts ...option.RequestOption) (res *Project, err error)
Delete a project object by its id
func (*ProjectService) Get ¶
func (r *ProjectService) Get(ctx context.Context, projectID string, opts ...option.RequestOption) (res *Project, err error)
Get a project object by its id
func (*ProjectService) List ¶
func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) (res *shared.ListObjects[Project], err error)
List out all projects. The projects are sorted by creation date, with the most recently-created projects coming first
func (*ProjectService) ListAutoPaging ¶
func (r *ProjectService) ListAutoPaging(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) *shared.ListObjectsAutoPager[Project]
List out all projects. The projects are sorted by creation date, with the most recently-created projects coming first
func (*ProjectService) New ¶
func (r *ProjectService) New(ctx context.Context, body ProjectNewParams, opts ...option.RequestOption) (res *Project, err error)
Create a new project. If there is an existing project with the same name as the one specified in the request, will return the existing project unmodified
func (*ProjectService) Replace ¶
func (r *ProjectService) Replace(ctx context.Context, body ProjectReplaceParams, opts ...option.RequestOption) (res *Project, err error)
Create or replace a new project. If there is an existing project with the same name as the one specified in the request, will replace the existing project with the provided fields
func (*ProjectService) Update ¶
func (r *ProjectService) Update(ctx context.Context, projectID string, body ProjectUpdateParams, opts ...option.RequestOption) (res *Project, err error)
Partially update a project object. Specify the fields to update in the payload. Any object-type fields will be deep-merged with existing content. Currently we do not support removing fields or setting them to null. As a workaround, you may retrieve the full object with `GET /project/{id}` and then replace it with `PUT /project`.
type ProjectUpdateParams ¶
func (ProjectUpdateParams) MarshalJSON ¶
func (r ProjectUpdateParams) MarshalJSON() (data []byte, err error)
type TopLevelService ¶
type TopLevelService struct {
Options []option.RequestOption
}
TopLevelService contains methods and other services that help with interacting with the braintrust API. Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewTopLevelService method instead.
func NewTopLevelService ¶
func NewTopLevelService(opts ...option.RequestOption) (r *TopLevelService)
NewTopLevelService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*TopLevelService) HelloWorld ¶
func (r *TopLevelService) HelloWorld(ctx context.Context, opts ...option.RequestOption) (res *string, err error)
Default endpoint. Simply replies with 'Hello, World!'. Authorization is not required