Class InsertExperimentEvent
-
- All Implemented Interfaces:
public final class InsertExperimentEventAn experiment event
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classInsertExperimentEvent.BuilderA builder for InsertExperimentEvent.
public final classInsertExperimentEvent.ContextContext is additional information about the code that produced the experiment event. It is essentially the textual counterpart to
metrics. Use thecaller_*attributes to track the location in code which produced the experiment eventpublic final classInsertExperimentEvent.MetadataA 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'sid, or anything else that would be useful to slice/dice later. The values inmetadatacan be any JSON-serializable type, but its keys must be stringspublic final classInsertExperimentEvent.MetricsMetrics 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
public final classInsertExperimentEvent.ScoresA 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
-
Method Summary
Modifier and Type Method Description final Optional<String>id()A unique identifier for the experiment event. final Optional<Boolean>_isMerge()The _is_mergefield controls how the row is merged with any existing row with the same id in the DB.final Optional<List<List<String>>>_mergePaths()The _merge_pathsfield allows controlling the depth of the merge, when_is_merge=true.final Optional<Boolean>_objectDelete()Pass _object_delete=trueto mark the experiment event deleted.final Optional<String>_parentId()DEPRECATED: The _parent_idfield is deprecated and should not be used.final Optional<InsertExperimentEvent.Context>context()Context is additional information about the code that produced the experiment event. final Optional<OffsetDateTime>created()The timestamp the experiment event was created final JsonValue_error()The error that occurred, if any. final JsonValue_expected()The ground truth value (an arbitrary, JSON serializable object) that you'd compare to outputto determine if youroutputvalue is correct or not.final JsonValue_input()The arguments that uniquely define a test case (an arbitrary, JSON serializable object). final Optional<InsertExperimentEvent.Metadata>metadata()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. final Optional<InsertExperimentEvent.Metrics>metrics()Metrics are numerical measurements tracking the execution of the code that produced the experiment event. final Optional<ObjectReference>origin()Indicates the event was copied from another object. final JsonValue_output()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. final Optional<String>rootSpanId()Use span_id,root_span_id, andspan_parentsinstead of_parent_id, which is now deprecated.final Optional<InsertExperimentEvent.Scores>scores()A dictionary of numeric values (between 0 and 1) to log. final Optional<SpanAttributes>spanAttributes()Human-identifying attributes of the span, such as name, type, etc. final Optional<String>spanId()Use span_id,root_span_id, andspan_parentsinstead of_parent_id, which is now deprecated.final Optional<List<String>>spanParents()Use span_id,root_span_id, andspan_parentsinstead of_parent_id, which is now deprecated.final Optional<List<String>>tags()A list of tags to log final JsonField<String>_id()Returns the raw JSON value of id. final JsonField<Boolean>__isMerge()Returns the raw JSON value of _isMerge. final JsonField<List<List<String>>>__mergePaths()Returns the raw JSON value of _mergePaths. final JsonField<Boolean>__objectDelete()Returns the raw JSON value of _objectDelete. final JsonField<String>__parentId()Returns the raw JSON value of _parentId. final JsonField<InsertExperimentEvent.Context>_context()Returns the raw JSON value of context. final JsonField<OffsetDateTime>_created()Returns the raw JSON value of created. final JsonField<InsertExperimentEvent.Metadata>_metadata()Returns the raw JSON value of metadata. final JsonField<InsertExperimentEvent.Metrics>_metrics()Returns the raw JSON value of metrics. final JsonField<ObjectReference>_origin()Returns the raw JSON value of origin. final JsonField<String>_rootSpanId()Returns the raw JSON value of rootSpanId. final JsonField<InsertExperimentEvent.Scores>_scores()Returns the raw JSON value of scores. final JsonField<SpanAttributes>_spanAttributes()Returns the raw JSON value of spanAttributes. final JsonField<String>_spanId()Returns the raw JSON value of spanId. final JsonField<List<String>>_spanParents()Returns the raw JSON value of spanParents. final JsonField<List<String>>_tags()Returns the raw JSON value of tags. final Map<String, JsonValue>_additionalProperties()final InsertExperimentEvent.BuildertoBuilder()final InsertExperimentEventvalidate()final BooleanisValid()Booleanequals(Object other)IntegerhashCode()StringtoString()final static InsertExperimentEvent.Builderbuilder()Returns a mutable builder for constructing an instance of InsertExperimentEvent. -
-
Method Detail
-
id
final Optional<String> id()
A unique identifier for the experiment event. If you don't provide one, BrainTrust will generate one for you
-
_isMerge
final Optional<Boolean> _isMerge()
The
_is_mergefield controls how the row is merged with any existing row with the same id in the DB. By default (or when set tofalse), the existing row is completely replaced by the new row. When set totrue, the new row is deep-merged into the existing row, if one is found. If no existing row is found, the new row is inserted as is.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}}
-
_mergePaths
final Optional<List<List<String>>> _mergePaths()
The
_merge_pathsfield allows controlling the depth of the merge, when_is_merge=true._merge_pathsis 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 replacedinput.aandoutput, but have still deep-mergedinputandinput.c.
-
_objectDelete
final Optional<Boolean> _objectDelete()
Pass
_object_delete=trueto mark the experiment event deleted. Deleted events will not show up in subsequent fetches for this experiment
-
_parentId
final Optional<String> _parentId()
DEPRECATED: The
_parent_idfield is deprecated and should not be used. Support for_parent_idwill be dropped in a future version of Braintrust. Logspan_id,root_span_id, andspan_parentsexplicitly instead.Use the
_parent_idfield to create this row as a subspan of an existing row. Tracking hierarchical relationships are important for tracing (see the guide 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.If the row is being merged into an existing row, this field will be ignored.
-
context
final Optional<InsertExperimentEvent.Context> context()
Context is additional information about the code that produced the experiment event. It is essentially the textual counterpart to
metrics. Use thecaller_*attributes to track the location in code which produced the experiment event
-
created
final Optional<OffsetDateTime> created()
The timestamp the experiment event was created
-
_expected
final JsonValue _expected()
The ground truth value (an arbitrary, JSON serializable object) that you'd compare to
outputto determine if youroutputvalue is correct or not. Braintrust currently does not compareoutputtoexpectedfor 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
-
_input
final JsonValue _input()
The arguments that uniquely define a test case (an arbitrary, JSON serializable object). Later on, Braintrust will use the
inputto 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, theinputshould be identical
-
metadata
final Optional<InsertExperimentEvent.Metadata> metadata()
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'sid, or anything else that would be useful to slice/dice later. The values inmetadatacan be any JSON-serializable type, but its keys must be strings
-
metrics
final Optional<InsertExperimentEvent.Metrics> metrics()
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
-
origin
final Optional<ObjectReference> origin()
Indicates the event was copied from another object.
-
_output
final JsonValue _output()
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
outputshould 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
-
rootSpanId
final Optional<String> rootSpanId()
Use
span_id,root_span_id, andspan_parentsinstead of_parent_id, which is now deprecated. The span_id is a unique identifier describing the row's place in the a trace, and the root_span_id is a unique identifier for the whole trace. See the guide for full details.For example, say we have logged a row
{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}. We can create a sub-span of the parent row by logging{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "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.If the row is being merged into an existing row, this field will be ignored.
-
scores
final Optional<InsertExperimentEvent.Scores> scores()
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
-
spanAttributes
final Optional<SpanAttributes> spanAttributes()
Human-identifying attributes of the span, such as name, type, etc.
-
spanId
final Optional<String> spanId()
Use
span_id,root_span_id, andspan_parentsinstead of_parent_id, which is now deprecated. The span_id is a unique identifier describing the row's place in the a trace, and the root_span_id is a unique identifier for the whole trace. See the guide for full details.For example, say we have logged a row
{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}. We can create a sub-span of the parent row by logging{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "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.If the row is being merged into an existing row, this field will be ignored.
-
spanParents
final Optional<List<String>> spanParents()
Use
span_id,root_span_id, andspan_parentsinstead of_parent_id, which is now deprecated. The span_id is a unique identifier describing the row's place in the a trace, and the root_span_id is a unique identifier for the whole trace. See the guide for full details.For example, say we have logged a row
{"id": "abc", "span_id": "span0", "root_span_id": "root_span0", "input": "foo", "output": "bar", "expected": "boo", "scores": {"correctness": 0.33}}. We can create a sub-span of the parent row by logging{"id": "llm_call", "span_id": "span1", "root_span_id": "root_span0", "span_parents": ["span0"], "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.If the row is being merged into an existing row, this field will be ignored.
-
_id
final JsonField<String> _id()
Returns the raw JSON value of id.
Unlike id, this method doesn't throw if the JSON field has an unexpected type.
-
__isMerge
final JsonField<Boolean> __isMerge()
Returns the raw JSON value of _isMerge.
Unlike _isMerge, this method doesn't throw if the JSON field has an unexpected type.
-
__mergePaths
final JsonField<List<List<String>>> __mergePaths()
Returns the raw JSON value of _mergePaths.
Unlike _mergePaths, this method doesn't throw if the JSON field has an unexpected type.
-
__objectDelete
final JsonField<Boolean> __objectDelete()
Returns the raw JSON value of _objectDelete.
Unlike _objectDelete, this method doesn't throw if the JSON field has an unexpected type.
-
__parentId
final JsonField<String> __parentId()
Returns the raw JSON value of _parentId.
Unlike _parentId, this method doesn't throw if the JSON field has an unexpected type.
-
_context
final JsonField<InsertExperimentEvent.Context> _context()
Returns the raw JSON value of context.
Unlike context, this method doesn't throw if the JSON field has an unexpected type.
-
_created
final JsonField<OffsetDateTime> _created()
Returns the raw JSON value of created.
Unlike created, this method doesn't throw if the JSON field has an unexpected type.
-
_metadata
final JsonField<InsertExperimentEvent.Metadata> _metadata()
Returns the raw JSON value of metadata.
Unlike metadata, this method doesn't throw if the JSON field has an unexpected type.
-
_metrics
final JsonField<InsertExperimentEvent.Metrics> _metrics()
Returns the raw JSON value of metrics.
Unlike metrics, this method doesn't throw if the JSON field has an unexpected type.
-
_origin
final JsonField<ObjectReference> _origin()
Returns the raw JSON value of origin.
Unlike origin, this method doesn't throw if the JSON field has an unexpected type.
-
_rootSpanId
final JsonField<String> _rootSpanId()
Returns the raw JSON value of rootSpanId.
Unlike rootSpanId, this method doesn't throw if the JSON field has an unexpected type.
-
_scores
final JsonField<InsertExperimentEvent.Scores> _scores()
Returns the raw JSON value of scores.
Unlike scores, this method doesn't throw if the JSON field has an unexpected type.
-
_spanAttributes
final JsonField<SpanAttributes> _spanAttributes()
Returns the raw JSON value of spanAttributes.
Unlike spanAttributes, this method doesn't throw if the JSON field has an unexpected type.
-
_spanId
final JsonField<String> _spanId()
Returns the raw JSON value of spanId.
Unlike spanId, this method doesn't throw if the JSON field has an unexpected type.
-
_spanParents
final JsonField<List<String>> _spanParents()
Returns the raw JSON value of spanParents.
Unlike spanParents, this method doesn't throw if the JSON field has an unexpected type.
-
_tags
final JsonField<List<String>> _tags()
Returns the raw JSON value of tags.
Unlike tags, this method doesn't throw if the JSON field has an unexpected type.
-
_additionalProperties
final Map<String, JsonValue> _additionalProperties()
-
toBuilder
final InsertExperimentEvent.Builder toBuilder()
-
validate
final InsertExperimentEvent validate()
-
builder
final static InsertExperimentEvent.Builder builder()
Returns a mutable builder for constructing an instance of InsertExperimentEvent.
-
-
-
-