diff --git a/js/eslint.config.ts b/js/eslint.config.ts index 1705032c7..04e2b8f78 100644 --- a/js/eslint.config.ts +++ b/js/eslint.config.ts @@ -31,6 +31,7 @@ export default [ "node_modules/**", "vendor/**", "examples/**", + "**/generated*_types.ts", "scripts/**", ".turbo/**", "docs/**", diff --git a/js/src/generated_plain_types.ts b/js/src/generated_plain_types.ts new file mode 100644 index 000000000..b03f1fddc --- /dev/null +++ b/js/src/generated_plain_types.ts @@ -0,0 +1,7154 @@ +// Auto-generated file (content hash 776b6c295e852681) -- do not modify + +export type AclObjectTypeType = + /** + * The object type that the ACL applies to + * + * @enum organization, project, experiment, dataset, prompt, prompt_session, group, role, org_member, project_log, org_project, org_audit_logs, project_group + */ + | /** + * The object type that the ACL applies to + * + * @enum organization, project, experiment, dataset, prompt, prompt_session, group, role, org_member, project_log, org_project, org_audit_logs, project_group + */ + (| "organization" + | "project" + | "experiment" + | "dataset" + | "prompt" + | "prompt_session" + | "group" + | "role" + | "org_member" + | "project_log" + | "org_project" + | "org_audit_logs" + | "project_group" + ) + /** + * The object type that the ACL applies to + * + * @enum organization, project, experiment, dataset, prompt, prompt_session, group, role, org_member, project_log, org_project, org_audit_logs, project_group + */ + | null; +export type PermissionType = + /** + * Each permission permits a certain type of operation on an object in the system + +Permissions can be assigned to to objects on an individual basis, or grouped into roles + * + * @enum create, read, update, delete, create_acls, read_acls, update_acls, delete_acls + */ + | "create" + | "read" + | "update" + | "delete" + | "create_acls" + | "read_acls" + | "update_acls" + | "delete_acls"; +export type AclType = { + /** + * Unique identifier for the acl + */ + id: string; + object_type: AclObjectTypeType & string; + /** + * The id of the object the ACL applies to + */ + object_id: string; + user_id?: + | /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + (| string + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + | null + ) + | undefined; + group_id?: + | /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + (| string + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + | null + ) + | undefined; + permission?: + | (PermissionType & + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + (| string + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + | null + )) + | undefined; + restrict_object_type?: + | (AclObjectTypeType & + /** + * When setting a permission directly, optionally restricts the permission grant to just the specified object type. Cannot be set alongside a `role_id`. + */ unknown) + | undefined; + role_id?: + | /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + (| string + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + | null + ) + | undefined; + /** + * The organization the ACL's referred object belongs to + */ + _object_org_id: string; + created?: + | /** + * Date of acl creation + */ + /** + * Date of acl creation + */ + (| string + /** + * Date of acl creation + */ + | null + ) + | undefined; +}; +export type AgentType = { + /** + * Unique identifier for the agent + */ + id: string; + /** + * Unique identifier for the project that the agent belongs under + */ + project_id: string; + user_id: string; + created?: + | /** + * Date of agent creation + */ + /** + * Date of agent creation + */ + (| string + /** + * Date of agent creation + */ + | null + ) + | undefined; + /** + * Name of the agent. Within a project, agent names are unique + */ + name: string; + /** + * Stable, URL-safe identifier for the agent, unique within its project. + */ + slug: string; + /** + * Agent classification: 'custom' for customer-defined agents, 'loop' for built-in Loop agents. + */ + kind: string; + description?: + | /** + * Textual description of the agent + */ + /** + * Textual description of the agent + */ + (| string + /** + * Textual description of the agent + */ + | null + ) + | undefined; + metadata?: + | /** + * User-controlled metadata about the agent + */ + /** + * User-controlled metadata about the agent + */ + (| {} + /** + * User-controlled metadata about the agent + */ + | null + ) + | undefined; +}; +export type AISecretType = { + /** + * Unique identifier for the AI secret + */ + id: string; + created?: + | /** + * Date of AI secret creation + */ + /** + * Date of AI secret creation + */ + (| string + /** + * Date of AI secret creation + */ + | null + ) + | undefined; + updated_at?: + | /** + * Date of last AI secret update + */ + /** + * Date of last AI secret update + */ + (| string + /** + * Date of last AI secret update + */ + | null + ) + | undefined; + secret_updated_at?: + | /** + * Date of last update to the encrypted secret value itself + */ + /** + * Date of last update to the encrypted secret value itself + */ + (| string + /** + * Date of last update to the encrypted secret value itself + */ + | null + ) + | undefined; + /** + * Unique identifier for the organization + */ + org_id: string; + /** + * Name of the AI secret + */ + name: string; + type?: (string | null) | undefined; + metadata?: ({} | null) | undefined; + secret_updated_by_user_id?: + | /** + * User id of the last update to the encrypted secret value + */ + /** + * User id of the last update to the encrypted secret value + */ + (| string + /** + * User id of the last update to the encrypted secret value + */ + | null + ) + | undefined; + preview_secret?: (string | null) | undefined; +}; +export type ResponseFormatJsonSchemaType = { + name: string; + description?: string | undefined; + schema?: ({} | string) | undefined; + strict?: (boolean | null) | undefined; +}; +export type ResponseFormatNullishType = + | { + /** + * @enum json_object + */ + type: "json_object"; + } + | { + /** + * @enum json_schema + */ + type: "json_schema"; + json_schema: ResponseFormatJsonSchemaType; + } + | { + /** + * @enum text + */ + type: "text"; + } + | null; +export type AnyModelParamsType = { + temperature?: number | undefined; + top_p?: number | undefined; + max_tokens: number; + max_completion_tokens?: /** + * The successor to max_tokens + */ + number | undefined; + frequency_penalty?: number | undefined; + presence_penalty?: number | undefined; + response_format?: ResponseFormatNullishType | undefined; + tool_choice?: + | ( + | /** + * @enum auto + */ + "auto" + /** + * @enum none + */ + | "none" + /** + * @enum required + */ + | "required" + | { + /** + * @enum function + */ + type: "function"; + function: { + name: string; + }; + } + ) + | undefined; + function_call?: + | ( + | /** + * @enum auto + */ + "auto" + /** + * @enum none + */ + | "none" + | { + name: string; + } + ) + | undefined; + n?: number | undefined; + stop?: Array | undefined; + reasoning_effort?: + | /** + * @enum none, minimal, low, medium, high + */ + ("none" | "minimal" | "low" | "medium" | "high") + | undefined; + verbosity?: + | /** + * @enum low, medium, high + */ + ("low" | "medium" | "high") + | undefined; + top_k?: number | undefined; + stop_sequences?: Array | undefined; + reasoning_enabled?: boolean | undefined; + reasoning_budget?: number | undefined; + max_tokens_to_sample?: /** + * This is a legacy parameter that should not be used. + */ + number | undefined; + maxOutputTokens?: number | undefined; + topP?: number | undefined; + topK?: number | undefined; + use_cache?: boolean | undefined; +}; +export type ApiKeyType = { + /** + * Unique identifier for the api key + */ + id: string; + created?: + | /** + * Date of api key creation + */ + /** + * Date of api key creation + */ + (| string + /** + * Date of api key creation + */ + | null + ) + | undefined; + /** + * Name of the api key + */ + name: string; + preview_name: string; + user_id?: + | /** + * Unique identifier for the user + */ + /** + * Unique identifier for the user + */ + (| string + /** + * Unique identifier for the user + */ + | null + ) + | undefined; + user_email?: + | /** + * The user's email + */ + /** + * The user's email + */ + (| string + /** + * The user's email + */ + | null + ) + | undefined; + user_given_name?: + | /** + * Given name of the user + */ + /** + * Given name of the user + */ + (| string + /** + * Given name of the user + */ + | null + ) + | undefined; + user_family_name?: + | /** + * Family name of the user + */ + /** + * Family name of the user + */ + (| string + /** + * Family name of the user + */ + | null + ) + | undefined; + org_id?: + | /** + * Unique identifier for the organization + */ + /** + * Unique identifier for the organization + */ + (| string + /** + * Unique identifier for the organization + */ + | null + ) + | undefined; + expires_at?: + | /** + * Date at which the API key expires. If null, the key never expires. + */ + /** + * Date at which the API key expires. If null, the key never expires. + */ + (| string + /** + * Date at which the API key expires. If null, the key never expires. + */ + | null + ) + | undefined; +}; +export type TriggeredFunctionStateType = { + /** + * The xact_id when this function was triggered + */ + triggered_xact_id: string; + completed_xact_id?: + | /** + * The xact_id when this function completed (matches triggered_xact_id if done) + */ + /** + * The xact_id when this function completed (matches triggered_xact_id if done) + */ + (| string + /** + * The xact_id when this function completed (matches triggered_xact_id if done) + */ + | null + ) + | undefined; + idempotency_key?: + | /** + * Deterministic key of the function definition + input version used to skip unchanged reruns + */ + /** + * Deterministic key of the function definition + input version used to skip unchanged reruns + */ + (| string + /** + * Deterministic key of the function definition + input version used to skip unchanged reruns + */ + | null + ) + | undefined; + /** + * Number of execution attempts (for retry tracking) + * + * @default 0 + * @minimum 0 + */ + attempts: number; + /** + * The scope of data this function operates on + */ + scope: + | { + /** + * @enum span + */ + type: "span"; + } + | { + /** + * @enum trace + */ + type: "trace"; + } + | { + /** + * @enum group + */ + type: "group"; + key: string; + value: string; + }; +}; +export type AsyncScoringStateType = + | { + /** + * @enum enabled + */ + status: "enabled"; + token: string; + function_ids: Array; + skip_logging?: (boolean | null) | undefined; + triggered_functions?: ({} | null) | undefined; + last_triggered_xact_id?: + | /** + * The xact_id of the last non-score change to this row (excludes scorer score merges) + */ + (string | number | null) + | undefined; + } + | { + /** + * @enum disabled + */ + status: "disabled"; + } + | null + | null; +export type AsyncScoringControlType = + | { + /** + * @enum score_update + */ + kind: "score_update"; + token?: string | undefined; + } + | { + /** + * @enum state_override + */ + kind: "state_override"; + state: AsyncScoringStateType; + } + | { + /** + * @enum state_force_reselect + */ + kind: "state_force_reselect"; + } + | { + /** + * @enum state_enabled_force_rescore + */ + kind: "state_enabled_force_rescore"; + } + | { + /** + * @enum trigger_functions + */ + kind: "trigger_functions"; + triggered_functions: Array<{ + function_id?: unknown | undefined; + scope: + | { + /** + * @enum span + */ + type: "span"; + } + | { + /** + * @enum trace + */ + type: "trace"; + }; + idempotency_key?: string | undefined; + }>; + } + | { + /** + * @enum complete_triggered_functions + */ + kind: "complete_triggered_functions"; + function_ids: Array; + triggered_xact_id: string; + } + | { + /** + * @enum mark_attempt_failed + */ + kind: "mark_attempt_failed"; + function_ids: Array; + }; +export type BraintrustAttachmentReferenceType = { + /** + * An identifier to help disambiguate parsing. + * + * @enum braintrust_attachment + */ + type: "braintrust_attachment"; + /** + * Human-readable filename for user interfaces. Not related to attachment storage. + * + * @minLength 1 + */ + filename: string; + /** + * MIME type of this file. + * + * @minLength 1 + */ + content_type: string; + /** + * Key in the object store bucket for this attachment. + * + * @minLength 1 + */ + key: string; +}; +export type ExternalAttachmentReferenceType = { + /** + * An identifier to help disambiguate parsing. + * + * @enum external_attachment + */ + type: "external_attachment"; + /** + * Human-readable filename for user interfaces. Not related to attachment storage. + * + * @minLength 1 + */ + filename: string; + /** + * MIME type of this file. + * + * @minLength 1 + */ + content_type: string; + /** + * Fully qualified URL to the object in the external object store. + * + * @minLength 1 + */ + url: string; +}; +export type AttachmentReferenceType = + | BraintrustAttachmentReferenceType + | ExternalAttachmentReferenceType; +export type UploadStatusType = + /** + * @enum uploading, done, error + */ + "uploading" | "done" | "error"; +export type AttachmentStatusType = { + upload_status: UploadStatusType; + error_message?: /** + * Describes the error encountered while uploading. + */ + string | undefined; +}; +export type AutomationStatusType = + /** + * Whether the automation is active or paused. + * + * @enum active, paused + */ + "active" | "paused"; +export type FunctionTypeEnumType = + /** + * The type of global function. Defaults to 'scorer'. + * + * @default "scorer" + * @enum llm, scorer, task, tool, custom_view, preprocessor, facet, classifier, tag, parameters, sandbox + */ + | "llm" + | "scorer" + | "task" + | "tool" + | "custom_view" + | "preprocessor" + | "facet" + | "classifier" + | "tag" + | "parameters" + | "sandbox"; +export type FacetPreprocessorIdType = + /** + * The saved, global, or inline preprocessor to use for facet extraction. If not provided, the project default preprocessor will be used, falling back to the global 'thread' preprocessor. + */ + | { + /** + * @enum function + */ + type: "function"; + id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + function_type: FunctionTypeEnumType; + } + | { + /** + * @enum inline + */ + type: "inline"; + /** + * The complete JavaScript preprocessor implementation, including its handler. + * + * @minLength 1 + */ + code: string; + } + | null; +export type TopicMapGenerationSettingsType = { + /** + * @enum hdbscan, kmeans, community + */ + algorithm: "hdbscan" | "kmeans" | "community"; + /** + * @enum umap, pca, none + */ + dimension_reduction: "umap" | "pca" | "none"; + sample_size?: number | undefined; + n_clusters?: number | undefined; + min_cluster_size?: number | undefined; + min_samples?: number | undefined; + hierarchy_threshold?: number | undefined; + naming_model?: string | undefined; +}; +export type TopicMapDataType = { + /** + * @enum topic_map + */ + type: "topic_map"; + /** + * The facet field name to use as input for classification + */ + source_facet: string; + /** + * The embedding model to use for embedding facet values + */ + embedding_model: string; + bundle_key?: /** + * Key of the topic map bundle in code_bundles bucket + */ + string | undefined; + report_key?: /** + * Key of the clustering report in code_bundles bucket + */ + string | undefined; + topic_names?: /** + * Mapping from topic_id to topic name + */ + {} | undefined; + generation_settings?: TopicMapGenerationSettingsType | undefined; + disable_reconciliation?: /** + * Whether new topic generation should ignore the previously saved report during reconciliation. Defaults to false when omitted. + */ + boolean | undefined; + reconcile_mode?: + | /** + * How reconciliation carries the previous map forward: "evolve" re-routes new samples into the previous topics before naming; "names_only" keeps the fresh clustering and carries only topic ids/names. Defaults to "names_only" when omitted. + * + * @enum evolve, names_only + */ + ("evolve" | "names_only") + | undefined; + distance_threshold?: /** + * Maximum distance to nearest centroid. If exceeded, returns no_match. + */ + number | undefined; + btql_filter?: /** + * Per-topic-map BTQL filter that was applied when this version was generated. Absent on versions generated before this was recorded. + */ + string | undefined; + automation_btql_filter?: /** + * Automation-level BTQL filter that was applied when this version was generated. Absent on versions generated before this was recorded. + */ + string | undefined; +}; +export type BatchedFacetDataType = { + /** + * @enum batched_facet + */ + type: "batched_facet"; + preprocessor?: FacetPreprocessorIdType | undefined; + facets: Array<{ + /** + * The name of the facet + */ + name: string; + /** + * The prompt to use for LLM extraction. The preprocessed text will be provided as context. + */ + prompt: string; + model?: /** + * The model to use for facet extraction + */ + string | undefined; + embedding_model?: /** + * The embedding model to use for vectorizing facet results. + */ + string | undefined; + no_match_pattern?: /** + * Regex pattern to identify outputs that do not match the facet. If the output matches, the facet will be saved as 'no_match' + */ + string | undefined; + }>; + topic_maps?: /** + * Topic maps that depend on facets in this batch, keyed by source facet name. Each source facet can have multiple topic maps. + */ + {} | undefined; +}; +export type BraintrustModelParamsType = Partial<{ + use_cache: boolean; + reasoning_enabled: boolean; + reasoning_budget: number; +}>; +export type CallEventType = + | { + id?: string | undefined; + data: string; + /** + * @enum text_delta + */ + event: "text_delta"; + } + | { + id?: string | undefined; + data: string; + /** + * @enum reasoning_delta + */ + event: "reasoning_delta"; + } + | { + id?: string | undefined; + data: string; + /** + * @enum json_delta + */ + event: "json_delta"; + } + | { + id?: string | undefined; + data: string; + /** + * @enum progress + */ + event: "progress"; + } + | { + id?: string | undefined; + data: string; + /** + * @enum error + */ + event: "error"; + } + | { + id?: string | undefined; + data: string; + /** + * @enum console + */ + event: "console"; + } + | { + id?: string | undefined; + /** + * @enum start + */ + event: "start"; + /** + * @enum + */ + data: ""; + } + | { + id?: string | undefined; + /** + * @enum done + */ + event: "done"; + /** + * @enum + */ + data: ""; + }; +export type ChatCompletionContentPartTextWithTitleType = { + /** + * @default "" + */ + text: string; + /** + * @enum text + */ + type: "text"; + cache_control?: + | { + /** + * @enum ephemeral + */ + type: "ephemeral"; + ttl?: + | /** + * @enum 5m, 1h + */ + ("5m" | "1h") + | undefined; + } + | undefined; +}; +export type ChatCompletionContentPartImageWithTitleType = { + image_url: { + url: string; + detail?: + | ( + | /** + * @enum auto + */ + "auto" + /** + * @enum low + */ + | "low" + /** + * @enum high + */ + | "high" + ) + | undefined; + }; + /** + * @enum image_url + */ + type: "image_url"; + cache_control?: + | { + /** + * @enum ephemeral + */ + type: "ephemeral"; + ttl?: + | /** + * @enum 5m, 1h + */ + ("5m" | "1h") + | undefined; + } + | undefined; +}; +export type ChatCompletionContentPartFileFileType = Partial<{ + file_data: string; + filename: string; + file_id: string; +}>; +export type ChatCompletionContentPartFileWithTitleType = { + file: ChatCompletionContentPartFileFileType; + /** + * @enum file + */ + type: "file"; + cache_control?: + | { + /** + * @enum ephemeral + */ + type: "ephemeral"; + ttl?: + | /** + * @enum 5m, 1h + */ + ("5m" | "1h") + | undefined; + } + | undefined; +}; +export type ChatCompletionContentPartType = + | ChatCompletionContentPartTextWithTitleType + | ChatCompletionContentPartImageWithTitleType + | ChatCompletionContentPartFileWithTitleType; +export type ChatCompletionContentPartTextType = { + /** + * @default "" + */ + text: string; + /** + * @enum text + */ + type: "text"; + cache_control?: + | { + /** + * @enum ephemeral + */ + type: "ephemeral"; + ttl?: + | /** + * @enum 5m, 1h + */ + ("5m" | "1h") + | undefined; + } + | undefined; +}; +export type ChatCompletionMessageToolCallType = { + id: string; + function: { + arguments: string; + name: string; + }; + /** + * @enum function + */ + type: "function"; +}; +export type ChatCompletionMessageReasoningType = Partial<{ + id: string; + content: string; +}>; +export type ChatCompletionMessageParamType = + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum system + */ + role: "system"; + name?: string | undefined; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum user + */ + role: "user"; + name?: string | undefined; + } + | { + /** + * @enum assistant + */ + role: "assistant"; + content?: + | (string | Array | null) + | undefined; + function_call?: + | { + arguments: string; + name: string; + } + | undefined; + name?: string | undefined; + tool_calls?: Array | undefined; + reasoning?: Array | undefined; + reasoning_signature?: string | undefined; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum tool + */ + role: "tool"; + /** + * @default "" + */ + tool_call_id: string; + } + | { + content: string | null; + name: string; + /** + * @enum function + */ + role: "function"; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum developer + */ + role: "developer"; + name?: string | undefined; + } + | { + /** + * @enum model + */ + role: "model"; + content?: (string | null) | undefined; + }; +export type ChatCompletionOpenAIMessageParamType = + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum system + */ + role: "system"; + name?: string | undefined; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum user + */ + role: "user"; + name?: string | undefined; + } + | { + /** + * @enum assistant + */ + role: "assistant"; + content?: + | (string | Array | null) + | undefined; + function_call?: + | { + arguments: string; + name: string; + } + | undefined; + name?: string | undefined; + tool_calls?: Array | undefined; + reasoning?: Array | undefined; + reasoning_signature?: string | undefined; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum tool + */ + role: "tool"; + /** + * @default "" + */ + tool_call_id: string; + } + | { + content: string | null; + name: string; + /** + * @enum function + */ + role: "function"; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum developer + */ + role: "developer"; + name?: string | undefined; + }; +export type ChatCompletionToolType = { + function: { + name: string; + description?: string | undefined; + parameters?: {} | undefined; + }; + /** + * @enum function + */ + type: "function"; +}; +export type CodeBundleType = { + runtime_context: { + /** + * @enum node, python, browser, quickjs + */ + runtime: "node" | "python" | "browser" | "quickjs"; + version: string; + }; + location: + | { + /** + * @enum experiment + */ + type: "experiment"; + eval_name: string; + position: + | { + /** + * @enum task + */ + type: "task"; + } + | { + /** + * @enum scorer + */ + type: "scorer"; + /** + * @minimum 0 + */ + index: number; + } + | { + /** + * @enum classifier + */ + type: "classifier"; + /** + * @minimum 0 + */ + index: number; + }; + } + | { + /** + * @enum function + */ + type: "function"; + /** + * @minimum 0 + */ + index: number; + } + | { + /** + * @enum sandbox + */ + type: "sandbox"; + sandbox_spec: + | { + /** + * @enum modal + */ + provider: "modal"; + /** + * sandbox snapshot ref + */ + snapshot_ref: string; + } + | { + /** + * @enum lambda + */ + provider: "lambda"; + }; + entrypoints?: /** + * Which entrypoints to execute in the sandbox + */ + Array | undefined; + eval_name: string; + parameters?: /** + * Parameter values for sandbox eval execution + */ + {} | undefined; + evaluator_definition?: /** + * Definition of current evaluator with parameters + */ + unknown | undefined; + }; + bundle_id?: (string | null) | undefined; + preview?: + | /** + * A preview of the code + */ + /** + * A preview of the code + */ + (| string + /** + * A preview of the code + */ + | null + ) + | undefined; +}; +export type DatasetType = { + /** + * Unique identifier for the dataset + */ + id: string; + /** + * Unique identifier for the project that the dataset belongs under + */ + project_id: string; + /** + * Name of the dataset. Within a project, dataset names are unique + */ + name: string; + description?: + | /** + * Textual description of the dataset + */ + /** + * Textual description of the dataset + */ + (| string + /** + * Textual description of the dataset + */ + | null + ) + | undefined; + created?: + | /** + * Date of dataset creation + */ + /** + * Date of dataset creation + */ + (| string + /** + * Date of dataset creation + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of dataset deletion, or null if the dataset is still active + */ + /** + * Date of dataset deletion, or null if the dataset is still active + */ + (| string + /** + * Date of dataset deletion, or null if the dataset is still active + */ + | null + ) + | undefined; + user_id?: + | /** + * Identifies the user who created the dataset + */ + /** + * Identifies the user who created the dataset + */ + (| string + /** + * Identifies the user who created the dataset + */ + | null + ) + | undefined; + tags?: + | /** + * A list of tags for the dataset + */ + /** + * A list of tags for the dataset + */ + (| Array + /** + * A list of tags for the dataset + */ + | null + ) + | undefined; + metadata?: + | /** + * User-controlled metadata about the dataset + */ + /** + * User-controlled metadata about the dataset + */ + (| {} + /** + * User-controlled metadata about the dataset + */ + | null + ) + | undefined; + /** + * URL slug for the dataset. used to construct dataset URLs + */ + url_slug: string; +}; +export type ObjectReferenceNullishType = + /** + * Indicates the event was copied from another object. + */ + /** + * Indicates the event was copied from another object. + */ + | { + /** + * Type of the object the event is originating from. + * + * @enum project_logs, experiment, dataset, prompt, function, prompt_session + */ + object_type: + | "project_logs" + | "experiment" + | "dataset" + | "prompt" + | "function" + | "prompt_session"; + /** + * ID of the object the event is originating from. + */ + object_id: string; + /** + * ID of the original event. + */ + id: string; + _xact_id?: + | /** + * Transaction ID of the original event. + */ + /** + * Transaction ID of the original event. + */ + (| string + /** + * Transaction ID of the original event. + */ + | null + ) + | undefined; + created?: + | /** + * Created timestamp of the original event. Used to help sort in the UI + */ + /** + * Created timestamp of the original event. Used to help sort in the UI + */ + (| string + /** + * Created timestamp of the original event. Used to help sort in the UI + */ + | null + ) + | undefined; + } + /** + * Indicates the event was copied from another object. + */ + | null; +export type SavedFunctionIdType = + | { + /** + * @enum function + */ + type: "function"; + id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + function_type: FunctionTypeEnumType; + }; +export type DatasetEventType = { + /** + * A unique identifier for the dataset event. If you don't provide one, Braintrust will generate one for you + */ + id: string; + /** + * 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) + */ + _xact_id: string; + /** + * The timestamp the dataset event was created + */ + created: string; + _pagination_key?: + | /** + * A stable, time-ordered key that can be used to paginate over dataset events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + /** + * A stable, time-ordered key that can be used to paginate over dataset events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + (| string + /** + * A stable, time-ordered key that can be used to paginate over dataset events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + | null + ) + | undefined; + /** + * Unique identifier for the project that the dataset belongs under + */ + project_id: string; + /** + * Unique identifier for the dataset + */ + dataset_id: string; + input?: /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + */ + unknown | undefined; + expected?: /** + * The output of your application, including post-processing (an arbitrary, JSON serializable object) + */ + unknown | undefined; + 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'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 + */ + /** + * 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 + */ + (| Partial< + { + /** + * The model used for this example + */ + model: /** + * The model used for this example + */ + | string + /** + * The model used for this example + */ + | null; + } & { + [key: string]: any; + } + > + /** + * 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 + */ + | null + ) + | undefined; + tags?: + | /** + * A list of tags to log + */ + /** + * A list of tags to log + */ + (| Array + /** + * A list of tags to log + */ + | null + ) + | undefined; + /** + * A unique identifier used to link different dataset events together as part of a full trace. See the [tracing guide](https://www.braintrust.dev/docs/instrument) for full details on tracing + */ + span_id: string; + /** + * A unique identifier for the trace this dataset event belongs to + */ + root_span_id: string; + is_root?: + | /** + * Whether this span is a root span + */ + /** + * Whether this span is a root span + */ + (| boolean + /** + * Whether this span is a root span + */ + | null + ) + | undefined; + origin?: ObjectReferenceNullishType | undefined; + comments?: + | /** + * Optional list of comments attached to this event + */ + /** + * Optional list of comments attached to this event + */ + (| Array + /** + * Optional list of comments attached to this event + */ + | null + ) + | undefined; + audit_data?: + | /** + * Optional list of audit entries attached to this event + */ + /** + * Optional list of audit entries attached to this event + */ + (| Array + /** + * Optional list of audit entries attached to this event + */ + | null + ) + | undefined; + facets?: + | /** + * Facets for categorization (dictionary from facet id to value) + */ + /** + * Facets for categorization (dictionary from facet id to value) + */ + (| {} + /** + * Facets for categorization (dictionary from facet id to value) + */ + | null + ) + | undefined; + classifications?: + | /** + * Classifications for this event (dictionary from classification name to items) + */ + /** + * Classifications for this event (dictionary from classification name to items) + */ + (| {} + /** + * Classifications for this event (dictionary from classification name to items) + */ + | null + ) + | undefined; +}; +export type DatasetSnapshotType = { + /** + * Unique identifier for the dataset snapshot + */ + id: string; + /** + * Unique identifier for the dataset that this snapshot belongs to + */ + dataset_id: string; + /** + * Name of the dataset snapshot + */ + name: string; + description: string | null; + /** + * Transaction id of the brainstore version at the time of the snapshot + */ + xact_id: string; + /** + * Date of dataset snapshot creation + */ + created: /** + * Date of dataset snapshot creation + */ + | string + /** + * Date of dataset snapshot creation + */ + | null; +}; +export type EnvVarType = { + /** + * Unique identifier for the environment variable + */ + id: string; + /** + * The type of the object the environment variable is scoped for + * + * @enum organization, project, function + */ + object_type: "organization" | "project" | "function"; + /** + * The id of the object the environment variable is scoped for + */ + object_id: string; + /** + * The name of the environment variable + */ + name: string; + created?: + | /** + * Date of environment variable creation + */ + /** + * Date of environment variable creation + */ + (| string + /** + * Date of environment variable creation + */ + | null + ) + | undefined; + secret_updated_at?: + | /** + * Date of last update to the encrypted secret value itself + */ + /** + * Date of last update to the encrypted secret value itself + */ + (| string + /** + * Date of last update to the encrypted secret value itself + */ + | null + ) + | undefined; + secret_updated_by_user_id?: + | /** + * User id of the last update to the encrypted secret value + */ + /** + * User id of the last update to the encrypted secret value + */ + (| string + /** + * User id of the last update to the encrypted secret value + */ + | null + ) + | undefined; + used?: + | /** + * Date the environment variable was last used + */ + /** + * Date the environment variable was last used + */ + (| string + /** + * Date the environment variable was last used + */ + | null + ) + | undefined; + metadata?: + | /** + * Optional metadata associated with the environment variable when managed via the function secrets API + */ + /** + * Optional metadata associated with the environment variable when managed via the function secrets API + */ + (| {} + /** + * Optional metadata associated with the environment variable when managed via the function secrets API + */ + | null + ) + | undefined; + preview_secret?: + | /** + * Redacted preview of the stored secret value + */ + /** + * Redacted preview of the stored secret value + */ + (| string + /** + * Redacted preview of the stored secret value + */ + | null + ) + | undefined; + secret_type?: + | /** + * Optional classification for the secret (for example, the AI provider name) + */ + /** + * Optional classification for the secret (for example, the AI provider name) + */ + (| string + /** + * Optional classification for the secret (for example, the AI provider name) + */ + | null + ) + | undefined; + /** + * The category of the secret: env_var for regular environment variables, ai_provider for AI provider API keys + * + * @default "env_var" + * @enum env_var, ai_provider, sandbox_provider + */ + secret_category: "env_var" | "ai_provider" | "sandbox_provider"; +}; +export type RepoInfoType = + /** + * Metadata about the state of the repo when the experiment was created + */ + /** + * Metadata about the state of the repo when the experiment was created + */ + | Partial<{ + /** + * SHA of most recent commit + */ + commit: /** + * SHA of most recent commit + */ + | string + /** + * SHA of most recent commit + */ + | null; + /** + * Name of the branch the most recent commit belongs to + */ + branch: /** + * Name of the branch the most recent commit belongs to + */ + | string + /** + * Name of the branch the most recent commit belongs to + */ + | null; + /** + * Name of the tag on the most recent commit + */ + tag: /** + * Name of the tag on the most recent commit + */ + | string + /** + * Name of the tag on the most recent commit + */ + | null; + /** + * Whether or not the repo had uncommitted changes when snapshotted + */ + dirty: /** + * Whether or not the repo had uncommitted changes when snapshotted + */ + | boolean + /** + * Whether or not the repo had uncommitted changes when snapshotted + */ + | null; + /** + * Name of the author of the most recent commit + */ + author_name: /** + * Name of the author of the most recent commit + */ + | string + /** + * Name of the author of the most recent commit + */ + | null; + /** + * Email of the author of the most recent commit + */ + author_email: /** + * Email of the author of the most recent commit + */ + | string + /** + * Email of the author of the most recent commit + */ + | null; + /** + * Most recent commit message + */ + commit_message: /** + * Most recent commit message + */ + | string + /** + * Most recent commit message + */ + | null; + /** + * Time of the most recent commit + */ + commit_time: /** + * Time of the most recent commit + */ + | string + /** + * Time of the most recent commit + */ + | null; + /** + * If the repo was dirty when run, this includes the diff between the current state of the repo and the most recent commit. + */ + git_diff: /** + * If the repo was dirty when run, this includes the diff between the current state of the repo and the most recent commit. + */ + | string + /** + * If the repo was dirty when run, this includes the diff between the current state of the repo and the most recent commit. + */ + | null; + }> + /** + * Metadata about the state of the repo when the experiment was created + */ + | null; +export type ExperimentType = { + /** + * Unique identifier for the experiment + */ + id: string; + /** + * Unique identifier for the project that the experiment belongs under + */ + project_id: string; + /** + * Name of the experiment. Within a project, experiment names are unique + */ + name: string; + description?: + | /** + * Textual description of the experiment + */ + /** + * Textual description of the experiment + */ + (| string + /** + * Textual description of the experiment + */ + | null + ) + | undefined; + created?: + | /** + * Date of experiment creation + */ + /** + * Date of experiment creation + */ + (| string + /** + * Date of experiment creation + */ + | null + ) + | undefined; + repo_info?: RepoInfoType | undefined; + commit?: + | /** + * Commit, taken directly from `repo_info.commit` + */ + /** + * Commit, taken directly from `repo_info.commit` + */ + (| string + /** + * Commit, taken directly from `repo_info.commit` + */ + | null + ) + | undefined; + base_exp_id?: + | /** + * Id of default base experiment to compare against when viewing this experiment + */ + /** + * Id of default base experiment to compare against when viewing this experiment + */ + (| string + /** + * Id of default base experiment to compare against when viewing this experiment + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of experiment deletion, or null if the experiment is still active + */ + /** + * Date of experiment deletion, or null if the experiment is still active + */ + (| string + /** + * Date of experiment deletion, or null if the experiment is still active + */ + | null + ) + | undefined; + dataset_id?: + | /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + (| string + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + | null + ) + | undefined; + dataset_version?: + | /** + * 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. + */ + /** + * 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. + */ + (| string + /** + * 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. + */ + | null + ) + | undefined; + internal_metadata?: + | /** + * Braintrust-controlled metadata about the experiment. + */ + /** + * Braintrust-controlled metadata about the experiment. + */ + (| Partial< + { + /** + * BTQL filter payload used to evaluate a subset of a linked dataset. + */ + dataset_filter: /** + * BTQL filter payload used to evaluate a subset of a linked dataset. + */ + | {} + /** + * BTQL filter payload used to evaluate a subset of a linked dataset. + */ + | null; + } & { + [key: string]: any; + } + > + /** + * Braintrust-controlled metadata about the experiment. + */ + | null + ) + | undefined; + parameters_id?: + | /** + * Identifier of the linked saved parameters object, or null if the experiment is not linked to saved parameters + */ + /** + * Identifier of the linked saved parameters object, or null if the experiment is not linked to saved parameters + */ + (| string + /** + * Identifier of the linked saved parameters object, or null if the experiment is not linked to saved parameters + */ + | null + ) + | undefined; + parameters_version?: + | /** + * Version number of the linked saved parameters object the experiment was run against. + */ + /** + * Version number of the linked saved parameters object the experiment was run against. + */ + (| string + /** + * Version number of the linked saved parameters object the experiment was run against. + */ + | null + ) + | undefined; + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside or outside the organization + */ + public: boolean; + user_id?: + | /** + * Identifies the user who created the experiment + */ + /** + * Identifies the user who created the experiment + */ + (| string + /** + * Identifies the user who created the experiment + */ + | null + ) + | undefined; + metadata?: + | /** + * User-controlled metadata about the experiment + */ + /** + * User-controlled metadata about the experiment + */ + (| {} + /** + * User-controlled metadata about the experiment + */ + | null + ) + | undefined; + tags?: + | /** + * A list of tags for the experiment + */ + /** + * A list of tags for the experiment + */ + (| Array + /** + * A list of tags for the experiment + */ + | null + ) + | undefined; +}; +export type SpanTypeType = + /** + * Type of the span, for display purposes only + * + * @enum llm, score, function, eval, task, tool, automation, facet, preprocessor, classifier, review + */ + | /** + * Type of the span, for display purposes only + * + * @enum llm, score, function, eval, task, tool, automation, facet, preprocessor, classifier, review + */ + (| "llm" + | "score" + | "function" + | "eval" + | "task" + | "tool" + | "automation" + | "facet" + | "preprocessor" + | "classifier" + | "review" + ) + /** + * Type of the span, for display purposes only + * + * @enum llm, score, function, eval, task, tool, automation, facet, preprocessor, classifier, review + */ + | null; +export type SpanAttributesType = + /** + * Human-identifying attributes of the span, such as name, type, etc. + */ + /** + * Human-identifying attributes of the span, such as name, type, etc. + */ + | Partial< + { + /** + * Name of the span, for display purposes only + */ + name: /** + * Name of the span, for display purposes only + */ + | string + /** + * Name of the span, for display purposes only + */ + | null; + type: SpanTypeType; + /** + * A special value that indicates the span was generated by a scoring automation + * + * @enum scorer + */ + purpose: + | /** + * A special value that indicates the span was generated by a scoring automation + * + * @enum scorer + */ + "scorer" + /** + * A special value that indicates the span was generated by a scoring automation + * + * @enum scorer + */ + | null; + } & { + [key: string]: any; + } + > + /** + * Human-identifying attributes of the span, such as name, type, etc. + */ + | null; +export type ExperimentEventType = { + /** + * A unique identifier for the experiment event. If you don't provide one, Braintrust will generate one for you + */ + id: string; + /** + * 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) + */ + _xact_id: string; + /** + * The timestamp the experiment event was created + */ + created: string; + _pagination_key?: + | /** + * A stable, time-ordered key that can be used to paginate over experiment events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + /** + * A stable, time-ordered key that can be used to paginate over experiment events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + (| string + /** + * A stable, time-ordered key that can be used to paginate over experiment events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + | null + ) + | undefined; + /** + * Unique identifier for the project that the experiment belongs under + */ + project_id: string; + /** + * Unique identifier for the experiment + */ + experiment_id: string; + input?: /** + * 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 + */ + unknown | undefined; + 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 `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 + */ + unknown | undefined; + expected?: /** + * 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 + */ + unknown | undefined; + error?: /** + * The error that occurred, if any. + */ + unknown | undefined; + 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 + */ + /** + * 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 + */ + (| {} + /** + * 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 + */ + | null + ) + | undefined; + 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'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 + */ + /** + * 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 + */ + (| Partial< + { + /** + * The model used for this example + */ + model: /** + * The model used for this example + */ + | string + /** + * The model used for this example + */ + | null; + } & { + [key: string]: any; + } + > + /** + * 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 + */ + | null + ) + | undefined; + tags?: + | /** + * A list of tags to log + */ + /** + * A list of tags to log + */ + (| Array + /** + * A list of tags to log + */ + | null + ) + | undefined; + 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 + */ + (| /** + * 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 + */ + ({} & { + [key: string]: number; + }) + /** + * 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 + */ + | null + ) + | undefined; + context?: + | /** + * 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 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 + */ + (| Partial< + { + /** + * The function in code which created the experiment event + */ + caller_functionname: /** + * The function in code which created the experiment event + */ + | string + /** + * The function in code which created the experiment event + */ + | null; + /** + * Name of the file in code where the experiment event was created + */ + caller_filename: /** + * Name of the file in code where the experiment event was created + */ + | string + /** + * Name of the file in code where the experiment event was created + */ + | null; + /** + * Line of code where the experiment event was created + */ + caller_lineno: /** + * Line of code where the experiment event was created + */ + | number + /** + * Line of code where the experiment event was created + */ + | null; + } & { + [key: string]: any; + } + > + /** + * 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 + */ + | null + ) + | undefined; + /** + * A unique identifier used to link different experiment events together as part of a full trace. See the [tracing guide](https://www.braintrust.dev/docs/instrument) for full details on tracing + */ + span_id: string; + span_parents?: + | /** + * 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 + */ + /** + * 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 + */ + (| Array + /** + * 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 + */ + | null + ) + | undefined; + /** + * A unique identifier for the trace this experiment event belongs to + */ + root_span_id: string; + span_attributes?: SpanAttributesType | undefined; + is_root?: + | /** + * Whether this span is a root span + */ + /** + * Whether this span is a root span + */ + (| boolean + /** + * Whether this span is a root span + */ + | null + ) + | undefined; + origin?: ObjectReferenceNullishType | undefined; + comments?: + | /** + * Optional list of comments attached to this event + */ + /** + * Optional list of comments attached to this event + */ + (| Array + /** + * Optional list of comments attached to this event + */ + | null + ) + | undefined; + audit_data?: + | /** + * Optional list of audit entries attached to this event + */ + /** + * Optional list of audit entries attached to this event + */ + (| Array + /** + * Optional list of audit entries attached to this event + */ + | null + ) + | undefined; + facets?: + | /** + * Facets for categorization (dictionary from facet id to value) + */ + /** + * Facets for categorization (dictionary from facet id to value) + */ + (| {} + /** + * Facets for categorization (dictionary from facet id to value) + */ + | null + ) + | undefined; + classifications?: + | /** + * Classifications for this event (dictionary from classification name to items) + */ + /** + * Classifications for this event (dictionary from classification name to items) + */ + (| {} + /** + * Classifications for this event (dictionary from classification name to items) + */ + | null + ) + | undefined; +}; +export type ExtendedSavedFunctionIdType = + | { + /** + * @enum function + */ + type: "function"; + id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + function_type: FunctionTypeEnumType; + } + | { + /** + * @enum slug + */ + type: "slug"; + project_id: string; + slug: string; + }; +export type FacetDataType = { + /** + * @enum facet + */ + type: "facet"; + preprocessor?: FacetPreprocessorIdType | undefined; + /** + * The prompt to use for LLM extraction. The preprocessed text will be provided as context. + */ + prompt: string; + model?: /** + * The model to use for facet extraction + */ + string | undefined; + embedding_model?: /** + * The embedding model to use for vectorizing facet results. + */ + string | undefined; + no_match_pattern?: /** + * Regex pattern to identify outputs that do not match the facet. If the output matches, the facet will be saved as 'no_match' + */ + string | undefined; +}; +export type PromptBlockDataNullishType = + | { + /** + * @enum chat + */ + type: "chat"; + messages: Array; + tools?: string | undefined; + } + | { + /** + * @enum completion + */ + type: "completion"; + content: string; + } + | null; +export type ModelParamsType = + | Partial< + { + use_cache: boolean; + reasoning_enabled: boolean; + reasoning_budget: number; + temperature: number; + top_p: number; + max_tokens: number; + /** + * The successor to max_tokens + */ + max_completion_tokens: number; + frequency_penalty: number; + presence_penalty: number; + response_format: ResponseFormatNullishType; + tool_choice: + | /** + * @enum auto + */ + "auto" + /** + * @enum none + */ + | "none" + /** + * @enum required + */ + | "required" + | { + /** + * @enum function + */ + type: "function"; + function: { + name: string; + }; + }; + function_call: + | /** + * @enum auto + */ + "auto" + /** + * @enum none + */ + | "none" + | { + name: string; + }; + n: number; + stop: Array; + /** + * @enum none, minimal, low, medium, high + */ + reasoning_effort: "none" | "minimal" | "low" | "medium" | "high"; + /** + * @enum low, medium, high + */ + verbosity: "low" | "medium" | "high"; + } & { + [key: string]: any; + } + > + | ({ + use_cache?: boolean | undefined; + reasoning_enabled?: boolean | undefined; + reasoning_budget?: number | undefined; + max_tokens: number; + temperature: number; + top_p?: number | undefined; + top_k?: number | undefined; + stop_sequences?: Array | undefined; + max_tokens_to_sample?: /** + * This is a legacy parameter that should not be used. + */ + number | undefined; + } & { + [key: string]: any; + }) + | Partial< + { + use_cache: boolean; + reasoning_enabled: boolean; + reasoning_budget: number; + temperature: number; + maxOutputTokens: number; + topP: number; + topK: number; + } & { + [key: string]: any; + } + > + | Partial< + { + use_cache: boolean; + reasoning_enabled: boolean; + reasoning_budget: number; + temperature: number; + topK: number; + } & { + [key: string]: any; + } + > + | Partial< + { + use_cache: boolean; + reasoning_enabled: boolean; + reasoning_budget: number; + } & { + [key: string]: any; + } + >; +export type PromptOptionsNullishType = Partial<{ + model: string; + params: ModelParamsType; + position: string; + endpoint_name: string | null; +}> | null; +export type PromptParserNullishType = { + /** + * @enum llm_classifier + */ + type: "llm_classifier"; + use_cot: boolean; + choice_scores?: /** + * Map of choices to scores (0-1). Used by scorers. + */ + {} | undefined; + choice?: /** + * List of valid choices without score mapping. Used by classifiers that deposit output to tags. + */ + Array | undefined; + allow_no_match?: /** + * If true, adds a 'No match' option. When selected, no tag is deposited. + */ + boolean | undefined; + allow_skip?: /** + * If true, adds a 'Skip' option. When selected, the scorer returns null. + */ + boolean | undefined; +} | null; +export type PreprocessorSavedFunctionIdType = + /** + * For prompt-backed scorers: the preprocessor function to use for trace template variables. Set to null to disable preprocessing. If omitted, the traced project's default preprocessor will be used, falling back to the global 'thread' preprocessor. + */ + | { + /** + * @enum function + */ + type: "function"; + id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + /** + * The type of global function. Defaults to 'preprocessor'. + * + * @default "preprocessor" + * @enum preprocessor + */ + function_type: "preprocessor"; + } + | null; +export type PromptDataNullishType = + /** + * The prompt, model, and its parameters + */ + /** + * The prompt, model, and its parameters + */ + | Partial<{ + prompt: PromptBlockDataNullishType; + options: PromptOptionsNullishType; + parser: PromptParserNullishType; + preprocessor: PreprocessorSavedFunctionIdType; + tool_functions: Array | null; + /** + * @enum mustache, nunjucks, none + */ + template_format: + | /** + * @enum mustache, nunjucks, none + */ + ("mustache" | "nunjucks" | "none") + /** + * @enum mustache, nunjucks, none + */ + | null; + mcp: {} | null; + origin: Partial<{ + prompt_id: string; + project_id: string; + prompt_version: string; + }> | null; + }> + /** + * The prompt, model, and its parameters + */ + | null; +export type FunctionTypeEnumNullishType = + /** + * @enum llm, scorer, task, tool, custom_view, preprocessor, facet, classifier, tag, parameters, sandbox + */ + | /** + * @enum llm, scorer, task, tool, custom_view, preprocessor, facet, classifier, tag, parameters, sandbox + */ + (| "llm" + | "scorer" + | "task" + | "tool" + | "custom_view" + | "preprocessor" + | "facet" + | "classifier" + | "tag" + | "parameters" + | "sandbox" + ) + /** + * @enum llm, scorer, task, tool, custom_view, preprocessor, facet, classifier, tag, parameters, sandbox + */ + | null; +export type FunctionIdRefType = Partial< + {} & { + [key: string]: any; + } +>; +export type PromptBlockDataType = + | { + /** + * @enum chat + */ + type: "chat"; + messages: Array; + tools?: string | undefined; + } + | { + /** + * @enum completion + */ + type: "completion"; + content: string; + }; +export type GraphNodeType = + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum function + */ + type: "function"; + function: FunctionIdRefType; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * The input to the graph + * + * @enum input + */ + type: "input"; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * The output of the graph + * + * @enum output + */ + type: "output"; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum literal + */ + type: "literal"; + value?: /** + * A literal value to be returned + */ + unknown | undefined; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum btql + */ + type: "btql"; + /** + * A BTQL expression to be evaluated + */ + expr: string; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum gate + */ + type: "gate"; + condition?: + | /** + * A BTQL expression to be evaluated + */ + /** + * A BTQL expression to be evaluated + */ + (| string + /** + * A BTQL expression to be evaluated + */ + | null + ) + | undefined; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum aggregator + */ + type: "aggregator"; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum prompt_template + */ + type: "prompt_template"; + prompt: PromptBlockDataType; + }; +export type GraphEdgeType = { + source: { + /** + * The id of the node in the graph + * + * @maxLength 1024 + */ + node: string; + variable: string; + }; + target: { + /** + * The id of the node in the graph + * + * @maxLength 1024 + */ + node: string; + variable: string; + }; + /** + * The purpose of the edge + * + * @enum control, data, messages + */ + purpose: "control" | "data" | "messages"; +}; +export type GraphDataType = { + /** + * @enum graph + */ + type: "graph"; + nodes: {}; + edges: {}; +}; +export type FunctionDataType = + | { + /** + * @enum prompt + */ + type: "prompt"; + } + | { + /** + * @enum code + */ + type: "code"; + data: + | ({ + /** + * @enum bundle + */ + type: "bundle"; + } & CodeBundleType) + | { + /** + * @enum inline + */ + type: "inline"; + runtime_context: { + /** + * @enum node, python, browser, quickjs + */ + runtime: "node" | "python" | "browser" | "quickjs"; + version: string; + }; + code: string; + code_hash?: /** + * SHA256 hash of the code, computed at save time + */ + string | undefined; + }; + } + | GraphDataType + /** + * A remote eval to run + */ + | { + /** + * @enum remote_eval + */ + type: "remote_eval"; + endpoint: string; + eval_name: string; + parameters: {}; + parameters_version?: + | /** + * The version (transaction ID) of the parameters being used + */ + /** + * The version (transaction ID) of the parameters being used + */ + (| string + /** + * The version (transaction ID) of the parameters being used + */ + | null + ) + | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + function_type: FunctionTypeEnumType; + config?: + | /** + * Configuration options to pass to the global function (e.g., for preprocessor customization) + */ + /** + * Configuration options to pass to the global function (e.g., for preprocessor customization) + */ + (| {} + /** + * Configuration options to pass to the global function (e.g., for preprocessor customization) + */ + | null + ) + | undefined; + } + | FacetDataType + | BatchedFacetDataType + | { + /** + * @enum parameters + */ + type: "parameters"; + /** + * The parameters data + */ + data: {}; + /** + * JSON Schema format for parameters + */ + __schema: { + /** + * @enum object + */ + type: "object"; + properties: {}; + required?: Array | undefined; + additionalProperties?: boolean | undefined; + }; + } + | (TopicMapDataType & unknown); +export type FunctionType = { + /** + * Unique identifier for the prompt + */ + id: string; + /** + * 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 prompt (see the `version` parameter) + */ + _xact_id: string; + /** + * Unique identifier for the project that the prompt belongs under + */ + project_id: string; + /** + * A literal 'p' which identifies the object as a project prompt + * + * @enum p + */ + log_id: "p"; + /** + * Unique identifier for the organization + */ + org_id: string; + /** + * Name of the prompt + */ + name: string; + /** + * Unique identifier for the prompt + */ + slug: string; + description?: + | /** + * Textual description of the prompt + */ + /** + * Textual description of the prompt + */ + (| string + /** + * Textual description of the prompt + */ + | null + ) + | undefined; + created?: + | /** + * Date of prompt creation + */ + /** + * Date of prompt creation + */ + (| string + /** + * Date of prompt creation + */ + | null + ) + | undefined; + prompt_data?: PromptDataNullishType | undefined; + tags?: + | /** + * A list of tags for the prompt + */ + /** + * A list of tags for the prompt + */ + (| Array + /** + * A list of tags for the prompt + */ + | null + ) + | undefined; + metadata?: + | /** + * User-controlled metadata about the prompt + */ + /** + * User-controlled metadata about the prompt + */ + (| {} + /** + * User-controlled metadata about the prompt + */ + | null + ) + | undefined; + function_type?: FunctionTypeEnumNullishType | undefined; + function_data: FunctionDataType; + origin?: + | ({ + object_type: AclObjectTypeType & string; + /** + * Id of the object the function is originating from + */ + object_id: string; + internal?: + | /** + * The function exists for internal purposes and should not be displayed in the list of functions. + */ + /** + * The function exists for internal purposes and should not be displayed in the list of functions. + */ + (| boolean + /** + * The function exists for internal purposes and should not be displayed in the list of functions. + */ + | null + ) + | undefined; + } | null) + | undefined; + function_schema?: + | /** + * JSON schema for the function's parameters and return type + */ + /** + * JSON schema for the function's parameters and return type + */ + (| Partial<{ + parameters: unknown; + returns: unknown; + }> + /** + * JSON schema for the function's parameters and return type + */ + | null + ) + | undefined; +}; +export type FunctionFormatType = + /** + * @enum llm, code, global, graph, topic_map + */ + "llm" | "code" | "global" | "graph" | "topic_map"; +export type PromptDataType = Partial<{ + prompt: PromptBlockDataNullishType; + options: PromptOptionsNullishType; + parser: PromptParserNullishType; + preprocessor: PreprocessorSavedFunctionIdType; + tool_functions: Array | null; + /** + * @enum mustache, nunjucks, none + */ + template_format: + | /** + * @enum mustache, nunjucks, none + */ + ("mustache" | "nunjucks" | "none") + /** + * @enum mustache, nunjucks, none + */ + | null; + mcp: {} | null; + origin: Partial<{ + prompt_id: string; + project_id: string; + prompt_version: string; + }> | null; +}>; +export type FunctionIdType = + /** + * Options for identifying a function + */ + /** + * Function id + */ + | { + /** + * The ID of the function + */ + function_id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + /** + * Project name and slug + */ + | { + /** + * The name of the project containing the function + */ + project_name: string; + /** + * The slug of the function + */ + slug: string; + version?: /** + * The version of the function + */ + string | undefined; + } + /** + * Global function name + */ + | { + /** + * The name of the global function. Currently, the global namespace includes the functions in autoevals + */ + global_function: string; + function_type: FunctionTypeEnumType; + } + /** + * Prompt session id + */ + | { + /** + * The ID of the prompt session + */ + prompt_session_id: string; + /** + * The ID of the function in the prompt session + */ + prompt_session_function_id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + /** + * Inline code function + */ + | { + inline_context: { + /** + * @enum node, python, browser, quickjs + */ + runtime: "node" | "python" | "browser" | "quickjs"; + version: string; + }; + /** + * The inline code to execute + */ + code: string; + function_type?: + | (FunctionTypeEnumType & + /** + * The function type for inline code. Required when invoking inline preprocessors. + */ unknown) + | undefined; + name?: + | /** + * The name of the inline code function + */ + /** + * The name of the inline code function + */ + (| string + /** + * The name of the inline code function + */ + | null + ) + | undefined; + } + /** + * Inline function definition + */ + | { + inline_prompt?: PromptDataType | undefined; + inline_function: {}; + function_type: FunctionTypeEnumType; + name?: + | /** + * The name of the inline function + */ + /** + * The name of the inline function + */ + (| string + /** + * The name of the inline function + */ + | null + ) + | undefined; + } + /** + * Inline prompt definition + */ + | { + inline_prompt: PromptDataType; + function_type: FunctionTypeEnumType; + name?: + | /** + * The name of the inline prompt + */ + /** + * The name of the inline prompt + */ + (| string + /** + * The name of the inline prompt + */ + | null + ) + | undefined; + }; +export type FunctionObjectTypeType = + /** + * @enum prompt, tool, scorer, task, workflow, custom_view, preprocessor, facet, classifier, parameters, sandbox + */ + | "prompt" + | "tool" + | "scorer" + | "task" + | "workflow" + | "custom_view" + | "preprocessor" + | "facet" + | "classifier" + | "parameters" + | "sandbox"; +export type FunctionOutputTypeType = + /** + * @enum completion, score, facet, classification, any + */ + "completion" | "score" | "facet" | "classification" | "any"; +export type GitMetadataSettingsType = { + /** + * @enum all, none, some + */ + collect: "all" | "none" | "some"; + fields?: + | Array< + /** + * @enum commit, branch, tag, dirty, author_name, author_email, commit_message, commit_time, git_diff + */ + | "commit" + | "branch" + | "tag" + | "dirty" + | "author_name" + | "author_email" + | "commit_message" + | "commit_time" + | "git_diff" + > + | undefined; +}; +export type GroupType = { + /** + * Unique identifier for the group + */ + id: string; + /** + * Unique id for the organization that the group belongs under + + It is forbidden to change the org after creating a group + */ + org_id: string; + user_id?: + | /** + * Identifies the user who created the group + */ + /** + * Identifies the user who created the group + */ + (| string + /** + * Identifies the user who created the group + */ + | null + ) + | undefined; + created?: + | /** + * Date of group creation + */ + /** + * Date of group creation + */ + (| string + /** + * Date of group creation + */ + | null + ) + | undefined; + /** + * Name of the group + */ + name: string; + description?: + | /** + * Textual description of the group + */ + /** + * Textual description of the group + */ + (| string + /** + * Textual description of the group + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of group deletion, or null if the group is still active + */ + /** + * Date of group deletion, or null if the group is still active + */ + (| string + /** + * Date of group deletion, or null if the group is still active + */ + | null + ) + | undefined; + member_users?: + | /** + * Ids of users which belong to this group + */ + /** + * Ids of users which belong to this group + */ + (| Array + /** + * Ids of users which belong to this group + */ + | null + ) + | undefined; + member_groups?: + | /** + * Ids of the groups this group inherits from + + An inheriting group has all the users contained in its member groups, as well as all of their inherited users + */ + /** + * Ids of the groups this group inherits from + + An inheriting group has all the users contained in its member groups, as well as all of their inherited users + */ + (| Array /** + * Ids of the groups this group inherits from + + An inheriting group has all the users contained in its member groups, as well as all of their inherited users + */ + | null + ) + | undefined; +}; +export type GroupScopeType = { + /** + * @enum group + */ + type: "group"; + /** + * Field path to group by, e.g. metadata.session_id + */ + group_by: string; + interval_seconds?: /** + * Maximum time range to include when constructing a group + * + * @minimum 1 + */ + number | undefined; + max_traces?: /** + * Maximum number of traces to include when constructing a group (default/max: 64) + * + * @minimum 1 + * @maximum 64 + */ + number | undefined; + /** + * Which trace or traces to write grouped scorer results to + * + * @enum first, each + */ + placement: "first" | "each"; + idle_seconds?: /** + * Optional: trigger after this many seconds of inactivity + */ + number | undefined; +}; +export type IfExistsType = + /** + * @enum error, ignore, replace + */ + "error" | "ignore" | "replace"; +export type ImageRenderingModeType = + /** + * Controls how images are rendered in the UI: 'auto' loads images automatically, 'click_to_load' shows a placeholder until clicked, 'blocked' prevents image loading entirely + * + * @enum auto, click_to_load, blocked + */ + | /** + * Controls how images are rendered in the UI: 'auto' loads images automatically, 'click_to_load' shows a placeholder until clicked, 'blocked' prevents image loading entirely + * + * @enum auto, click_to_load, blocked + */ + ("auto" | "click_to_load" | "blocked") + /** + * Controls how images are rendered in the UI: 'auto' loads images automatically, 'click_to_load' shows a placeholder until clicked, 'blocked' prevents image loading entirely + * + * @enum auto, click_to_load, blocked + */ + | null; +export type InvokeParentType = + /** + * Options for tracing the function call + */ + /** + * Span parent properties + */ + | { + /** + * @enum project_logs, experiment, playground_logs + */ + object_type: "project_logs" | "experiment" | "playground_logs"; + /** + * The id of the container object you are logging to + */ + object_id: string; + row_ids?: + | /** + * Identifiers for the row to to log a subspan under + */ + /** + * Identifiers for the row to to log a subspan under + */ + (| { + /** + * The id of the row + */ + id: string; + /** + * The span_id of the row + */ + span_id: string; + /** + * The root_span_id of the row + */ + root_span_id: string; + } + /** + * Identifiers for the row to to log a subspan under + */ + | null + ) + | undefined; + propagated_event?: + | /** + * Include these properties in every span created under this parent + */ + /** + * Include these properties in every span created under this parent + */ + (| {} + /** + * Include these properties in every span created under this parent + */ + | null + ) + | undefined; + } + /** + * The parent's span identifier, created by calling `.export()` on a span + */ + | string; +export type StreamingModeType = + /** + * The mode format of the returned value (defaults to 'auto') + * + * @enum auto, parallel, json, text + */ + | /** + * The mode format of the returned value (defaults to 'auto') + * + * @enum auto, parallel, json, text + */ + ("auto" | "parallel" | "json" | "text") + /** + * The mode format of the returned value (defaults to 'auto') + * + * @enum auto, parallel, json, text + */ + | null; +export type InvokeFunctionType = + /** + * Options for identifying a function + */ + FunctionIdType & + Partial<{ + /** + * Argument to the function, which can be any JSON serializable value + */ + input: unknown; + /** + * The expected output of the function + */ + expected: unknown; + /** + * Any relevant metadata. This will be logged and available as the `metadata` argument. + */ + metadata: /** + * Any relevant metadata. This will be logged and available as the `metadata` argument. + */ + | {} + /** + * Any relevant metadata. This will be logged and available as the `metadata` argument. + */ + | null; + /** + * Any relevant tags to log on the span. + */ + tags: /** + * Any relevant tags to log on the span. + */ + | Array + /** + * Any relevant tags to log on the span. + */ + | null; + /** + * If the function is an LLM, additional messages to pass along to it + */ + messages: Array; + parent: InvokeParentType; + /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE format. + */ + stream: /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE format. + */ + | boolean + /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE format. + */ + | null; + mode: StreamingModeType; + /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + strict: /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + | boolean + /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + | null; + /** + * Map of MCP server URL to auth credentials + */ + mcp_auth: {}; + /** + * Partial function definition to merge with the function being invoked. Fields are validated against the function type's schema at runtime. For facets: { preprocessor?, prompt?, model? }. For prompts: { model?, ... }. + */ + overrides: /** + * Partial function definition to merge with the function being invoked. Fields are validated against the function type's schema at runtime. For facets: { preprocessor?, prompt?, model? }. For prompts: { model?, ... }. + */ + | {} + /** + * Partial function definition to merge with the function being invoked. Fields are validated against the function type's schema at runtime. For facets: { preprocessor?, prompt?, model? }. For prompts: { model?, ... }. + */ + | null; + /** + * Name of the AI provider secret to pin this invocation to. + */ + endpoint_name: /** + * Name of the AI provider secret to pin this invocation to. + */ + | string + /** + * Name of the AI provider secret to pin this invocation to. + */ + | null; + }>; +export type MCPServerType = { + /** + * Unique identifier for the MCP server + */ + id: string; + /** + * Unique identifier for the project that the MCP server belongs under + */ + project_id: string; + user_id?: + | /** + * Identifies the user who created the MCP server + */ + /** + * Identifies the user who created the MCP server + */ + (| string + /** + * Identifies the user who created the MCP server + */ + | null + ) + | undefined; + created?: + | /** + * Date of MCP server creation + */ + /** + * Date of MCP server creation + */ + (| string + /** + * Date of MCP server creation + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of MCP server deletion, or null if the MCP server is still active + */ + /** + * Date of MCP server deletion, or null if the MCP server is still active + */ + (| string + /** + * Date of MCP server deletion, or null if the MCP server is still active + */ + | null + ) + | undefined; + /** + * Name of the MCP server. Within a project, MCP server names are unique + */ + name: string; + description?: + | /** + * Textual description of the MCP server + */ + /** + * Textual description of the MCP server + */ + (| string + /** + * Textual description of the MCP server + */ + | null + ) + | undefined; + /** + * URL of the MCP server endpoint + */ + url: string; +}; +export type MessageRoleType = + /** + * @enum system, user, assistant, function, tool, model, developer + */ + "system" | "user" | "assistant" | "function" | "tool" | "model" | "developer"; +export type NullableSavedFunctionIdType = + /** + * Default preprocessor for this project. When set, functions that use preprocessors will use this instead of their built-in default. + */ + | { + /** + * @enum function + */ + type: "function"; + id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + function_type: FunctionTypeEnumType; + } + | null; +export type ObjectReferenceType = { + /** + * Type of the object the event is originating from. + * + * @enum project_logs, experiment, dataset, prompt, function, prompt_session + */ + object_type: + | "project_logs" + | "experiment" + | "dataset" + | "prompt" + | "function" + | "prompt_session"; + /** + * ID of the object the event is originating from. + */ + object_id: string; + /** + * ID of the original event. + */ + id: string; + _xact_id?: + | /** + * Transaction ID of the original event. + */ + /** + * Transaction ID of the original event. + */ + (| string + /** + * Transaction ID of the original event. + */ + | null + ) + | undefined; + created?: + | /** + * Created timestamp of the original event. Used to help sort in the UI + */ + /** + * Created timestamp of the original event. Used to help sort in the UI + */ + (| string + /** + * Created timestamp of the original event. Used to help sort in the UI + */ + | null + ) + | undefined; +}; +export type SpanScopeType = { + /** + * @enum span + */ + type: "span"; +}; +export type TraceScopeType = { + /** + * @enum trace + */ + type: "trace"; + idle_seconds?: /** + * Consider trace complete after this many seconds of inactivity (default: 30) + */ + number | undefined; +}; +export type OnlineScoreConfigType = { + status?: AutomationStatusType | undefined; + /** + * The sampling rate for online scoring + * + * @minimum 0 + * @maximum 1 + */ + sampling_rate: number; + /** + * The list of functions to run for online scoring. Can include scorers, facets, or other function types. + */ + scorers: Array; + btql_filter?: + | /** + * Filter logs using BTQL + */ + /** + * Filter logs using BTQL + */ + (| string + /** + * Filter logs using BTQL + */ + | null + ) + | undefined; + apply_to_root_span?: + | /** + * Whether to trigger online scoring on the root span of each trace. Only applies when scope is 'span' or unset. + */ + /** + * Whether to trigger online scoring on the root span of each trace. Only applies when scope is 'span' or unset. + */ + (| boolean + /** + * Whether to trigger online scoring on the root span of each trace. Only applies when scope is 'span' or unset. + */ + | null + ) + | undefined; + apply_to_span_names?: + | /** + * Trigger online scoring on any spans with a name in this list. Only applies when scope is 'span' or unset. + */ + /** + * Trigger online scoring on any spans with a name in this list. Only applies when scope is 'span' or unset. + */ + (| Array + /** + * Trigger online scoring on any spans with a name in this list. Only applies when scope is 'span' or unset. + */ + | null + ) + | undefined; + skip_logging?: + | /** + * Whether to skip adding scorer spans when computing scores + */ + /** + * Whether to skip adding scorer spans when computing scores + */ + (| boolean + /** + * Whether to skip adding scorer spans when computing scores + */ + | null + ) + | undefined; + scope?: + | /** + * The scope at which to run the functions. Defaults to span-level execution. + */ + (SpanScopeType | TraceScopeType | GroupScopeType | null) + | undefined; +} | null; +export type OrganizationType = { + /** + * Unique identifier for the organization + */ + id: string; + /** + * Name of the organization + */ + name: string; + api_url?: (string | null) | undefined; + is_universal_api?: (boolean | null) | undefined; + is_dataplane_private?: (boolean | null) | undefined; + proxy_url?: (string | null) | undefined; + realtime_url?: (string | null) | undefined; + created?: + | /** + * Date of organization creation + */ + /** + * Date of organization creation + */ + (| string + /** + * Date of organization creation + */ + | null + ) + | undefined; + image_rendering_mode?: ImageRenderingModeType | undefined; +}; +export type RetentionObjectTypeType = + /** + * The object type that the retention policy applies to + * + * @enum project_logs, experiment, dataset + */ + "project_logs" | "experiment" | "dataset"; +export type OrgAutomationType = { + /** + * Unique identifier for the project automation + */ + id: string; + /** + * Unique identifier for the organization that the org automation belongs under + */ + org_id: string; + user_id?: + | /** + * Identifies the user who created the project automation + */ + /** + * Identifies the user who created the project automation + */ + (| string + /** + * Identifies the user who created the project automation + */ + | null + ) + | undefined; + created?: + | /** + * Date of project automation creation + */ + /** + * Date of project automation creation + */ + (| string + /** + * Date of project automation creation + */ + | null + ) + | undefined; + /** + * Name of the project automation + */ + name: string; + description?: + | /** + * Textual description of the project automation + */ + /** + * Textual description of the project automation + */ + (| string + /** + * Textual description of the project automation + */ + | null + ) + | undefined; + /** + * The configuration for the org automation rule + */ + config: { + /** + * The type of automation. + * + * @enum retention + */ + event_type: "retention"; + object_type: RetentionObjectTypeType; + /** + * The number of days to retain the object + * + * @minimum 0 + */ + retention_days: number; + }; +}; +export type ProjectSettingsType = Partial<{ + /** + * The key used to join two experiments (defaults to `input`) + */ + comparison_key: /** + * The key used to join two experiments (defaults to `input`) + */ + | string + /** + * The key used to join two experiments (defaults to `input`) + */ + | null; + /** + * The id of the experiment to use as the default baseline for comparisons + */ + baseline_experiment_id: /** + * The id of the experiment to use as the default baseline for comparisons + */ + | string + /** + * The id of the experiment to use as the default baseline for comparisons + */ + | null; + /** + * The order of the fields to display in the trace view + */ + spanFieldOrder: /** + * The order of the fields to display in the trace view + */ + | Array<{ + object_type: string; + column_id: string; + position: string; + layout?: + | ( + | /** + * @enum full + */ + "full" + /** + * @enum two_column + */ + | "two_column" + | null + ) + | undefined; + }> + /** + * The order of the fields to display in the trace view + */ + | null; + /** + * The remote eval sources to use for the project + */ + remote_eval_sources: /** + * The remote eval sources to use for the project + */ + | Array<{ + url: string; + name?: (string | null) | undefined; + description?: (string | null) | undefined; + }> + /** + * The remote eval sources to use for the project + */ + | null; + /** + * If true, disable real-time queries for this project. This can improve query performance for high-volume logs. + */ + disable_realtime_queries: /** + * If true, disable real-time queries for this project. This can improve query performance for high-volume logs. + */ + | boolean + /** + * If true, disable real-time queries for this project. This can improve query performance for high-volume logs. + */ + | null; + /** + * If true, use metrics.start rather than created for monitor chart time bucket dimensions. + */ + monitor_charts_use_metrics_start: /** + * If true, use metrics.start rather than created for monitor chart time bucket dimensions. + */ + | boolean + /** + * If true, use metrics.start rather than created for monitor chart time bucket dimensions. + */ + | null; + default_preprocessor: NullableSavedFunctionIdType; +}> | null; +export type ProjectType = { + /** + * Unique identifier for the project + */ + id: string; + /** + * Unique id for the organization that the project belongs under + */ + org_id: string; + /** + * Name of the project + */ + name: string; + description?: + | /** + * Textual description of the project + */ + /** + * Textual description of the project + */ + (| string + /** + * Textual description of the project + */ + | null + ) + | undefined; + created?: + | /** + * Date of project creation + */ + /** + * Date of project creation + */ + (| string + /** + * Date of project creation + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of project deletion, or null if the project is still active + */ + /** + * Date of project deletion, or null if the project is still active + */ + (| string + /** + * Date of project deletion, or null if the project is still active + */ + | null + ) + | undefined; + user_id?: + | /** + * Identifies the user who created the project + */ + /** + * Identifies the user who created the project + */ + (| string + /** + * Identifies the user who created the project + */ + | null + ) + | undefined; + settings?: ProjectSettingsType | undefined; +}; +export type WindowedAutomationConfigType = { + /** + * The type of automation. + * + * @enum windowed + */ + event_type: "windowed"; + product_origin?: + | /** + * The product surface that created and manages the automation + * + * @enum patterns + */ + (| /** + * The product surface that created and manages the automation + * + * @enum patterns + */ + "patterns" + /** + * The product surface that created and manages the automation + * + * @enum patterns + */ + | null + ) + | undefined; + status?: AutomationStatusType | undefined; + threshold?: /** + * Optional calculation and lifecycle policy that gate scheduled delivery + */ + | { + /** + * The calculation evaluated for each window + */ + calculation: { + /** + * @enum btql + */ + type: "btql"; + /** + * A project-scoped BTQL or SQL query without runtime-owned evaluation time bounds + * + * @minLength 1 + */ + btql_query: string; + output: { + /** + * @enum scalar + */ + type: "scalar"; + /** + * The numeric result column produced by the query + * + * @minLength 1 + */ + value_column: string; + }; + }; + /** + * The lifecycle policy applied to each calculation result + */ + policy: { + condition: { + /** + * @enum threshold + */ + type: "threshold"; + /** + * @enum lt, lte, gt, gte, eq, neq + */ + operator: "lt" | "lte" | "gt" | "gte" | "eq" | "neq"; + threshold: number; + }; + /** + * How long the condition must remain breached before firing + * + * @minimum 0 + * @maximum 2592000 + */ + pending_seconds: number; + /** + * How the lifecycle changes when the calculation returns no data + * + * @enum keep_last, resolve, alert + */ + no_data_behavior: "keep_last" | "resolve" | "alert"; + renotify_interval_seconds?: + | /** + * Optional reminder interval while the automation is firing + * + * @minimum 1 + * @maximum 2592000 + */ + /** + * Optional reminder interval while the automation is firing + * + * @minimum 1 + * @maximum 2592000 + */ + (| number + /** + * Optional reminder interval while the automation is firing + * + * @minimum 1 + * @maximum 2592000 + */ + | null + ) + | undefined; + /** + * Whether to deliver actions when a firing automation recovers + * + * @default true + */ + notify_on_recovery: boolean; + }; + } + | undefined; + window: { + /** + * How much recent data each scheduled run covers + * + * @minimum 1 + * @maximum 2592000 + */ + window_seconds: number; + /** + * How often the windowed automation runs: at a fixed interval or on a cron schedule + */ + schedule: + | { + /** + * @enum interval + */ + type: "interval"; + /** + * How often the automation runs + * + * @minimum 1 + * @maximum 2592000 + */ + evaluation_interval_seconds: number; + } + | { + /** + * @enum cron + */ + type: "cron"; + /** + * A standard five-field cron expression (minute hour day-of-month month day-of-week) controlling when the automation runs + * + * @minLength 1 + */ + cron_expression: string; + timezone?: + | /** + * IANA timezone used to interpret the cron expression (defaults to UTC) + * + * @minLength 1 + */ + /** + * IANA timezone used to interpret the cron expression (defaults to UTC) + * + * @minLength 1 + */ + (| string + /** + * IANA timezone used to interpret the cron expression (defaults to UTC) + * + * @minLength 1 + */ + | null + ) + | undefined; + }; + /** + * How far behind the present each evaluation window ends + * + * @minimum 0 + * @maximum 2592000 + */ + evaluation_delay_seconds: number; + }; + loop?: /** + * Optional Loop agent to run for each triggered window + */ + | { + /** + * Instructions for the Loop agent + * + * @minLength 1 + * @maxLength 10000 + */ + prompt: string; + /** + * Whether to include the automation trigger payload as input + * + * @default false + */ + include_trigger_input: boolean; + /** + * The Loop agent to run + * + * @minLength 1 + */ + agent_slug: string; + /** + * Write tools that may run without interactive approval + * + * @default [] + */ + auto_approve_tools: Array; + harness?: + | /** + * @enum native, codex, claude-code + */ + ("native" | "codex" | "claude-code") + | undefined; + model?: /** + * @minLength 1 + */ + string | undefined; + reasoning_effort?: + | /** + * @enum none, minimal, low, medium, high, xhigh, max + */ + ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max") + | undefined; + } + | undefined; + /** + * Delivery actions exposed to Loop as tools, or run directly when Loop is not configured + * + * @default [] + */ + actions: Array< + /** + * A delivery action available to an automation + */ + | { + /** + * The type of action to take + * + * @enum webhook + */ + type: "webhook"; + /** + * The webhook URL to send the request to + */ + url: string; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + } + | { + /** + * The type of action to take + * + * @enum slack + */ + type: "slack"; + /** + * The Slack workspace ID to post to + */ + workspace_id: string; + /** + * The Slack channel ID to post to + */ + channel: string; + message_template?: /** + * Custom message template for the alert + */ + string | undefined; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + } + >; +}; +export type TopicAutomationFacetModelType = + /** + * Optional facet model override for topic automation + * + * @enum brain-facet-latest, brain-facet-1, brain-facet-2 + */ + | /** + * Optional facet model override for topic automation + * + * @enum brain-facet-latest, brain-facet-1, brain-facet-2 + */ + ("brain-facet-latest" | "brain-facet-1" | "brain-facet-2") + /** + * Optional facet model override for topic automation + * + * @enum brain-facet-latest, brain-facet-1, brain-facet-2 + */ + | null; +export type TopicMapFunctionAutomationType = { + function: SavedFunctionIdType & + /** + * Topic map function + */ unknown; + btql_filter?: + | /** + * Per-topic-map BTQL filter. For trace scope, a topic map runs when max(filter) over the trace is truthy. For span scope, it runs when the current span matches. + */ + /** + * Per-topic-map BTQL filter. For trace scope, a topic map runs when max(filter) over the trace is truthy. For span scope, it runs when the current span matches. + */ + (| string + /** + * Per-topic-map BTQL filter. For trace scope, a topic map runs when max(filter) over the trace is truthy. For span scope, it runs when the current span matches. + */ + | null + ) + | undefined; +}; +export type TopicAutomationDataScopeType = + /** + * Optional data scope for topic automation. + */ + | { + /** + * @enum project_logs + */ + type: "project_logs"; + } + | { + /** + * @enum project_experiments + */ + type: "project_experiments"; + } + | { + /** + * @enum experiment + */ + type: "experiment"; + experiment_id: string; + } + | null; +export type TopicAutomationConfigType = { + /** + * The type of automation. + * + * @enum topic + */ + event_type: "topic"; + status?: AutomationStatusType | undefined; + /** + * The sampling rate for topic automation + * + * @minimum 0 + * @maximum 1 + */ + sampling_rate: number; + facet_model?: TopicAutomationFacetModelType | undefined; + /** + * Facet functions used by the topic automation + */ + facet_functions: Array; + /** + * Topic map functions with optional per-topic-map filters + */ + topic_map_functions: Array; + scope?: + | /** + * Execution scope for topic automation. Defaults to span-level execution. + */ + (SpanScopeType | TraceScopeType | GroupScopeType | null) + | undefined; + data_scope?: TopicAutomationDataScopeType | undefined; + btql_filter?: + | /** + * Optional BTQL filter applied before topic automation. + */ + /** + * Optional BTQL filter applied before topic automation. + */ + (| string + /** + * Optional BTQL filter applied before topic automation. + */ + | null + ) + | undefined; + rerun_seconds?: + | /** + * How often to recompute topic maps + * + * @minimum 600 + */ + /** + * How often to recompute topic maps + * + * @minimum 600 + */ + (| number + /** + * How often to recompute topic maps + * + * @minimum 600 + */ + | null + ) + | undefined; + relabel_overlap_seconds?: + | /** + * How much recent history to relabel after a new topic map version becomes active + * + * @minimum 60 + */ + /** + * How much recent history to relabel after a new topic map version becomes active + * + * @minimum 60 + */ + (| number + /** + * How much recent history to relabel after a new topic map version becomes active + * + * @minimum 60 + */ + | null + ) + | undefined; + backfill_time_range?: + | /** + * Topic window used for classification coverage and initial backfill. + */ + (| string + | { + from: string; + to: string; + } + | null + ) + | undefined; +}; +export type TopicDigestAutomationConfigType = { + /** + * The type of automation. + * + * @enum topic_digest + */ + event_type: "topic_digest"; + status?: AutomationStatusType | undefined; + /** + * How much recent history to include in each digest + * + * @default 86400 + * @minimum 3600 + * @maximum 2592000 + */ + window_seconds: number; + /** + * Minutes after midnight UTC when the digest should be sent + * + * @minimum 0 + * @maximum 1439 + */ + scheduled_time_minutes_utc: number; + /** + * The Slack action to take when the digest is sent + */ + action: { + /** + * The type of action to take + * + * @enum slack + */ + type: "slack"; + /** + * The Slack workspace ID to post to + */ + workspace_id: string; + /** + * The Slack channel ID to post to + */ + channel: string; + message_template?: /** + * Custom message template for the alert + */ + string | undefined; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + }; + topic_map_function_ids?: /** + * Optional topic map function IDs to include in the digest + */ + Array | undefined; +}; +export type ProjectAutomationType = { + /** + * Unique identifier for the project automation + */ + id: string; + /** + * Unique identifier for the project that the project automation belongs under + */ + project_id: string; + user_id?: + | /** + * Identifies the user who created the project automation + */ + /** + * Identifies the user who created the project automation + */ + (| string + /** + * Identifies the user who created the project automation + */ + | null + ) + | undefined; + created?: + | /** + * Date of project automation creation + */ + /** + * Date of project automation creation + */ + (| string + /** + * Date of project automation creation + */ + | null + ) + | undefined; + /** + * Name of the project automation + */ + name: string; + description?: + | /** + * Textual description of the project automation + */ + /** + * Textual description of the project automation + */ + (| string + /** + * Textual description of the project automation + */ + | null + ) + | undefined; + /** + * The configuration for the automation rule + */ + config: + | { + /** + * The type of automation. + * + * @enum logs + */ + event_type: "logs"; + status?: AutomationStatusType | undefined; + /** + * BTQL filter to identify rows for the automation rule + */ + btql_filter: string; + /** + * Perform the triggered action at most once in this interval of seconds + * + * @minimum 1 + * @maximum 2592000 + */ + interval_seconds: number; + /** + * The action to take when the automation rule is triggered + */ + action: + | { + /** + * The type of action to take + * + * @enum webhook + */ + type: "webhook"; + /** + * The webhook URL to send the request to + */ + url: string; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + } + | { + /** + * The type of action to take + * + * @enum slack + */ + type: "slack"; + /** + * The Slack workspace ID to post to + */ + workspace_id: string; + /** + * The Slack channel ID to post to + */ + channel: string; + message_template?: /** + * Custom message template for the alert + */ + string | undefined; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + }; + } + | { + /** + * The type of automation. + * + * @enum btql_export + */ + event_type: "btql_export"; + status?: AutomationStatusType | undefined; + /** + * The definition of what to export + */ + export_definition: + | { + /** + * @enum log_traces + */ + type: "log_traces"; + } + | { + /** + * @enum log_spans + */ + type: "log_spans"; + } + | { + /** + * @enum btql_query + */ + type: "btql_query"; + /** + * The BTQL query to export + */ + btql_query: string; + }; + scope?: + | /** + * Execution scope for export automation. Defaults to span-level execution. + */ + (SpanScopeType | TraceScopeType | GroupScopeType | null) + | undefined; + /** + * The path to export the results to. It should include the storage protocol and prefix, e.g. s3://bucket-name/path/to/export + */ + export_path: string; + /** + * The format to export the results in + * + * @enum jsonl, parquet + */ + format: "jsonl" | "parquet"; + /** + * Perform the triggered action at most once in this interval of seconds + * + * @minimum 1 + * @maximum 2592000 + */ + interval_seconds: number; + credentials: + | { + /** + * @enum aws_iam + */ + type: "aws_iam"; + /** + * The ARN of the IAM role to use + */ + role_arn: string; + /** + * The automation-specific external id component (auto-generated by default) + */ + external_id: string; + } + | { + /** + * @enum gcp_service_account + */ + type: "gcp_service_account"; + /** + * The GCP service account email to impersonate + */ + service_account_email: string; + }; + batch_size?: + | /** + * The number of rows to export in each batch + */ + /** + * The number of rows to export in each batch + */ + (| number + /** + * The number of rows to export in each batch + */ + | null + ) + | undefined; + } + | { + /** + * The type of automation. + * + * @enum async_query + */ + event_type: "async_query"; + status?: AutomationStatusType | undefined; + /** + * The user who submitted the async query + */ + created_by_user_id: string; + /** + * The source object type for the async query + * + * @enum project_logs, experiment, dataset, playground_logs + */ + object_type: + | "project_logs" + | "experiment" + | "dataset" + | "playground_logs"; + /** + * The source object ID for the async query + */ + object_id: string; + /** + * The SQL query to execute asynchronously + */ + query: string; + /** + * The materialized result format + * + * @enum jsonl + */ + format: "jsonl"; + batch_size?: + | /** + * The maximum number of result rows to write per async query batch + * + * @maximum 100000 + */ + /** + * The maximum number of result rows to write per async query batch + * + * @maximum 100000 + */ + (| number + /** + * The maximum number of result rows to write per async query batch + * + * @maximum 100000 + */ + | null + ) + | undefined; + } + | { + /** + * The type of automation. + * + * @enum retention + */ + event_type: "retention"; + object_type: RetentionObjectTypeType; + /** + * The number of days to retain the object + * + * @minimum 0 + */ + retention_days: number; + } + | { + /** + * The type of automation. + * + * @enum environment_update + */ + event_type: "environment_update"; + status?: AutomationStatusType | undefined; + environment_filter?: /** + * Optional list of environment slugs to filter by + */ + Array | undefined; + /** + * The action to take when the automation rule is triggered + */ + action: + | { + /** + * The type of action to take + * + * @enum webhook + */ + type: "webhook"; + /** + * The webhook URL to send the request to + */ + url: string; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + } + | { + /** + * The type of action to take + * + * @enum slack + */ + type: "slack"; + /** + * The Slack workspace ID to post to + */ + workspace_id: string; + /** + * The Slack channel ID to post to + */ + channel: string; + message_template?: /** + * Custom message template for the alert + */ + string | undefined; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + }; + } + | WindowedAutomationConfigType + | TopicAutomationConfigType + | TopicDigestAutomationConfigType; +}; +export type ProjectGroupType = { + /** + * Unique identifier for the project group + */ + id: string; + /** + * Unique id for the organization that the project group belongs under + + It is forbidden to change the org after creating a project group + */ + org_id: string; + user_id?: + | /** + * Identifies the user who created the project group + */ + /** + * Identifies the user who created the project group + */ + (| string + /** + * Identifies the user who created the project group + */ + | null + ) + | undefined; + created?: + | /** + * Date of project group creation + */ + /** + * Date of project group creation + */ + (| string + /** + * Date of project group creation + */ + | null + ) + | undefined; + /** + * Name of the project group + */ + name: string; + description?: + | /** + * Textual description of the project group + */ + /** + * Textual description of the project group + */ + (| string + /** + * Textual description of the project group + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of project group deletion, or null if the project group is still active + */ + /** + * Date of project group deletion, or null if the project group is still active + */ + (| string + /** + * Date of project group deletion, or null if the project group is still active + */ + | null + ) + | undefined; + /** + * Sorted ids of active projects in this project group + */ + member_projects: Array; +}; +export type ProjectLogsEventType = { + /** + * A unique identifier for the project logs event. If you don't provide one, Braintrust will generate one for you + */ + id: string; + /** + * 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) + */ + _xact_id: string; + _pagination_key?: + | /** + * A stable, time-ordered key that can be used to paginate over project logs events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + /** + * A stable, time-ordered key that can be used to paginate over project logs events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + (| string + /** + * A stable, time-ordered key that can be used to paginate over project logs events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + | null + ) + | undefined; + /** + * The timestamp the project logs event was created + */ + created: string; + /** + * Unique id for the organization that the project belongs under + */ + org_id: string; + /** + * Unique identifier for the project + */ + project_id: string; + /** + * A literal 'g' which identifies the log as a project log + * + * @enum g + */ + log_id: "g"; + input?: /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + */ + unknown | undefined; + 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 `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. + */ + unknown | undefined; + expected?: /** + * 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. + */ + unknown | undefined; + error?: /** + * The error that occurred, if any. + */ + unknown | undefined; + 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 logs. + */ + /** + * 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. + */ + (| {} + /** + * 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. + */ + | null + ) + | undefined; + 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'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 + */ + /** + * 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 + */ + (| Partial< + { + /** + * The model used for this example + */ + model: /** + * The model used for this example + */ + | string + /** + * The model used for this example + */ + | null; + } & { + [key: string]: any; + } + > + /** + * 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 + */ + | null + ) + | undefined; + tags?: + | /** + * A list of tags to log + */ + /** + * A list of tags to log + */ + (| Array + /** + * A list of tags to log + */ + | null + ) + | undefined; + metrics?: + | /** + * 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 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 + */ + ({} & { + [key: string]: number; + }) + /** + * 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 + */ + | null + ) + | undefined; + context?: + | /** + * 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 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 + */ + (| Partial< + { + /** + * The function in code which created the project logs event + */ + caller_functionname: /** + * The function in code which created the project logs event + */ + | string + /** + * The function in code which created the project logs event + */ + | null; + /** + * Name of the file in code where the project logs event was created + */ + caller_filename: /** + * Name of the file in code where the project logs event was created + */ + | string + /** + * Name of the file in code where the project logs event was created + */ + | null; + /** + * Line of code where the project logs event was created + */ + caller_lineno: /** + * Line of code where the project logs event was created + */ + | number + /** + * Line of code where the project logs event was created + */ + | null; + } & { + [key: string]: any; + } + > + /** + * 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 + */ + | null + ) + | undefined; + /** + * A unique identifier used to link different project logs events together as part of a full trace. See the [tracing guide](https://www.braintrust.dev/docs/instrument) for full details on tracing + */ + span_id: string; + span_parents?: + | /** + * 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 + */ + /** + * 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 + */ + (| Array + /** + * 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 + */ + | null + ) + | undefined; + /** + * A unique identifier for the trace this project logs event belongs to + */ + root_span_id: string; + is_root?: + | /** + * Whether this span is a root span + */ + /** + * Whether this span is a root span + */ + (| boolean + /** + * Whether this span is a root span + */ + | null + ) + | undefined; + span_attributes?: SpanAttributesType | undefined; + origin?: ObjectReferenceNullishType | undefined; + comments?: + | /** + * Optional list of comments attached to this event + */ + /** + * Optional list of comments attached to this event + */ + (| Array + /** + * Optional list of comments attached to this event + */ + | null + ) + | undefined; + audit_data?: + | /** + * Optional list of audit entries attached to this event + */ + /** + * Optional list of audit entries attached to this event + */ + (| Array + /** + * Optional list of audit entries attached to this event + */ + | null + ) + | undefined; + _async_scoring_state?: /** + * The async scoring state for this event + */ + unknown | undefined; + facets?: + | /** + * Facets for categorization (dictionary from facet id to value) + */ + /** + * Facets for categorization (dictionary from facet id to value) + */ + (| {} + /** + * Facets for categorization (dictionary from facet id to value) + */ + | null + ) + | undefined; + classifications?: + | /** + * Classifications for this event (dictionary from classification name to items) + */ + /** + * Classifications for this event (dictionary from classification name to items) + */ + (| {} + /** + * Classifications for this event (dictionary from classification name to items) + */ + | null + ) + | undefined; +}; +export type ProjectScoreTypeType = + /** + * The type of the configured score + * + * @enum slider, categorical, weighted, minimum, maximum, online, free-form + */ + | "slider" + | "categorical" + | "weighted" + | "minimum" + | "maximum" + | "online" + | "free-form"; +export type ProjectScoreCategoryType = { + /** + * Name of the category + */ + name: string; + /** + * Numerical value of the category. Must be between 0 and 1, inclusive + */ + value: number; +}; +export type ProjectScoreCategoriesType = + /** + * For categorical-type project scores, the list of all categories + */ + | Array + /** + * For weighted-type project scores, the weights of each score + */ + | {} + /** + * For minimum-type project scores, the list of included scores + */ + | Array + | null; +export type ProjectScoreConditionType = { + when: Partial<{ + clauses: Array | null; + subspan_clauses: Array | null; + trace_clauses: Array | null; + }>; + /** + * @default "hidden" + * @enum hidden + */ + behavior: "hidden"; +} | null; +export type ProjectScoreConfigType = Partial<{ + multi_select: boolean | null; + destination: string | null; + visibility: Partial<{ + users: Array | null; + groups: Array | null; + }> | null; + online: OnlineScoreConfigType; + condition: ProjectScoreConditionType; + object_types: Array< + /** + * @enum project_logs, dataset, experiment + */ + "project_logs" | "dataset" | "experiment" + > | null; +}> | null; +export type ProjectScoreType = { + /** + * Unique identifier for the project score + */ + id: string; + /** + * Unique identifier for the project that the project score belongs under + */ + project_id: string; + user_id: string; + created?: + | /** + * Date of project score creation + */ + /** + * Date of project score creation + */ + (| string + /** + * Date of project score creation + */ + | null + ) + | undefined; + /** + * Name of the project score + */ + name: string; + description?: + | /** + * Textual description of the project score + */ + /** + * Textual description of the project score + */ + (| string + /** + * Textual description of the project score + */ + | null + ) + | undefined; + score_type: ProjectScoreTypeType; + categories?: ProjectScoreCategoriesType | undefined; + config?: ProjectScoreConfigType | undefined; + position?: + | /** + * An optional LexoRank-based string that sets the sort position for the score in the UI + */ + /** + * An optional LexoRank-based string that sets the sort position for the score in the UI + */ + (| string + /** + * An optional LexoRank-based string that sets the sort position for the score in the UI + */ + | null + ) + | undefined; +}; +export type ProjectTagType = { + /** + * Unique identifier for the project tag + */ + id: string; + /** + * Unique identifier for the project that the project tag belongs under + */ + project_id: string; + user_id: string; + created?: + | /** + * Date of project tag creation + */ + /** + * Date of project tag creation + */ + (| string + /** + * Date of project tag creation + */ + | null + ) + | undefined; + /** + * Name of the project tag + */ + name: string; + description?: + | /** + * Textual description of the project tag + */ + /** + * Textual description of the project tag + */ + (| string + /** + * Textual description of the project tag + */ + | null + ) + | undefined; + color?: + | /** + * Color of the tag for the UI + */ + /** + * Color of the tag for the UI + */ + (| string + /** + * Color of the tag for the UI + */ + | null + ) + | undefined; + position?: + | /** + * An optional LexoRank-based string that sets the sort position for the tag in the UI + */ + /** + * An optional LexoRank-based string that sets the sort position for the tag in the UI + */ + (| string + /** + * An optional LexoRank-based string that sets the sort position for the tag in the UI + */ + | null + ) + | undefined; +}; +export type PromptType = { + /** + * Unique identifier for the prompt + */ + id: string; + /** + * 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 prompt (see the `version` parameter) + */ + _xact_id: string; + /** + * Unique identifier for the project that the prompt belongs under + */ + project_id: string; + /** + * A literal 'p' which identifies the object as a project prompt + * + * @enum p + */ + log_id: "p"; + /** + * Unique identifier for the organization + */ + org_id: string; + /** + * Name of the prompt + */ + name: string; + /** + * Unique identifier for the prompt + */ + slug: string; + description?: + | /** + * Textual description of the prompt + */ + /** + * Textual description of the prompt + */ + (| string + /** + * Textual description of the prompt + */ + | null + ) + | undefined; + created?: + | /** + * Date of prompt creation + */ + /** + * Date of prompt creation + */ + (| string + /** + * Date of prompt creation + */ + | null + ) + | undefined; + prompt_data?: PromptDataNullishType | undefined; + tags?: + | /** + * A list of tags for the prompt + */ + /** + * A list of tags for the prompt + */ + (| Array + /** + * A list of tags for the prompt + */ + | null + ) + | undefined; + metadata?: + | /** + * User-controlled metadata about the prompt + */ + /** + * User-controlled metadata about the prompt + */ + (| {} + /** + * User-controlled metadata about the prompt + */ + | null + ) + | undefined; + function_type?: FunctionTypeEnumNullishType | undefined; +}; +export type PromptOptionsType = Partial<{ + model: string; + params: ModelParamsType; + position: string; + endpoint_name: string | null; +}>; +export type PromptSessionEventType = { + /** + * A unique identifier for the prompt session event. If you don't provide one, Braintrust will generate one for you + */ + id: string; + /** + * 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 prompt session (see the `version` parameter) + */ + _xact_id: string; + /** + * The timestamp the prompt session event was created + */ + created: string; + _pagination_key?: + | /** + * A stable, time-ordered key that can be used to paginate over prompt session events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + /** + * A stable, time-ordered key that can be used to paginate over prompt session events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + (| string + /** + * A stable, time-ordered key that can be used to paginate over prompt session events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + | null + ) + | undefined; + /** + * Unique identifier for the project that the prompt belongs under + */ + project_id: string; + /** + * Unique identifier for the prompt + */ + prompt_session_id: string; + prompt_session_data?: /** + * Data about the prompt session + */ + unknown | undefined; + prompt_data?: /** + * Data about the prompt + */ + unknown | undefined; + function_data?: /** + * Data about the function + */ + unknown | undefined; + function_type?: FunctionTypeEnumNullishType | undefined; + object_data?: /** + * Data about the mapped data + */ + unknown | undefined; + completion?: /** + * Data about the completion + */ + unknown | undefined; + tags?: + | /** + * A list of tags to log + */ + /** + * A list of tags to log + */ + (| Array + /** + * A list of tags to log + */ + | null + ) + | undefined; +}; +export type ResponseFormatType = + | { + /** + * @enum json_object + */ + type: "json_object"; + } + | { + /** + * @enum json_schema + */ + type: "json_schema"; + json_schema: ResponseFormatJsonSchemaType; + } + | { + /** + * @enum text + */ + type: "text"; + }; +export type RoleType = { + /** + * Unique identifier for the role + */ + id: string; + org_id?: + | /** + * Unique id for the organization that the role belongs under + + A null org_id indicates a system role, which may be assigned to anybody and inherited by any other role, but cannot be edited. + + It is forbidden to change the org after creating a role + */ + /** + * Unique id for the organization that the role belongs under + + A null org_id indicates a system role, which may be assigned to anybody and inherited by any other role, but cannot be edited. + + It is forbidden to change the org after creating a role + */ + (| string /** + * Unique id for the organization that the role belongs under + + A null org_id indicates a system role, which may be assigned to anybody and inherited by any other role, but cannot be edited. + + It is forbidden to change the org after creating a role + */ + | null + ) + | undefined; + user_id?: + | /** + * Identifies the user who created the role + */ + /** + * Identifies the user who created the role + */ + (| string + /** + * Identifies the user who created the role + */ + | null + ) + | undefined; + created?: + | /** + * Date of role creation + */ + /** + * Date of role creation + */ + (| string + /** + * Date of role creation + */ + | null + ) + | undefined; + /** + * Name of the role + */ + name: string; + description?: + | /** + * Textual description of the role + */ + /** + * Textual description of the role + */ + (| string + /** + * Textual description of the role + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of role deletion, or null if the role is still active + */ + /** + * Date of role deletion, or null if the role is still active + */ + (| string + /** + * Date of role deletion, or null if the role is still active + */ + | null + ) + | undefined; + member_permissions?: + | /** + * (permission, restrict_object_type) tuples which belong to this role + */ + /** + * (permission, restrict_object_type) tuples which belong to this role + */ + (| Array<{ + permission: PermissionType; + restrict_object_type?: AclObjectTypeType | undefined; + }> + /** + * (permission, restrict_object_type) tuples which belong to this role + */ + | null + ) + | undefined; + member_roles?: + | /** + * Ids of the roles this role inherits from + + An inheriting role has all the permissions contained in its member roles, as well as all of their inherited permissions + */ + /** + * Ids of the roles this role inherits from + + An inheriting role has all the permissions contained in its member roles, as well as all of their inherited permissions + */ + (| Array /** + * Ids of the roles this role inherits from + + An inheriting role has all the permissions contained in its member roles, as well as all of their inherited permissions + */ + | null + ) + | undefined; +}; +export type RunEvalType = { + /** + * Unique identifier for the project to run the eval in + */ + project_id: string; + /** + * The dataset to use + */ + data: /** + * Dataset id + */ + | { + dataset_id: string; + dataset_version?: + | /** + * The version of the dataset to evaluate + */ + /** + * The version of the dataset to evaluate + */ + (| string + /** + * The version of the dataset to evaluate + */ + | null + ) + | undefined; + dataset_environment?: + | /** + * The environment tag that resolves to the dataset version to evaluate + */ + /** + * The environment tag that resolves to the dataset version to evaluate + */ + (| string + /** + * The environment tag that resolves to the dataset version to evaluate + */ + | null + ) + | undefined; + _internal_btql?: ({} | null) | undefined; + } + /** + * Project and dataset name + */ + | { + project_name: string; + dataset_name: string; + dataset_version?: + | /** + * The version of the dataset to evaluate + */ + /** + * The version of the dataset to evaluate + */ + (| string + /** + * The version of the dataset to evaluate + */ + | null + ) + | undefined; + dataset_environment?: + | /** + * The environment tag that resolves to the dataset version to evaluate + */ + /** + * The environment tag that resolves to the dataset version to evaluate + */ + (| string + /** + * The environment tag that resolves to the dataset version to evaluate + */ + | null + ) + | undefined; + _internal_btql?: ({} | null) | undefined; + } + /** + * Dataset rows + */ + | { + data: Array; + }; + name?: /** + * The name of the eval to run when multiple evals available + */ + string | undefined; + parameters?: /** + * Values for any parameters used in the eval + */ + {} | undefined; + task: FunctionIdType & + /** + * The function to evaluate + */ unknown; + /** + * The functions to score the eval on + */ + scores: Array; + experiment_name?: /** + * An optional name for the experiment created by this eval. If it conflicts with an existing experiment, it will be suffixed with a unique identifier. + */ + string | undefined; + metadata?: /** + * Optional experiment-level metadata to store about the evaluation. You can later use this to slice & dice across experiments. + */ + {} | undefined; + parent?: + | (InvokeParentType & + /** + * Options for tracing the evaluation + */ unknown) + | undefined; + stream?: /** + * Whether to stream the results of the eval. If true, the request will return two events: one to indicate the experiment has started, and another upon completion. If false, the request will return the evaluation's summary upon completion. + */ + boolean | undefined; + trial_count?: + | /** + * The number of times to run the evaluator per input. This is useful for evaluating applications that have non-deterministic behavior and gives you both a stronger aggregate measure and a sense of the variance in the results. + */ + /** + * The number of times to run the evaluator per input. This is useful for evaluating applications that have non-deterministic behavior and gives you both a stronger aggregate measure and a sense of the variance in the results. + */ + (| number + /** + * The number of times to run the evaluator per input. This is useful for evaluating applications that have non-deterministic behavior and gives you both a stronger aggregate measure and a sense of the variance in the results. + */ + | null + ) + | undefined; + is_public?: + | /** + * Whether the experiment should be public. Defaults to false. + */ + /** + * Whether the experiment should be public. Defaults to false. + */ + (| boolean + /** + * Whether the experiment should be public. Defaults to false. + */ + | null + ) + | undefined; + timeout?: + | /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which case there is no timeout. + */ + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which case there is no timeout. + */ + (| number + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which case there is no timeout. + */ + | null + ) + | undefined; + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to 10. If null is provided, no max concurrency will be used. + * + * @default 10 + */ + max_concurrency: /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to 10. If null is provided, no max concurrency will be used. + * + * @default 10 + */ + | number + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to 10. If null is provided, no max concurrency will be used. + * + * @default 10 + */ + | null; + base_experiment_name?: + | /** + * An optional experiment name to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + /** + * An optional experiment name to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + (| string + /** + * An optional experiment name to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + | null + ) + | undefined; + base_experiment_id?: + | /** + * An optional experiment id to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + /** + * An optional experiment id to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + (| string + /** + * An optional experiment id to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + | null + ) + | undefined; + git_metadata_settings?: + | (GitMetadataSettingsType & + /** + * Optional settings for collecting git metadata. By default, will collect git metadata fields allowed in org-level settings, excluding diff content unless the org opts in. + */ /** + * Optional settings for collecting git metadata. By default, will collect git metadata fields allowed in org-level settings, excluding diff content unless the org opts in. + */ + (| {} + /** + * Optional settings for collecting git metadata. By default, will collect git metadata fields allowed in org-level settings, excluding diff content unless the org opts in. + */ + | null + )) + | undefined; + repo_info?: + | (RepoInfoType & + /** + * Optionally explicitly specify the git metadata for this experiment. This takes precedence over `gitMetadataSettings` if specified. + */ unknown) + | undefined; + strict?: + | /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + (| boolean + /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + | null + ) + | undefined; + stop_token?: + | /** + * The token to stop the run + */ + /** + * The token to stop the run + */ + (| string + /** + * The token to stop the run + */ + | null + ) + | undefined; + extra_messages?: /** + * A template path of extra messages to append to the conversion. These messages will be appended to the end of the conversation, after the last message. + */ + string | undefined; + tags?: /** + * Optional tags that will be added to the experiment. + */ + Array | undefined; + mcp_auth?: {} | undefined; + endpoint_name?: + | /** + * Name of the AI provider secret to pin this run to. + */ + /** + * Name of the AI provider secret to pin this run to. + */ + (| string + /** + * Name of the AI provider secret to pin this run to. + */ + | null + ) + | undefined; +}; +export type ServiceTokenType = { + /** + * Unique identifier for the service token + */ + id: string; + created?: + | /** + * Date of service token creation + */ + /** + * Date of service token creation + */ + (| string + /** + * Date of service token creation + */ + | null + ) + | undefined; + /** + * Name of the service token + */ + name: string; + preview_name: string; + service_account_id?: + | /** + * Unique identifier for the service token + */ + /** + * Unique identifier for the service token + */ + (| string + /** + * Unique identifier for the service token + */ + | null + ) + | undefined; + service_account_email?: + | /** + * The service account email (not routable) + */ + /** + * The service account email (not routable) + */ + (| string + /** + * The service account email (not routable) + */ + | null + ) + | undefined; + service_account_name?: + | /** + * The service account name + */ + /** + * The service account name + */ + (| string + /** + * The service account name + */ + | null + ) + | undefined; + org_id?: + | /** + * Unique identifier for the organization + */ + /** + * Unique identifier for the organization + */ + (| string + /** + * Unique identifier for the organization + */ + | null + ) + | undefined; + expires_at?: + | /** + * Date and time at which the service token expires. If null, the token never expires. + */ + /** + * Date and time at which the service token expires. If null, the token never expires. + */ + (| string + /** + * Date and time at which the service token expires. If null, the token never expires. + */ + | null + ) + | undefined; +}; +export type SpanIFrameType = { + /** + * Unique identifier for the span iframe + */ + id: string; + /** + * Unique identifier for the project that the span iframe belongs under + */ + project_id: string; + user_id?: + | /** + * Identifies the user who created the span iframe + */ + /** + * Identifies the user who created the span iframe + */ + (| string + /** + * Identifies the user who created the span iframe + */ + | null + ) + | undefined; + created?: + | /** + * Date of span iframe creation + */ + /** + * Date of span iframe creation + */ + (| string + /** + * Date of span iframe creation + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of span iframe deletion, or null if the span iframe is still active + */ + /** + * Date of span iframe deletion, or null if the span iframe is still active + */ + (| string + /** + * Date of span iframe deletion, or null if the span iframe is still active + */ + | null + ) + | undefined; + /** + * Name of the span iframe + */ + name: string; + description?: + | /** + * Textual description of the span iframe + */ + /** + * Textual description of the span iframe + */ + (| string + /** + * Textual description of the span iframe + */ + | null + ) + | undefined; + /** + * URL to embed the project viewer in an iframe + */ + url: string; + post_message?: + | /** + * Whether to post messages to the iframe containing the span's data. This is useful when you want to render more data than fits in the URL. + */ + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you want to render more data than fits in the URL. + */ + (| boolean + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you want to render more data than fits in the URL. + */ + | null + ) + | undefined; +}; +export type SSEConsoleEventDataType = { + /** + * @enum stderr, stdout + */ + stream: "stderr" | "stdout"; + message: string; +}; +export type SSEProgressEventDataType = { + /** + * The id of the span this event is for + */ + id: string; + object_type: FunctionObjectTypeType; + origin?: + | (ObjectReferenceNullishType & + /** + * The origin of the event + */ unknown) + | undefined; + format: FunctionFormatType; + output_type: FunctionOutputTypeType; + name: string; + /** + * @enum reasoning_delta, text_delta, json_delta, error, console, start, done, progress + */ + event: + | "reasoning_delta" + | "text_delta" + | "json_delta" + | "error" + | "console" + | "start" + | "done" + | "progress"; + data: string; +}; +export type ToolFunctionDefinitionType = { + /** + * @enum function + */ + type: "function"; + function: { + name: string; + description?: string | undefined; + parameters?: {} | undefined; + strict?: (boolean | null) | undefined; + }; +}; +export type UserType = { + /** + * Unique identifier for the user + */ + id: string; + given_name?: + | /** + * Given name of the user + */ + /** + * Given name of the user + */ + (| string + /** + * Given name of the user + */ + | null + ) + | undefined; + family_name?: + | /** + * Family name of the user + */ + /** + * Family name of the user + */ + (| string + /** + * Family name of the user + */ + | null + ) + | undefined; + email?: + | /** + * The user's email + */ + /** + * The user's email + */ + (| string + /** + * The user's email + */ + | null + ) + | undefined; + avatar_url?: + | /** + * URL of the user's Avatar image + */ + /** + * URL of the user's Avatar image + */ + (| string + /** + * URL of the user's Avatar image + */ + | null + ) + | undefined; + created?: + | /** + * Date of user creation + */ + /** + * Date of user creation + */ + (| string + /** + * Date of user creation + */ + | null + ) + | undefined; +}; +export type ViewDataSearchType = Partial<{ + filter: Array | null; + tag: Array | null; + match: Array | null; + sort: Array | null; +}> | null; +export type ViewDataType = + /** + * The view definition + */ + /** + * The view definition + */ + | Partial<{ + search: ViewDataSearchType; + custom_charts: unknown; + }> + /** + * The view definition + */ + | null; +export type ViewOptionsType = + /** + * Options for the view in the app + */ + | { + /** + * @enum monitor + */ + viewType: "monitor"; + options: Partial<{ + /** + * @enum range, frame + */ + spanType: + | /** + * @enum range, frame + */ + ("range" | "frame") + /** + * @enum range, frame + */ + | null; + rangeValue: string | null; + frameStart: string | null; + frameEnd: string | null; + tzUTC: boolean | null; + chartVisibility: {} | null; + projectId: string | null; + /** + * @enum project, experiment + */ + type: + | /** + * @enum project, experiment + */ + ("project" | "experiment") + /** + * @enum project, experiment + */ + | null; + groupBy: string | null; + }>; + freezeColumns?: (boolean | null) | undefined; + } + | Partial<{ + columnVisibility: {} | null; + columnOrder: Array | null; + columnSizing: {} | null; + grouping: string | null; + rowHeight: string | null; + tallGroupRows: boolean | null; + layout: string | null; + topicMapReportKey: string | null; + chartHeight: number | null; + excludedMeasures: Array<{ + /** + * @enum none, score, metric, metadata + */ + type: "none" | "score" | "metric" | "metadata"; + value: string; + }> | null; + yMetric: { + /** + * @enum none, score, metric, metadata + */ + type: "none" | "score" | "metric" | "metadata"; + value: string; + } | null; + xAxis: { + /** + * @enum none, score, metric, metadata + */ + type: "none" | "score" | "metric" | "metadata"; + value: string; + } | null; + symbolGrouping: { + /** + * @enum none, score, metric, metadata + */ + type: "none" | "score" | "metric" | "metadata"; + value: string; + } | null; + pointSizeMetric: { + /** + * @enum none, score, metric, metadata + */ + type: "none" | "score" | "metric" | "metadata"; + value: string; + } | null; + /** + * One of 'avg', 'sum', 'min', 'max', 'median', 'all' + */ + xAxisAggregation: /** + * One of 'avg', 'sum', 'min', 'max', 'median', 'all' + */ + | string + /** + * One of 'avg', 'sum', 'min', 'max', 'median', 'all' + */ + | null; + chartAnnotations: Array<{ + id: string; + text: string; + }> | null; + timeRangeFilter: + | string + | { + from: string; + to: string; + } + | null; + /** + * @enum traces, spans, topics + */ + queryShape: + | /** + * @enum traces, spans, topics + */ + ("traces" | "spans" | "topics") + /** + * @enum traces, spans, topics + */ + | null; + cluster: string | null; + freezeColumns: boolean | null; + }> + | null; +export type ViewType = { + /** + * Unique identifier for the view + */ + id: string; + object_type: AclObjectTypeType & string; + /** + * The id of the object the view applies to + */ + object_id: string; + /** + * Type of object that the view corresponds to. + * + * @enum projects, experiments, experiment, playgrounds, playground, datasets, dataset, prompts, parameters, tools, scorers, classifiers, logs, monitor, for_review_project_log, for_review_experiments, for_review_datasets + */ + view_type: + | "projects" + | "experiments" + | "experiment" + | "playgrounds" + | "playground" + | "datasets" + | "dataset" + | "prompts" + | "parameters" + | "tools" + | "scorers" + | "classifiers" + | "logs" + | "monitor" + | "for_review_project_log" + | "for_review_experiments" + | "for_review_datasets"; + /** + * Name of the view + */ + name: string; + description?: + | /** + * Textual description of the view + */ + /** + * Textual description of the view + */ + (| string + /** + * Textual description of the view + */ + | null + ) + | undefined; + created?: + | /** + * Date of view creation + */ + /** + * Date of view creation + */ + (| string + /** + * Date of view creation + */ + | null + ) + | undefined; + updated_at?: + | /** + * Date of last view update + */ + /** + * Date of last view update + */ + (| string + /** + * Date of last view update + */ + | null + ) + | undefined; + view_data?: ViewDataType | undefined; + options?: ViewOptionsType | undefined; + user_id?: + | /** + * Identifies the user who created the view + */ + /** + * Identifies the user who created the view + */ + (| string + /** + * Identifies the user who created the view + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of role deletion, or null if the role is still active + */ + /** + * Date of role deletion, or null if the role is still active + */ + (| string + /** + * Date of role deletion, or null if the role is still active + */ + | null + ) + | undefined; +}; diff --git a/js/util/generated_plain_types.ts b/js/util/generated_plain_types.ts new file mode 100644 index 000000000..b03f1fddc --- /dev/null +++ b/js/util/generated_plain_types.ts @@ -0,0 +1,7154 @@ +// Auto-generated file (content hash 776b6c295e852681) -- do not modify + +export type AclObjectTypeType = + /** + * The object type that the ACL applies to + * + * @enum organization, project, experiment, dataset, prompt, prompt_session, group, role, org_member, project_log, org_project, org_audit_logs, project_group + */ + | /** + * The object type that the ACL applies to + * + * @enum organization, project, experiment, dataset, prompt, prompt_session, group, role, org_member, project_log, org_project, org_audit_logs, project_group + */ + (| "organization" + | "project" + | "experiment" + | "dataset" + | "prompt" + | "prompt_session" + | "group" + | "role" + | "org_member" + | "project_log" + | "org_project" + | "org_audit_logs" + | "project_group" + ) + /** + * The object type that the ACL applies to + * + * @enum organization, project, experiment, dataset, prompt, prompt_session, group, role, org_member, project_log, org_project, org_audit_logs, project_group + */ + | null; +export type PermissionType = + /** + * Each permission permits a certain type of operation on an object in the system + +Permissions can be assigned to to objects on an individual basis, or grouped into roles + * + * @enum create, read, update, delete, create_acls, read_acls, update_acls, delete_acls + */ + | "create" + | "read" + | "update" + | "delete" + | "create_acls" + | "read_acls" + | "update_acls" + | "delete_acls"; +export type AclType = { + /** + * Unique identifier for the acl + */ + id: string; + object_type: AclObjectTypeType & string; + /** + * The id of the object the ACL applies to + */ + object_id: string; + user_id?: + | /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + (| string + /** + * Id of the user the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + | null + ) + | undefined; + group_id?: + | /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + (| string + /** + * Id of the group the ACL applies to. Exactly one of `user_id` and `group_id` will be provided + */ + | null + ) + | undefined; + permission?: + | (PermissionType & + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + (| string + /** + * Permission the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + | null + )) + | undefined; + restrict_object_type?: + | (AclObjectTypeType & + /** + * When setting a permission directly, optionally restricts the permission grant to just the specified object type. Cannot be set alongside a `role_id`. + */ unknown) + | undefined; + role_id?: + | /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + (| string + /** + * Id of the role the ACL grants. Exactly one of `permission` and `role_id` will be provided + */ + | null + ) + | undefined; + /** + * The organization the ACL's referred object belongs to + */ + _object_org_id: string; + created?: + | /** + * Date of acl creation + */ + /** + * Date of acl creation + */ + (| string + /** + * Date of acl creation + */ + | null + ) + | undefined; +}; +export type AgentType = { + /** + * Unique identifier for the agent + */ + id: string; + /** + * Unique identifier for the project that the agent belongs under + */ + project_id: string; + user_id: string; + created?: + | /** + * Date of agent creation + */ + /** + * Date of agent creation + */ + (| string + /** + * Date of agent creation + */ + | null + ) + | undefined; + /** + * Name of the agent. Within a project, agent names are unique + */ + name: string; + /** + * Stable, URL-safe identifier for the agent, unique within its project. + */ + slug: string; + /** + * Agent classification: 'custom' for customer-defined agents, 'loop' for built-in Loop agents. + */ + kind: string; + description?: + | /** + * Textual description of the agent + */ + /** + * Textual description of the agent + */ + (| string + /** + * Textual description of the agent + */ + | null + ) + | undefined; + metadata?: + | /** + * User-controlled metadata about the agent + */ + /** + * User-controlled metadata about the agent + */ + (| {} + /** + * User-controlled metadata about the agent + */ + | null + ) + | undefined; +}; +export type AISecretType = { + /** + * Unique identifier for the AI secret + */ + id: string; + created?: + | /** + * Date of AI secret creation + */ + /** + * Date of AI secret creation + */ + (| string + /** + * Date of AI secret creation + */ + | null + ) + | undefined; + updated_at?: + | /** + * Date of last AI secret update + */ + /** + * Date of last AI secret update + */ + (| string + /** + * Date of last AI secret update + */ + | null + ) + | undefined; + secret_updated_at?: + | /** + * Date of last update to the encrypted secret value itself + */ + /** + * Date of last update to the encrypted secret value itself + */ + (| string + /** + * Date of last update to the encrypted secret value itself + */ + | null + ) + | undefined; + /** + * Unique identifier for the organization + */ + org_id: string; + /** + * Name of the AI secret + */ + name: string; + type?: (string | null) | undefined; + metadata?: ({} | null) | undefined; + secret_updated_by_user_id?: + | /** + * User id of the last update to the encrypted secret value + */ + /** + * User id of the last update to the encrypted secret value + */ + (| string + /** + * User id of the last update to the encrypted secret value + */ + | null + ) + | undefined; + preview_secret?: (string | null) | undefined; +}; +export type ResponseFormatJsonSchemaType = { + name: string; + description?: string | undefined; + schema?: ({} | string) | undefined; + strict?: (boolean | null) | undefined; +}; +export type ResponseFormatNullishType = + | { + /** + * @enum json_object + */ + type: "json_object"; + } + | { + /** + * @enum json_schema + */ + type: "json_schema"; + json_schema: ResponseFormatJsonSchemaType; + } + | { + /** + * @enum text + */ + type: "text"; + } + | null; +export type AnyModelParamsType = { + temperature?: number | undefined; + top_p?: number | undefined; + max_tokens: number; + max_completion_tokens?: /** + * The successor to max_tokens + */ + number | undefined; + frequency_penalty?: number | undefined; + presence_penalty?: number | undefined; + response_format?: ResponseFormatNullishType | undefined; + tool_choice?: + | ( + | /** + * @enum auto + */ + "auto" + /** + * @enum none + */ + | "none" + /** + * @enum required + */ + | "required" + | { + /** + * @enum function + */ + type: "function"; + function: { + name: string; + }; + } + ) + | undefined; + function_call?: + | ( + | /** + * @enum auto + */ + "auto" + /** + * @enum none + */ + | "none" + | { + name: string; + } + ) + | undefined; + n?: number | undefined; + stop?: Array | undefined; + reasoning_effort?: + | /** + * @enum none, minimal, low, medium, high + */ + ("none" | "minimal" | "low" | "medium" | "high") + | undefined; + verbosity?: + | /** + * @enum low, medium, high + */ + ("low" | "medium" | "high") + | undefined; + top_k?: number | undefined; + stop_sequences?: Array | undefined; + reasoning_enabled?: boolean | undefined; + reasoning_budget?: number | undefined; + max_tokens_to_sample?: /** + * This is a legacy parameter that should not be used. + */ + number | undefined; + maxOutputTokens?: number | undefined; + topP?: number | undefined; + topK?: number | undefined; + use_cache?: boolean | undefined; +}; +export type ApiKeyType = { + /** + * Unique identifier for the api key + */ + id: string; + created?: + | /** + * Date of api key creation + */ + /** + * Date of api key creation + */ + (| string + /** + * Date of api key creation + */ + | null + ) + | undefined; + /** + * Name of the api key + */ + name: string; + preview_name: string; + user_id?: + | /** + * Unique identifier for the user + */ + /** + * Unique identifier for the user + */ + (| string + /** + * Unique identifier for the user + */ + | null + ) + | undefined; + user_email?: + | /** + * The user's email + */ + /** + * The user's email + */ + (| string + /** + * The user's email + */ + | null + ) + | undefined; + user_given_name?: + | /** + * Given name of the user + */ + /** + * Given name of the user + */ + (| string + /** + * Given name of the user + */ + | null + ) + | undefined; + user_family_name?: + | /** + * Family name of the user + */ + /** + * Family name of the user + */ + (| string + /** + * Family name of the user + */ + | null + ) + | undefined; + org_id?: + | /** + * Unique identifier for the organization + */ + /** + * Unique identifier for the organization + */ + (| string + /** + * Unique identifier for the organization + */ + | null + ) + | undefined; + expires_at?: + | /** + * Date at which the API key expires. If null, the key never expires. + */ + /** + * Date at which the API key expires. If null, the key never expires. + */ + (| string + /** + * Date at which the API key expires. If null, the key never expires. + */ + | null + ) + | undefined; +}; +export type TriggeredFunctionStateType = { + /** + * The xact_id when this function was triggered + */ + triggered_xact_id: string; + completed_xact_id?: + | /** + * The xact_id when this function completed (matches triggered_xact_id if done) + */ + /** + * The xact_id when this function completed (matches triggered_xact_id if done) + */ + (| string + /** + * The xact_id when this function completed (matches triggered_xact_id if done) + */ + | null + ) + | undefined; + idempotency_key?: + | /** + * Deterministic key of the function definition + input version used to skip unchanged reruns + */ + /** + * Deterministic key of the function definition + input version used to skip unchanged reruns + */ + (| string + /** + * Deterministic key of the function definition + input version used to skip unchanged reruns + */ + | null + ) + | undefined; + /** + * Number of execution attempts (for retry tracking) + * + * @default 0 + * @minimum 0 + */ + attempts: number; + /** + * The scope of data this function operates on + */ + scope: + | { + /** + * @enum span + */ + type: "span"; + } + | { + /** + * @enum trace + */ + type: "trace"; + } + | { + /** + * @enum group + */ + type: "group"; + key: string; + value: string; + }; +}; +export type AsyncScoringStateType = + | { + /** + * @enum enabled + */ + status: "enabled"; + token: string; + function_ids: Array; + skip_logging?: (boolean | null) | undefined; + triggered_functions?: ({} | null) | undefined; + last_triggered_xact_id?: + | /** + * The xact_id of the last non-score change to this row (excludes scorer score merges) + */ + (string | number | null) + | undefined; + } + | { + /** + * @enum disabled + */ + status: "disabled"; + } + | null + | null; +export type AsyncScoringControlType = + | { + /** + * @enum score_update + */ + kind: "score_update"; + token?: string | undefined; + } + | { + /** + * @enum state_override + */ + kind: "state_override"; + state: AsyncScoringStateType; + } + | { + /** + * @enum state_force_reselect + */ + kind: "state_force_reselect"; + } + | { + /** + * @enum state_enabled_force_rescore + */ + kind: "state_enabled_force_rescore"; + } + | { + /** + * @enum trigger_functions + */ + kind: "trigger_functions"; + triggered_functions: Array<{ + function_id?: unknown | undefined; + scope: + | { + /** + * @enum span + */ + type: "span"; + } + | { + /** + * @enum trace + */ + type: "trace"; + }; + idempotency_key?: string | undefined; + }>; + } + | { + /** + * @enum complete_triggered_functions + */ + kind: "complete_triggered_functions"; + function_ids: Array; + triggered_xact_id: string; + } + | { + /** + * @enum mark_attempt_failed + */ + kind: "mark_attempt_failed"; + function_ids: Array; + }; +export type BraintrustAttachmentReferenceType = { + /** + * An identifier to help disambiguate parsing. + * + * @enum braintrust_attachment + */ + type: "braintrust_attachment"; + /** + * Human-readable filename for user interfaces. Not related to attachment storage. + * + * @minLength 1 + */ + filename: string; + /** + * MIME type of this file. + * + * @minLength 1 + */ + content_type: string; + /** + * Key in the object store bucket for this attachment. + * + * @minLength 1 + */ + key: string; +}; +export type ExternalAttachmentReferenceType = { + /** + * An identifier to help disambiguate parsing. + * + * @enum external_attachment + */ + type: "external_attachment"; + /** + * Human-readable filename for user interfaces. Not related to attachment storage. + * + * @minLength 1 + */ + filename: string; + /** + * MIME type of this file. + * + * @minLength 1 + */ + content_type: string; + /** + * Fully qualified URL to the object in the external object store. + * + * @minLength 1 + */ + url: string; +}; +export type AttachmentReferenceType = + | BraintrustAttachmentReferenceType + | ExternalAttachmentReferenceType; +export type UploadStatusType = + /** + * @enum uploading, done, error + */ + "uploading" | "done" | "error"; +export type AttachmentStatusType = { + upload_status: UploadStatusType; + error_message?: /** + * Describes the error encountered while uploading. + */ + string | undefined; +}; +export type AutomationStatusType = + /** + * Whether the automation is active or paused. + * + * @enum active, paused + */ + "active" | "paused"; +export type FunctionTypeEnumType = + /** + * The type of global function. Defaults to 'scorer'. + * + * @default "scorer" + * @enum llm, scorer, task, tool, custom_view, preprocessor, facet, classifier, tag, parameters, sandbox + */ + | "llm" + | "scorer" + | "task" + | "tool" + | "custom_view" + | "preprocessor" + | "facet" + | "classifier" + | "tag" + | "parameters" + | "sandbox"; +export type FacetPreprocessorIdType = + /** + * The saved, global, or inline preprocessor to use for facet extraction. If not provided, the project default preprocessor will be used, falling back to the global 'thread' preprocessor. + */ + | { + /** + * @enum function + */ + type: "function"; + id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + function_type: FunctionTypeEnumType; + } + | { + /** + * @enum inline + */ + type: "inline"; + /** + * The complete JavaScript preprocessor implementation, including its handler. + * + * @minLength 1 + */ + code: string; + } + | null; +export type TopicMapGenerationSettingsType = { + /** + * @enum hdbscan, kmeans, community + */ + algorithm: "hdbscan" | "kmeans" | "community"; + /** + * @enum umap, pca, none + */ + dimension_reduction: "umap" | "pca" | "none"; + sample_size?: number | undefined; + n_clusters?: number | undefined; + min_cluster_size?: number | undefined; + min_samples?: number | undefined; + hierarchy_threshold?: number | undefined; + naming_model?: string | undefined; +}; +export type TopicMapDataType = { + /** + * @enum topic_map + */ + type: "topic_map"; + /** + * The facet field name to use as input for classification + */ + source_facet: string; + /** + * The embedding model to use for embedding facet values + */ + embedding_model: string; + bundle_key?: /** + * Key of the topic map bundle in code_bundles bucket + */ + string | undefined; + report_key?: /** + * Key of the clustering report in code_bundles bucket + */ + string | undefined; + topic_names?: /** + * Mapping from topic_id to topic name + */ + {} | undefined; + generation_settings?: TopicMapGenerationSettingsType | undefined; + disable_reconciliation?: /** + * Whether new topic generation should ignore the previously saved report during reconciliation. Defaults to false when omitted. + */ + boolean | undefined; + reconcile_mode?: + | /** + * How reconciliation carries the previous map forward: "evolve" re-routes new samples into the previous topics before naming; "names_only" keeps the fresh clustering and carries only topic ids/names. Defaults to "names_only" when omitted. + * + * @enum evolve, names_only + */ + ("evolve" | "names_only") + | undefined; + distance_threshold?: /** + * Maximum distance to nearest centroid. If exceeded, returns no_match. + */ + number | undefined; + btql_filter?: /** + * Per-topic-map BTQL filter that was applied when this version was generated. Absent on versions generated before this was recorded. + */ + string | undefined; + automation_btql_filter?: /** + * Automation-level BTQL filter that was applied when this version was generated. Absent on versions generated before this was recorded. + */ + string | undefined; +}; +export type BatchedFacetDataType = { + /** + * @enum batched_facet + */ + type: "batched_facet"; + preprocessor?: FacetPreprocessorIdType | undefined; + facets: Array<{ + /** + * The name of the facet + */ + name: string; + /** + * The prompt to use for LLM extraction. The preprocessed text will be provided as context. + */ + prompt: string; + model?: /** + * The model to use for facet extraction + */ + string | undefined; + embedding_model?: /** + * The embedding model to use for vectorizing facet results. + */ + string | undefined; + no_match_pattern?: /** + * Regex pattern to identify outputs that do not match the facet. If the output matches, the facet will be saved as 'no_match' + */ + string | undefined; + }>; + topic_maps?: /** + * Topic maps that depend on facets in this batch, keyed by source facet name. Each source facet can have multiple topic maps. + */ + {} | undefined; +}; +export type BraintrustModelParamsType = Partial<{ + use_cache: boolean; + reasoning_enabled: boolean; + reasoning_budget: number; +}>; +export type CallEventType = + | { + id?: string | undefined; + data: string; + /** + * @enum text_delta + */ + event: "text_delta"; + } + | { + id?: string | undefined; + data: string; + /** + * @enum reasoning_delta + */ + event: "reasoning_delta"; + } + | { + id?: string | undefined; + data: string; + /** + * @enum json_delta + */ + event: "json_delta"; + } + | { + id?: string | undefined; + data: string; + /** + * @enum progress + */ + event: "progress"; + } + | { + id?: string | undefined; + data: string; + /** + * @enum error + */ + event: "error"; + } + | { + id?: string | undefined; + data: string; + /** + * @enum console + */ + event: "console"; + } + | { + id?: string | undefined; + /** + * @enum start + */ + event: "start"; + /** + * @enum + */ + data: ""; + } + | { + id?: string | undefined; + /** + * @enum done + */ + event: "done"; + /** + * @enum + */ + data: ""; + }; +export type ChatCompletionContentPartTextWithTitleType = { + /** + * @default "" + */ + text: string; + /** + * @enum text + */ + type: "text"; + cache_control?: + | { + /** + * @enum ephemeral + */ + type: "ephemeral"; + ttl?: + | /** + * @enum 5m, 1h + */ + ("5m" | "1h") + | undefined; + } + | undefined; +}; +export type ChatCompletionContentPartImageWithTitleType = { + image_url: { + url: string; + detail?: + | ( + | /** + * @enum auto + */ + "auto" + /** + * @enum low + */ + | "low" + /** + * @enum high + */ + | "high" + ) + | undefined; + }; + /** + * @enum image_url + */ + type: "image_url"; + cache_control?: + | { + /** + * @enum ephemeral + */ + type: "ephemeral"; + ttl?: + | /** + * @enum 5m, 1h + */ + ("5m" | "1h") + | undefined; + } + | undefined; +}; +export type ChatCompletionContentPartFileFileType = Partial<{ + file_data: string; + filename: string; + file_id: string; +}>; +export type ChatCompletionContentPartFileWithTitleType = { + file: ChatCompletionContentPartFileFileType; + /** + * @enum file + */ + type: "file"; + cache_control?: + | { + /** + * @enum ephemeral + */ + type: "ephemeral"; + ttl?: + | /** + * @enum 5m, 1h + */ + ("5m" | "1h") + | undefined; + } + | undefined; +}; +export type ChatCompletionContentPartType = + | ChatCompletionContentPartTextWithTitleType + | ChatCompletionContentPartImageWithTitleType + | ChatCompletionContentPartFileWithTitleType; +export type ChatCompletionContentPartTextType = { + /** + * @default "" + */ + text: string; + /** + * @enum text + */ + type: "text"; + cache_control?: + | { + /** + * @enum ephemeral + */ + type: "ephemeral"; + ttl?: + | /** + * @enum 5m, 1h + */ + ("5m" | "1h") + | undefined; + } + | undefined; +}; +export type ChatCompletionMessageToolCallType = { + id: string; + function: { + arguments: string; + name: string; + }; + /** + * @enum function + */ + type: "function"; +}; +export type ChatCompletionMessageReasoningType = Partial<{ + id: string; + content: string; +}>; +export type ChatCompletionMessageParamType = + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum system + */ + role: "system"; + name?: string | undefined; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum user + */ + role: "user"; + name?: string | undefined; + } + | { + /** + * @enum assistant + */ + role: "assistant"; + content?: + | (string | Array | null) + | undefined; + function_call?: + | { + arguments: string; + name: string; + } + | undefined; + name?: string | undefined; + tool_calls?: Array | undefined; + reasoning?: Array | undefined; + reasoning_signature?: string | undefined; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum tool + */ + role: "tool"; + /** + * @default "" + */ + tool_call_id: string; + } + | { + content: string | null; + name: string; + /** + * @enum function + */ + role: "function"; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum developer + */ + role: "developer"; + name?: string | undefined; + } + | { + /** + * @enum model + */ + role: "model"; + content?: (string | null) | undefined; + }; +export type ChatCompletionOpenAIMessageParamType = + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum system + */ + role: "system"; + name?: string | undefined; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum user + */ + role: "user"; + name?: string | undefined; + } + | { + /** + * @enum assistant + */ + role: "assistant"; + content?: + | (string | Array | null) + | undefined; + function_call?: + | { + arguments: string; + name: string; + } + | undefined; + name?: string | undefined; + tool_calls?: Array | undefined; + reasoning?: Array | undefined; + reasoning_signature?: string | undefined; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum tool + */ + role: "tool"; + /** + * @default "" + */ + tool_call_id: string; + } + | { + content: string | null; + name: string; + /** + * @enum function + */ + role: "function"; + } + | { + content: /** + * @default "" + */ + string | Array; + /** + * @enum developer + */ + role: "developer"; + name?: string | undefined; + }; +export type ChatCompletionToolType = { + function: { + name: string; + description?: string | undefined; + parameters?: {} | undefined; + }; + /** + * @enum function + */ + type: "function"; +}; +export type CodeBundleType = { + runtime_context: { + /** + * @enum node, python, browser, quickjs + */ + runtime: "node" | "python" | "browser" | "quickjs"; + version: string; + }; + location: + | { + /** + * @enum experiment + */ + type: "experiment"; + eval_name: string; + position: + | { + /** + * @enum task + */ + type: "task"; + } + | { + /** + * @enum scorer + */ + type: "scorer"; + /** + * @minimum 0 + */ + index: number; + } + | { + /** + * @enum classifier + */ + type: "classifier"; + /** + * @minimum 0 + */ + index: number; + }; + } + | { + /** + * @enum function + */ + type: "function"; + /** + * @minimum 0 + */ + index: number; + } + | { + /** + * @enum sandbox + */ + type: "sandbox"; + sandbox_spec: + | { + /** + * @enum modal + */ + provider: "modal"; + /** + * sandbox snapshot ref + */ + snapshot_ref: string; + } + | { + /** + * @enum lambda + */ + provider: "lambda"; + }; + entrypoints?: /** + * Which entrypoints to execute in the sandbox + */ + Array | undefined; + eval_name: string; + parameters?: /** + * Parameter values for sandbox eval execution + */ + {} | undefined; + evaluator_definition?: /** + * Definition of current evaluator with parameters + */ + unknown | undefined; + }; + bundle_id?: (string | null) | undefined; + preview?: + | /** + * A preview of the code + */ + /** + * A preview of the code + */ + (| string + /** + * A preview of the code + */ + | null + ) + | undefined; +}; +export type DatasetType = { + /** + * Unique identifier for the dataset + */ + id: string; + /** + * Unique identifier for the project that the dataset belongs under + */ + project_id: string; + /** + * Name of the dataset. Within a project, dataset names are unique + */ + name: string; + description?: + | /** + * Textual description of the dataset + */ + /** + * Textual description of the dataset + */ + (| string + /** + * Textual description of the dataset + */ + | null + ) + | undefined; + created?: + | /** + * Date of dataset creation + */ + /** + * Date of dataset creation + */ + (| string + /** + * Date of dataset creation + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of dataset deletion, or null if the dataset is still active + */ + /** + * Date of dataset deletion, or null if the dataset is still active + */ + (| string + /** + * Date of dataset deletion, or null if the dataset is still active + */ + | null + ) + | undefined; + user_id?: + | /** + * Identifies the user who created the dataset + */ + /** + * Identifies the user who created the dataset + */ + (| string + /** + * Identifies the user who created the dataset + */ + | null + ) + | undefined; + tags?: + | /** + * A list of tags for the dataset + */ + /** + * A list of tags for the dataset + */ + (| Array + /** + * A list of tags for the dataset + */ + | null + ) + | undefined; + metadata?: + | /** + * User-controlled metadata about the dataset + */ + /** + * User-controlled metadata about the dataset + */ + (| {} + /** + * User-controlled metadata about the dataset + */ + | null + ) + | undefined; + /** + * URL slug for the dataset. used to construct dataset URLs + */ + url_slug: string; +}; +export type ObjectReferenceNullishType = + /** + * Indicates the event was copied from another object. + */ + /** + * Indicates the event was copied from another object. + */ + | { + /** + * Type of the object the event is originating from. + * + * @enum project_logs, experiment, dataset, prompt, function, prompt_session + */ + object_type: + | "project_logs" + | "experiment" + | "dataset" + | "prompt" + | "function" + | "prompt_session"; + /** + * ID of the object the event is originating from. + */ + object_id: string; + /** + * ID of the original event. + */ + id: string; + _xact_id?: + | /** + * Transaction ID of the original event. + */ + /** + * Transaction ID of the original event. + */ + (| string + /** + * Transaction ID of the original event. + */ + | null + ) + | undefined; + created?: + | /** + * Created timestamp of the original event. Used to help sort in the UI + */ + /** + * Created timestamp of the original event. Used to help sort in the UI + */ + (| string + /** + * Created timestamp of the original event. Used to help sort in the UI + */ + | null + ) + | undefined; + } + /** + * Indicates the event was copied from another object. + */ + | null; +export type SavedFunctionIdType = + | { + /** + * @enum function + */ + type: "function"; + id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + function_type: FunctionTypeEnumType; + }; +export type DatasetEventType = { + /** + * A unique identifier for the dataset event. If you don't provide one, Braintrust will generate one for you + */ + id: string; + /** + * 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) + */ + _xact_id: string; + /** + * The timestamp the dataset event was created + */ + created: string; + _pagination_key?: + | /** + * A stable, time-ordered key that can be used to paginate over dataset events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + /** + * A stable, time-ordered key that can be used to paginate over dataset events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + (| string + /** + * A stable, time-ordered key that can be used to paginate over dataset events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + | null + ) + | undefined; + /** + * Unique identifier for the project that the dataset belongs under + */ + project_id: string; + /** + * Unique identifier for the dataset + */ + dataset_id: string; + input?: /** + * The argument that uniquely define an input case (an arbitrary, JSON serializable object) + */ + unknown | undefined; + expected?: /** + * The output of your application, including post-processing (an arbitrary, JSON serializable object) + */ + unknown | undefined; + 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'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 + */ + /** + * 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 + */ + (| Partial< + { + /** + * The model used for this example + */ + model: /** + * The model used for this example + */ + | string + /** + * The model used for this example + */ + | null; + } & { + [key: string]: any; + } + > + /** + * 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 + */ + | null + ) + | undefined; + tags?: + | /** + * A list of tags to log + */ + /** + * A list of tags to log + */ + (| Array + /** + * A list of tags to log + */ + | null + ) + | undefined; + /** + * A unique identifier used to link different dataset events together as part of a full trace. See the [tracing guide](https://www.braintrust.dev/docs/instrument) for full details on tracing + */ + span_id: string; + /** + * A unique identifier for the trace this dataset event belongs to + */ + root_span_id: string; + is_root?: + | /** + * Whether this span is a root span + */ + /** + * Whether this span is a root span + */ + (| boolean + /** + * Whether this span is a root span + */ + | null + ) + | undefined; + origin?: ObjectReferenceNullishType | undefined; + comments?: + | /** + * Optional list of comments attached to this event + */ + /** + * Optional list of comments attached to this event + */ + (| Array + /** + * Optional list of comments attached to this event + */ + | null + ) + | undefined; + audit_data?: + | /** + * Optional list of audit entries attached to this event + */ + /** + * Optional list of audit entries attached to this event + */ + (| Array + /** + * Optional list of audit entries attached to this event + */ + | null + ) + | undefined; + facets?: + | /** + * Facets for categorization (dictionary from facet id to value) + */ + /** + * Facets for categorization (dictionary from facet id to value) + */ + (| {} + /** + * Facets for categorization (dictionary from facet id to value) + */ + | null + ) + | undefined; + classifications?: + | /** + * Classifications for this event (dictionary from classification name to items) + */ + /** + * Classifications for this event (dictionary from classification name to items) + */ + (| {} + /** + * Classifications for this event (dictionary from classification name to items) + */ + | null + ) + | undefined; +}; +export type DatasetSnapshotType = { + /** + * Unique identifier for the dataset snapshot + */ + id: string; + /** + * Unique identifier for the dataset that this snapshot belongs to + */ + dataset_id: string; + /** + * Name of the dataset snapshot + */ + name: string; + description: string | null; + /** + * Transaction id of the brainstore version at the time of the snapshot + */ + xact_id: string; + /** + * Date of dataset snapshot creation + */ + created: /** + * Date of dataset snapshot creation + */ + | string + /** + * Date of dataset snapshot creation + */ + | null; +}; +export type EnvVarType = { + /** + * Unique identifier for the environment variable + */ + id: string; + /** + * The type of the object the environment variable is scoped for + * + * @enum organization, project, function + */ + object_type: "organization" | "project" | "function"; + /** + * The id of the object the environment variable is scoped for + */ + object_id: string; + /** + * The name of the environment variable + */ + name: string; + created?: + | /** + * Date of environment variable creation + */ + /** + * Date of environment variable creation + */ + (| string + /** + * Date of environment variable creation + */ + | null + ) + | undefined; + secret_updated_at?: + | /** + * Date of last update to the encrypted secret value itself + */ + /** + * Date of last update to the encrypted secret value itself + */ + (| string + /** + * Date of last update to the encrypted secret value itself + */ + | null + ) + | undefined; + secret_updated_by_user_id?: + | /** + * User id of the last update to the encrypted secret value + */ + /** + * User id of the last update to the encrypted secret value + */ + (| string + /** + * User id of the last update to the encrypted secret value + */ + | null + ) + | undefined; + used?: + | /** + * Date the environment variable was last used + */ + /** + * Date the environment variable was last used + */ + (| string + /** + * Date the environment variable was last used + */ + | null + ) + | undefined; + metadata?: + | /** + * Optional metadata associated with the environment variable when managed via the function secrets API + */ + /** + * Optional metadata associated with the environment variable when managed via the function secrets API + */ + (| {} + /** + * Optional metadata associated with the environment variable when managed via the function secrets API + */ + | null + ) + | undefined; + preview_secret?: + | /** + * Redacted preview of the stored secret value + */ + /** + * Redacted preview of the stored secret value + */ + (| string + /** + * Redacted preview of the stored secret value + */ + | null + ) + | undefined; + secret_type?: + | /** + * Optional classification for the secret (for example, the AI provider name) + */ + /** + * Optional classification for the secret (for example, the AI provider name) + */ + (| string + /** + * Optional classification for the secret (for example, the AI provider name) + */ + | null + ) + | undefined; + /** + * The category of the secret: env_var for regular environment variables, ai_provider for AI provider API keys + * + * @default "env_var" + * @enum env_var, ai_provider, sandbox_provider + */ + secret_category: "env_var" | "ai_provider" | "sandbox_provider"; +}; +export type RepoInfoType = + /** + * Metadata about the state of the repo when the experiment was created + */ + /** + * Metadata about the state of the repo when the experiment was created + */ + | Partial<{ + /** + * SHA of most recent commit + */ + commit: /** + * SHA of most recent commit + */ + | string + /** + * SHA of most recent commit + */ + | null; + /** + * Name of the branch the most recent commit belongs to + */ + branch: /** + * Name of the branch the most recent commit belongs to + */ + | string + /** + * Name of the branch the most recent commit belongs to + */ + | null; + /** + * Name of the tag on the most recent commit + */ + tag: /** + * Name of the tag on the most recent commit + */ + | string + /** + * Name of the tag on the most recent commit + */ + | null; + /** + * Whether or not the repo had uncommitted changes when snapshotted + */ + dirty: /** + * Whether or not the repo had uncommitted changes when snapshotted + */ + | boolean + /** + * Whether or not the repo had uncommitted changes when snapshotted + */ + | null; + /** + * Name of the author of the most recent commit + */ + author_name: /** + * Name of the author of the most recent commit + */ + | string + /** + * Name of the author of the most recent commit + */ + | null; + /** + * Email of the author of the most recent commit + */ + author_email: /** + * Email of the author of the most recent commit + */ + | string + /** + * Email of the author of the most recent commit + */ + | null; + /** + * Most recent commit message + */ + commit_message: /** + * Most recent commit message + */ + | string + /** + * Most recent commit message + */ + | null; + /** + * Time of the most recent commit + */ + commit_time: /** + * Time of the most recent commit + */ + | string + /** + * Time of the most recent commit + */ + | null; + /** + * If the repo was dirty when run, this includes the diff between the current state of the repo and the most recent commit. + */ + git_diff: /** + * If the repo was dirty when run, this includes the diff between the current state of the repo and the most recent commit. + */ + | string + /** + * If the repo was dirty when run, this includes the diff between the current state of the repo and the most recent commit. + */ + | null; + }> + /** + * Metadata about the state of the repo when the experiment was created + */ + | null; +export type ExperimentType = { + /** + * Unique identifier for the experiment + */ + id: string; + /** + * Unique identifier for the project that the experiment belongs under + */ + project_id: string; + /** + * Name of the experiment. Within a project, experiment names are unique + */ + name: string; + description?: + | /** + * Textual description of the experiment + */ + /** + * Textual description of the experiment + */ + (| string + /** + * Textual description of the experiment + */ + | null + ) + | undefined; + created?: + | /** + * Date of experiment creation + */ + /** + * Date of experiment creation + */ + (| string + /** + * Date of experiment creation + */ + | null + ) + | undefined; + repo_info?: RepoInfoType | undefined; + commit?: + | /** + * Commit, taken directly from `repo_info.commit` + */ + /** + * Commit, taken directly from `repo_info.commit` + */ + (| string + /** + * Commit, taken directly from `repo_info.commit` + */ + | null + ) + | undefined; + base_exp_id?: + | /** + * Id of default base experiment to compare against when viewing this experiment + */ + /** + * Id of default base experiment to compare against when viewing this experiment + */ + (| string + /** + * Id of default base experiment to compare against when viewing this experiment + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of experiment deletion, or null if the experiment is still active + */ + /** + * Date of experiment deletion, or null if the experiment is still active + */ + (| string + /** + * Date of experiment deletion, or null if the experiment is still active + */ + | null + ) + | undefined; + dataset_id?: + | /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + (| string + /** + * Identifier of the linked dataset, or null if the experiment is not linked to a dataset + */ + | null + ) + | undefined; + dataset_version?: + | /** + * 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. + */ + /** + * 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. + */ + (| string + /** + * 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. + */ + | null + ) + | undefined; + internal_metadata?: + | /** + * Braintrust-controlled metadata about the experiment. + */ + /** + * Braintrust-controlled metadata about the experiment. + */ + (| Partial< + { + /** + * BTQL filter payload used to evaluate a subset of a linked dataset. + */ + dataset_filter: /** + * BTQL filter payload used to evaluate a subset of a linked dataset. + */ + | {} + /** + * BTQL filter payload used to evaluate a subset of a linked dataset. + */ + | null; + } & { + [key: string]: any; + } + > + /** + * Braintrust-controlled metadata about the experiment. + */ + | null + ) + | undefined; + parameters_id?: + | /** + * Identifier of the linked saved parameters object, or null if the experiment is not linked to saved parameters + */ + /** + * Identifier of the linked saved parameters object, or null if the experiment is not linked to saved parameters + */ + (| string + /** + * Identifier of the linked saved parameters object, or null if the experiment is not linked to saved parameters + */ + | null + ) + | undefined; + parameters_version?: + | /** + * Version number of the linked saved parameters object the experiment was run against. + */ + /** + * Version number of the linked saved parameters object the experiment was run against. + */ + (| string + /** + * Version number of the linked saved parameters object the experiment was run against. + */ + | null + ) + | undefined; + /** + * Whether or not the experiment is public. Public experiments can be viewed by anybody inside or outside the organization + */ + public: boolean; + user_id?: + | /** + * Identifies the user who created the experiment + */ + /** + * Identifies the user who created the experiment + */ + (| string + /** + * Identifies the user who created the experiment + */ + | null + ) + | undefined; + metadata?: + | /** + * User-controlled metadata about the experiment + */ + /** + * User-controlled metadata about the experiment + */ + (| {} + /** + * User-controlled metadata about the experiment + */ + | null + ) + | undefined; + tags?: + | /** + * A list of tags for the experiment + */ + /** + * A list of tags for the experiment + */ + (| Array + /** + * A list of tags for the experiment + */ + | null + ) + | undefined; +}; +export type SpanTypeType = + /** + * Type of the span, for display purposes only + * + * @enum llm, score, function, eval, task, tool, automation, facet, preprocessor, classifier, review + */ + | /** + * Type of the span, for display purposes only + * + * @enum llm, score, function, eval, task, tool, automation, facet, preprocessor, classifier, review + */ + (| "llm" + | "score" + | "function" + | "eval" + | "task" + | "tool" + | "automation" + | "facet" + | "preprocessor" + | "classifier" + | "review" + ) + /** + * Type of the span, for display purposes only + * + * @enum llm, score, function, eval, task, tool, automation, facet, preprocessor, classifier, review + */ + | null; +export type SpanAttributesType = + /** + * Human-identifying attributes of the span, such as name, type, etc. + */ + /** + * Human-identifying attributes of the span, such as name, type, etc. + */ + | Partial< + { + /** + * Name of the span, for display purposes only + */ + name: /** + * Name of the span, for display purposes only + */ + | string + /** + * Name of the span, for display purposes only + */ + | null; + type: SpanTypeType; + /** + * A special value that indicates the span was generated by a scoring automation + * + * @enum scorer + */ + purpose: + | /** + * A special value that indicates the span was generated by a scoring automation + * + * @enum scorer + */ + "scorer" + /** + * A special value that indicates the span was generated by a scoring automation + * + * @enum scorer + */ + | null; + } & { + [key: string]: any; + } + > + /** + * Human-identifying attributes of the span, such as name, type, etc. + */ + | null; +export type ExperimentEventType = { + /** + * A unique identifier for the experiment event. If you don't provide one, Braintrust will generate one for you + */ + id: string; + /** + * 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) + */ + _xact_id: string; + /** + * The timestamp the experiment event was created + */ + created: string; + _pagination_key?: + | /** + * A stable, time-ordered key that can be used to paginate over experiment events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + /** + * A stable, time-ordered key that can be used to paginate over experiment events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + (| string + /** + * A stable, time-ordered key that can be used to paginate over experiment events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + | null + ) + | undefined; + /** + * Unique identifier for the project that the experiment belongs under + */ + project_id: string; + /** + * Unique identifier for the experiment + */ + experiment_id: string; + input?: /** + * 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 + */ + unknown | undefined; + 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 `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 + */ + unknown | undefined; + expected?: /** + * 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 + */ + unknown | undefined; + error?: /** + * The error that occurred, if any. + */ + unknown | undefined; + 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 + */ + /** + * 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 + */ + (| {} + /** + * 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 + */ + | null + ) + | undefined; + 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'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 + */ + /** + * 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 + */ + (| Partial< + { + /** + * The model used for this example + */ + model: /** + * The model used for this example + */ + | string + /** + * The model used for this example + */ + | null; + } & { + [key: string]: any; + } + > + /** + * 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 + */ + | null + ) + | undefined; + tags?: + | /** + * A list of tags to log + */ + /** + * A list of tags to log + */ + (| Array + /** + * A list of tags to log + */ + | null + ) + | undefined; + 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 + */ + (| /** + * 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 + */ + ({} & { + [key: string]: number; + }) + /** + * 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 + */ + | null + ) + | undefined; + context?: + | /** + * 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 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 + */ + (| Partial< + { + /** + * The function in code which created the experiment event + */ + caller_functionname: /** + * The function in code which created the experiment event + */ + | string + /** + * The function in code which created the experiment event + */ + | null; + /** + * Name of the file in code where the experiment event was created + */ + caller_filename: /** + * Name of the file in code where the experiment event was created + */ + | string + /** + * Name of the file in code where the experiment event was created + */ + | null; + /** + * Line of code where the experiment event was created + */ + caller_lineno: /** + * Line of code where the experiment event was created + */ + | number + /** + * Line of code where the experiment event was created + */ + | null; + } & { + [key: string]: any; + } + > + /** + * 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 + */ + | null + ) + | undefined; + /** + * A unique identifier used to link different experiment events together as part of a full trace. See the [tracing guide](https://www.braintrust.dev/docs/instrument) for full details on tracing + */ + span_id: string; + span_parents?: + | /** + * 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 + */ + /** + * 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 + */ + (| Array + /** + * 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 + */ + | null + ) + | undefined; + /** + * A unique identifier for the trace this experiment event belongs to + */ + root_span_id: string; + span_attributes?: SpanAttributesType | undefined; + is_root?: + | /** + * Whether this span is a root span + */ + /** + * Whether this span is a root span + */ + (| boolean + /** + * Whether this span is a root span + */ + | null + ) + | undefined; + origin?: ObjectReferenceNullishType | undefined; + comments?: + | /** + * Optional list of comments attached to this event + */ + /** + * Optional list of comments attached to this event + */ + (| Array + /** + * Optional list of comments attached to this event + */ + | null + ) + | undefined; + audit_data?: + | /** + * Optional list of audit entries attached to this event + */ + /** + * Optional list of audit entries attached to this event + */ + (| Array + /** + * Optional list of audit entries attached to this event + */ + | null + ) + | undefined; + facets?: + | /** + * Facets for categorization (dictionary from facet id to value) + */ + /** + * Facets for categorization (dictionary from facet id to value) + */ + (| {} + /** + * Facets for categorization (dictionary from facet id to value) + */ + | null + ) + | undefined; + classifications?: + | /** + * Classifications for this event (dictionary from classification name to items) + */ + /** + * Classifications for this event (dictionary from classification name to items) + */ + (| {} + /** + * Classifications for this event (dictionary from classification name to items) + */ + | null + ) + | undefined; +}; +export type ExtendedSavedFunctionIdType = + | { + /** + * @enum function + */ + type: "function"; + id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + function_type: FunctionTypeEnumType; + } + | { + /** + * @enum slug + */ + type: "slug"; + project_id: string; + slug: string; + }; +export type FacetDataType = { + /** + * @enum facet + */ + type: "facet"; + preprocessor?: FacetPreprocessorIdType | undefined; + /** + * The prompt to use for LLM extraction. The preprocessed text will be provided as context. + */ + prompt: string; + model?: /** + * The model to use for facet extraction + */ + string | undefined; + embedding_model?: /** + * The embedding model to use for vectorizing facet results. + */ + string | undefined; + no_match_pattern?: /** + * Regex pattern to identify outputs that do not match the facet. If the output matches, the facet will be saved as 'no_match' + */ + string | undefined; +}; +export type PromptBlockDataNullishType = + | { + /** + * @enum chat + */ + type: "chat"; + messages: Array; + tools?: string | undefined; + } + | { + /** + * @enum completion + */ + type: "completion"; + content: string; + } + | null; +export type ModelParamsType = + | Partial< + { + use_cache: boolean; + reasoning_enabled: boolean; + reasoning_budget: number; + temperature: number; + top_p: number; + max_tokens: number; + /** + * The successor to max_tokens + */ + max_completion_tokens: number; + frequency_penalty: number; + presence_penalty: number; + response_format: ResponseFormatNullishType; + tool_choice: + | /** + * @enum auto + */ + "auto" + /** + * @enum none + */ + | "none" + /** + * @enum required + */ + | "required" + | { + /** + * @enum function + */ + type: "function"; + function: { + name: string; + }; + }; + function_call: + | /** + * @enum auto + */ + "auto" + /** + * @enum none + */ + | "none" + | { + name: string; + }; + n: number; + stop: Array; + /** + * @enum none, minimal, low, medium, high + */ + reasoning_effort: "none" | "minimal" | "low" | "medium" | "high"; + /** + * @enum low, medium, high + */ + verbosity: "low" | "medium" | "high"; + } & { + [key: string]: any; + } + > + | ({ + use_cache?: boolean | undefined; + reasoning_enabled?: boolean | undefined; + reasoning_budget?: number | undefined; + max_tokens: number; + temperature: number; + top_p?: number | undefined; + top_k?: number | undefined; + stop_sequences?: Array | undefined; + max_tokens_to_sample?: /** + * This is a legacy parameter that should not be used. + */ + number | undefined; + } & { + [key: string]: any; + }) + | Partial< + { + use_cache: boolean; + reasoning_enabled: boolean; + reasoning_budget: number; + temperature: number; + maxOutputTokens: number; + topP: number; + topK: number; + } & { + [key: string]: any; + } + > + | Partial< + { + use_cache: boolean; + reasoning_enabled: boolean; + reasoning_budget: number; + temperature: number; + topK: number; + } & { + [key: string]: any; + } + > + | Partial< + { + use_cache: boolean; + reasoning_enabled: boolean; + reasoning_budget: number; + } & { + [key: string]: any; + } + >; +export type PromptOptionsNullishType = Partial<{ + model: string; + params: ModelParamsType; + position: string; + endpoint_name: string | null; +}> | null; +export type PromptParserNullishType = { + /** + * @enum llm_classifier + */ + type: "llm_classifier"; + use_cot: boolean; + choice_scores?: /** + * Map of choices to scores (0-1). Used by scorers. + */ + {} | undefined; + choice?: /** + * List of valid choices without score mapping. Used by classifiers that deposit output to tags. + */ + Array | undefined; + allow_no_match?: /** + * If true, adds a 'No match' option. When selected, no tag is deposited. + */ + boolean | undefined; + allow_skip?: /** + * If true, adds a 'Skip' option. When selected, the scorer returns null. + */ + boolean | undefined; +} | null; +export type PreprocessorSavedFunctionIdType = + /** + * For prompt-backed scorers: the preprocessor function to use for trace template variables. Set to null to disable preprocessing. If omitted, the traced project's default preprocessor will be used, falling back to the global 'thread' preprocessor. + */ + | { + /** + * @enum function + */ + type: "function"; + id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + /** + * The type of global function. Defaults to 'preprocessor'. + * + * @default "preprocessor" + * @enum preprocessor + */ + function_type: "preprocessor"; + } + | null; +export type PromptDataNullishType = + /** + * The prompt, model, and its parameters + */ + /** + * The prompt, model, and its parameters + */ + | Partial<{ + prompt: PromptBlockDataNullishType; + options: PromptOptionsNullishType; + parser: PromptParserNullishType; + preprocessor: PreprocessorSavedFunctionIdType; + tool_functions: Array | null; + /** + * @enum mustache, nunjucks, none + */ + template_format: + | /** + * @enum mustache, nunjucks, none + */ + ("mustache" | "nunjucks" | "none") + /** + * @enum mustache, nunjucks, none + */ + | null; + mcp: {} | null; + origin: Partial<{ + prompt_id: string; + project_id: string; + prompt_version: string; + }> | null; + }> + /** + * The prompt, model, and its parameters + */ + | null; +export type FunctionTypeEnumNullishType = + /** + * @enum llm, scorer, task, tool, custom_view, preprocessor, facet, classifier, tag, parameters, sandbox + */ + | /** + * @enum llm, scorer, task, tool, custom_view, preprocessor, facet, classifier, tag, parameters, sandbox + */ + (| "llm" + | "scorer" + | "task" + | "tool" + | "custom_view" + | "preprocessor" + | "facet" + | "classifier" + | "tag" + | "parameters" + | "sandbox" + ) + /** + * @enum llm, scorer, task, tool, custom_view, preprocessor, facet, classifier, tag, parameters, sandbox + */ + | null; +export type FunctionIdRefType = Partial< + {} & { + [key: string]: any; + } +>; +export type PromptBlockDataType = + | { + /** + * @enum chat + */ + type: "chat"; + messages: Array; + tools?: string | undefined; + } + | { + /** + * @enum completion + */ + type: "completion"; + content: string; + }; +export type GraphNodeType = + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum function + */ + type: "function"; + function: FunctionIdRefType; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * The input to the graph + * + * @enum input + */ + type: "input"; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * The output of the graph + * + * @enum output + */ + type: "output"; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum literal + */ + type: "literal"; + value?: /** + * A literal value to be returned + */ + unknown | undefined; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum btql + */ + type: "btql"; + /** + * A BTQL expression to be evaluated + */ + expr: string; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum gate + */ + type: "gate"; + condition?: + | /** + * A BTQL expression to be evaluated + */ + /** + * A BTQL expression to be evaluated + */ + (| string + /** + * A BTQL expression to be evaluated + */ + | null + ) + | undefined; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum aggregator + */ + type: "aggregator"; + } + | { + description?: + | /** + * The description of the node + */ + /** + * The description of the node + */ + (| string + /** + * The description of the node + */ + | null + ) + | undefined; + position?: + | /** + * The position of the node + */ + /** + * The position of the node + */ + (| { + /** + * The x position of the node + */ + x: number; + /** + * The y position of the node + */ + y: number; + } + /** + * The position of the node + */ + | null + ) + | undefined; + /** + * @enum prompt_template + */ + type: "prompt_template"; + prompt: PromptBlockDataType; + }; +export type GraphEdgeType = { + source: { + /** + * The id of the node in the graph + * + * @maxLength 1024 + */ + node: string; + variable: string; + }; + target: { + /** + * The id of the node in the graph + * + * @maxLength 1024 + */ + node: string; + variable: string; + }; + /** + * The purpose of the edge + * + * @enum control, data, messages + */ + purpose: "control" | "data" | "messages"; +}; +export type GraphDataType = { + /** + * @enum graph + */ + type: "graph"; + nodes: {}; + edges: {}; +}; +export type FunctionDataType = + | { + /** + * @enum prompt + */ + type: "prompt"; + } + | { + /** + * @enum code + */ + type: "code"; + data: + | ({ + /** + * @enum bundle + */ + type: "bundle"; + } & CodeBundleType) + | { + /** + * @enum inline + */ + type: "inline"; + runtime_context: { + /** + * @enum node, python, browser, quickjs + */ + runtime: "node" | "python" | "browser" | "quickjs"; + version: string; + }; + code: string; + code_hash?: /** + * SHA256 hash of the code, computed at save time + */ + string | undefined; + }; + } + | GraphDataType + /** + * A remote eval to run + */ + | { + /** + * @enum remote_eval + */ + type: "remote_eval"; + endpoint: string; + eval_name: string; + parameters: {}; + parameters_version?: + | /** + * The version (transaction ID) of the parameters being used + */ + /** + * The version (transaction ID) of the parameters being used + */ + (| string + /** + * The version (transaction ID) of the parameters being used + */ + | null + ) + | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + function_type: FunctionTypeEnumType; + config?: + | /** + * Configuration options to pass to the global function (e.g., for preprocessor customization) + */ + /** + * Configuration options to pass to the global function (e.g., for preprocessor customization) + */ + (| {} + /** + * Configuration options to pass to the global function (e.g., for preprocessor customization) + */ + | null + ) + | undefined; + } + | FacetDataType + | BatchedFacetDataType + | { + /** + * @enum parameters + */ + type: "parameters"; + /** + * The parameters data + */ + data: {}; + /** + * JSON Schema format for parameters + */ + __schema: { + /** + * @enum object + */ + type: "object"; + properties: {}; + required?: Array | undefined; + additionalProperties?: boolean | undefined; + }; + } + | (TopicMapDataType & unknown); +export type FunctionType = { + /** + * Unique identifier for the prompt + */ + id: string; + /** + * 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 prompt (see the `version` parameter) + */ + _xact_id: string; + /** + * Unique identifier for the project that the prompt belongs under + */ + project_id: string; + /** + * A literal 'p' which identifies the object as a project prompt + * + * @enum p + */ + log_id: "p"; + /** + * Unique identifier for the organization + */ + org_id: string; + /** + * Name of the prompt + */ + name: string; + /** + * Unique identifier for the prompt + */ + slug: string; + description?: + | /** + * Textual description of the prompt + */ + /** + * Textual description of the prompt + */ + (| string + /** + * Textual description of the prompt + */ + | null + ) + | undefined; + created?: + | /** + * Date of prompt creation + */ + /** + * Date of prompt creation + */ + (| string + /** + * Date of prompt creation + */ + | null + ) + | undefined; + prompt_data?: PromptDataNullishType | undefined; + tags?: + | /** + * A list of tags for the prompt + */ + /** + * A list of tags for the prompt + */ + (| Array + /** + * A list of tags for the prompt + */ + | null + ) + | undefined; + metadata?: + | /** + * User-controlled metadata about the prompt + */ + /** + * User-controlled metadata about the prompt + */ + (| {} + /** + * User-controlled metadata about the prompt + */ + | null + ) + | undefined; + function_type?: FunctionTypeEnumNullishType | undefined; + function_data: FunctionDataType; + origin?: + | ({ + object_type: AclObjectTypeType & string; + /** + * Id of the object the function is originating from + */ + object_id: string; + internal?: + | /** + * The function exists for internal purposes and should not be displayed in the list of functions. + */ + /** + * The function exists for internal purposes and should not be displayed in the list of functions. + */ + (| boolean + /** + * The function exists for internal purposes and should not be displayed in the list of functions. + */ + | null + ) + | undefined; + } | null) + | undefined; + function_schema?: + | /** + * JSON schema for the function's parameters and return type + */ + /** + * JSON schema for the function's parameters and return type + */ + (| Partial<{ + parameters: unknown; + returns: unknown; + }> + /** + * JSON schema for the function's parameters and return type + */ + | null + ) + | undefined; +}; +export type FunctionFormatType = + /** + * @enum llm, code, global, graph, topic_map + */ + "llm" | "code" | "global" | "graph" | "topic_map"; +export type PromptDataType = Partial<{ + prompt: PromptBlockDataNullishType; + options: PromptOptionsNullishType; + parser: PromptParserNullishType; + preprocessor: PreprocessorSavedFunctionIdType; + tool_functions: Array | null; + /** + * @enum mustache, nunjucks, none + */ + template_format: + | /** + * @enum mustache, nunjucks, none + */ + ("mustache" | "nunjucks" | "none") + /** + * @enum mustache, nunjucks, none + */ + | null; + mcp: {} | null; + origin: Partial<{ + prompt_id: string; + project_id: string; + prompt_version: string; + }> | null; +}>; +export type FunctionIdType = + /** + * Options for identifying a function + */ + /** + * Function id + */ + | { + /** + * The ID of the function + */ + function_id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + /** + * Project name and slug + */ + | { + /** + * The name of the project containing the function + */ + project_name: string; + /** + * The slug of the function + */ + slug: string; + version?: /** + * The version of the function + */ + string | undefined; + } + /** + * Global function name + */ + | { + /** + * The name of the global function. Currently, the global namespace includes the functions in autoevals + */ + global_function: string; + function_type: FunctionTypeEnumType; + } + /** + * Prompt session id + */ + | { + /** + * The ID of the prompt session + */ + prompt_session_id: string; + /** + * The ID of the function in the prompt session + */ + prompt_session_function_id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + /** + * Inline code function + */ + | { + inline_context: { + /** + * @enum node, python, browser, quickjs + */ + runtime: "node" | "python" | "browser" | "quickjs"; + version: string; + }; + /** + * The inline code to execute + */ + code: string; + function_type?: + | (FunctionTypeEnumType & + /** + * The function type for inline code. Required when invoking inline preprocessors. + */ unknown) + | undefined; + name?: + | /** + * The name of the inline code function + */ + /** + * The name of the inline code function + */ + (| string + /** + * The name of the inline code function + */ + | null + ) + | undefined; + } + /** + * Inline function definition + */ + | { + inline_prompt?: PromptDataType | undefined; + inline_function: {}; + function_type: FunctionTypeEnumType; + name?: + | /** + * The name of the inline function + */ + /** + * The name of the inline function + */ + (| string + /** + * The name of the inline function + */ + | null + ) + | undefined; + } + /** + * Inline prompt definition + */ + | { + inline_prompt: PromptDataType; + function_type: FunctionTypeEnumType; + name?: + | /** + * The name of the inline prompt + */ + /** + * The name of the inline prompt + */ + (| string + /** + * The name of the inline prompt + */ + | null + ) + | undefined; + }; +export type FunctionObjectTypeType = + /** + * @enum prompt, tool, scorer, task, workflow, custom_view, preprocessor, facet, classifier, parameters, sandbox + */ + | "prompt" + | "tool" + | "scorer" + | "task" + | "workflow" + | "custom_view" + | "preprocessor" + | "facet" + | "classifier" + | "parameters" + | "sandbox"; +export type FunctionOutputTypeType = + /** + * @enum completion, score, facet, classification, any + */ + "completion" | "score" | "facet" | "classification" | "any"; +export type GitMetadataSettingsType = { + /** + * @enum all, none, some + */ + collect: "all" | "none" | "some"; + fields?: + | Array< + /** + * @enum commit, branch, tag, dirty, author_name, author_email, commit_message, commit_time, git_diff + */ + | "commit" + | "branch" + | "tag" + | "dirty" + | "author_name" + | "author_email" + | "commit_message" + | "commit_time" + | "git_diff" + > + | undefined; +}; +export type GroupType = { + /** + * Unique identifier for the group + */ + id: string; + /** + * Unique id for the organization that the group belongs under + + It is forbidden to change the org after creating a group + */ + org_id: string; + user_id?: + | /** + * Identifies the user who created the group + */ + /** + * Identifies the user who created the group + */ + (| string + /** + * Identifies the user who created the group + */ + | null + ) + | undefined; + created?: + | /** + * Date of group creation + */ + /** + * Date of group creation + */ + (| string + /** + * Date of group creation + */ + | null + ) + | undefined; + /** + * Name of the group + */ + name: string; + description?: + | /** + * Textual description of the group + */ + /** + * Textual description of the group + */ + (| string + /** + * Textual description of the group + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of group deletion, or null if the group is still active + */ + /** + * Date of group deletion, or null if the group is still active + */ + (| string + /** + * Date of group deletion, or null if the group is still active + */ + | null + ) + | undefined; + member_users?: + | /** + * Ids of users which belong to this group + */ + /** + * Ids of users which belong to this group + */ + (| Array + /** + * Ids of users which belong to this group + */ + | null + ) + | undefined; + member_groups?: + | /** + * Ids of the groups this group inherits from + + An inheriting group has all the users contained in its member groups, as well as all of their inherited users + */ + /** + * Ids of the groups this group inherits from + + An inheriting group has all the users contained in its member groups, as well as all of their inherited users + */ + (| Array /** + * Ids of the groups this group inherits from + + An inheriting group has all the users contained in its member groups, as well as all of their inherited users + */ + | null + ) + | undefined; +}; +export type GroupScopeType = { + /** + * @enum group + */ + type: "group"; + /** + * Field path to group by, e.g. metadata.session_id + */ + group_by: string; + interval_seconds?: /** + * Maximum time range to include when constructing a group + * + * @minimum 1 + */ + number | undefined; + max_traces?: /** + * Maximum number of traces to include when constructing a group (default/max: 64) + * + * @minimum 1 + * @maximum 64 + */ + number | undefined; + /** + * Which trace or traces to write grouped scorer results to + * + * @enum first, each + */ + placement: "first" | "each"; + idle_seconds?: /** + * Optional: trigger after this many seconds of inactivity + */ + number | undefined; +}; +export type IfExistsType = + /** + * @enum error, ignore, replace + */ + "error" | "ignore" | "replace"; +export type ImageRenderingModeType = + /** + * Controls how images are rendered in the UI: 'auto' loads images automatically, 'click_to_load' shows a placeholder until clicked, 'blocked' prevents image loading entirely + * + * @enum auto, click_to_load, blocked + */ + | /** + * Controls how images are rendered in the UI: 'auto' loads images automatically, 'click_to_load' shows a placeholder until clicked, 'blocked' prevents image loading entirely + * + * @enum auto, click_to_load, blocked + */ + ("auto" | "click_to_load" | "blocked") + /** + * Controls how images are rendered in the UI: 'auto' loads images automatically, 'click_to_load' shows a placeholder until clicked, 'blocked' prevents image loading entirely + * + * @enum auto, click_to_load, blocked + */ + | null; +export type InvokeParentType = + /** + * Options for tracing the function call + */ + /** + * Span parent properties + */ + | { + /** + * @enum project_logs, experiment, playground_logs + */ + object_type: "project_logs" | "experiment" | "playground_logs"; + /** + * The id of the container object you are logging to + */ + object_id: string; + row_ids?: + | /** + * Identifiers for the row to to log a subspan under + */ + /** + * Identifiers for the row to to log a subspan under + */ + (| { + /** + * The id of the row + */ + id: string; + /** + * The span_id of the row + */ + span_id: string; + /** + * The root_span_id of the row + */ + root_span_id: string; + } + /** + * Identifiers for the row to to log a subspan under + */ + | null + ) + | undefined; + propagated_event?: + | /** + * Include these properties in every span created under this parent + */ + /** + * Include these properties in every span created under this parent + */ + (| {} + /** + * Include these properties in every span created under this parent + */ + | null + ) + | undefined; + } + /** + * The parent's span identifier, created by calling `.export()` on a span + */ + | string; +export type StreamingModeType = + /** + * The mode format of the returned value (defaults to 'auto') + * + * @enum auto, parallel, json, text + */ + | /** + * The mode format of the returned value (defaults to 'auto') + * + * @enum auto, parallel, json, text + */ + ("auto" | "parallel" | "json" | "text") + /** + * The mode format of the returned value (defaults to 'auto') + * + * @enum auto, parallel, json, text + */ + | null; +export type InvokeFunctionType = + /** + * Options for identifying a function + */ + FunctionIdType & + Partial<{ + /** + * Argument to the function, which can be any JSON serializable value + */ + input: unknown; + /** + * The expected output of the function + */ + expected: unknown; + /** + * Any relevant metadata. This will be logged and available as the `metadata` argument. + */ + metadata: /** + * Any relevant metadata. This will be logged and available as the `metadata` argument. + */ + | {} + /** + * Any relevant metadata. This will be logged and available as the `metadata` argument. + */ + | null; + /** + * Any relevant tags to log on the span. + */ + tags: /** + * Any relevant tags to log on the span. + */ + | Array + /** + * Any relevant tags to log on the span. + */ + | null; + /** + * If the function is an LLM, additional messages to pass along to it + */ + messages: Array; + parent: InvokeParentType; + /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE format. + */ + stream: /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE format. + */ + | boolean + /** + * Whether to stream the response. If true, results will be returned in the Braintrust SSE format. + */ + | null; + mode: StreamingModeType; + /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + strict: /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + | boolean + /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + | null; + /** + * Map of MCP server URL to auth credentials + */ + mcp_auth: {}; + /** + * Partial function definition to merge with the function being invoked. Fields are validated against the function type's schema at runtime. For facets: { preprocessor?, prompt?, model? }. For prompts: { model?, ... }. + */ + overrides: /** + * Partial function definition to merge with the function being invoked. Fields are validated against the function type's schema at runtime. For facets: { preprocessor?, prompt?, model? }. For prompts: { model?, ... }. + */ + | {} + /** + * Partial function definition to merge with the function being invoked. Fields are validated against the function type's schema at runtime. For facets: { preprocessor?, prompt?, model? }. For prompts: { model?, ... }. + */ + | null; + /** + * Name of the AI provider secret to pin this invocation to. + */ + endpoint_name: /** + * Name of the AI provider secret to pin this invocation to. + */ + | string + /** + * Name of the AI provider secret to pin this invocation to. + */ + | null; + }>; +export type MCPServerType = { + /** + * Unique identifier for the MCP server + */ + id: string; + /** + * Unique identifier for the project that the MCP server belongs under + */ + project_id: string; + user_id?: + | /** + * Identifies the user who created the MCP server + */ + /** + * Identifies the user who created the MCP server + */ + (| string + /** + * Identifies the user who created the MCP server + */ + | null + ) + | undefined; + created?: + | /** + * Date of MCP server creation + */ + /** + * Date of MCP server creation + */ + (| string + /** + * Date of MCP server creation + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of MCP server deletion, or null if the MCP server is still active + */ + /** + * Date of MCP server deletion, or null if the MCP server is still active + */ + (| string + /** + * Date of MCP server deletion, or null if the MCP server is still active + */ + | null + ) + | undefined; + /** + * Name of the MCP server. Within a project, MCP server names are unique + */ + name: string; + description?: + | /** + * Textual description of the MCP server + */ + /** + * Textual description of the MCP server + */ + (| string + /** + * Textual description of the MCP server + */ + | null + ) + | undefined; + /** + * URL of the MCP server endpoint + */ + url: string; +}; +export type MessageRoleType = + /** + * @enum system, user, assistant, function, tool, model, developer + */ + "system" | "user" | "assistant" | "function" | "tool" | "model" | "developer"; +export type NullableSavedFunctionIdType = + /** + * Default preprocessor for this project. When set, functions that use preprocessors will use this instead of their built-in default. + */ + | { + /** + * @enum function + */ + type: "function"; + id: string; + version?: /** + * The version of the function + */ + string | undefined; + } + | { + /** + * @enum global + */ + type: "global"; + name: string; + function_type: FunctionTypeEnumType; + } + | null; +export type ObjectReferenceType = { + /** + * Type of the object the event is originating from. + * + * @enum project_logs, experiment, dataset, prompt, function, prompt_session + */ + object_type: + | "project_logs" + | "experiment" + | "dataset" + | "prompt" + | "function" + | "prompt_session"; + /** + * ID of the object the event is originating from. + */ + object_id: string; + /** + * ID of the original event. + */ + id: string; + _xact_id?: + | /** + * Transaction ID of the original event. + */ + /** + * Transaction ID of the original event. + */ + (| string + /** + * Transaction ID of the original event. + */ + | null + ) + | undefined; + created?: + | /** + * Created timestamp of the original event. Used to help sort in the UI + */ + /** + * Created timestamp of the original event. Used to help sort in the UI + */ + (| string + /** + * Created timestamp of the original event. Used to help sort in the UI + */ + | null + ) + | undefined; +}; +export type SpanScopeType = { + /** + * @enum span + */ + type: "span"; +}; +export type TraceScopeType = { + /** + * @enum trace + */ + type: "trace"; + idle_seconds?: /** + * Consider trace complete after this many seconds of inactivity (default: 30) + */ + number | undefined; +}; +export type OnlineScoreConfigType = { + status?: AutomationStatusType | undefined; + /** + * The sampling rate for online scoring + * + * @minimum 0 + * @maximum 1 + */ + sampling_rate: number; + /** + * The list of functions to run for online scoring. Can include scorers, facets, or other function types. + */ + scorers: Array; + btql_filter?: + | /** + * Filter logs using BTQL + */ + /** + * Filter logs using BTQL + */ + (| string + /** + * Filter logs using BTQL + */ + | null + ) + | undefined; + apply_to_root_span?: + | /** + * Whether to trigger online scoring on the root span of each trace. Only applies when scope is 'span' or unset. + */ + /** + * Whether to trigger online scoring on the root span of each trace. Only applies when scope is 'span' or unset. + */ + (| boolean + /** + * Whether to trigger online scoring on the root span of each trace. Only applies when scope is 'span' or unset. + */ + | null + ) + | undefined; + apply_to_span_names?: + | /** + * Trigger online scoring on any spans with a name in this list. Only applies when scope is 'span' or unset. + */ + /** + * Trigger online scoring on any spans with a name in this list. Only applies when scope is 'span' or unset. + */ + (| Array + /** + * Trigger online scoring on any spans with a name in this list. Only applies when scope is 'span' or unset. + */ + | null + ) + | undefined; + skip_logging?: + | /** + * Whether to skip adding scorer spans when computing scores + */ + /** + * Whether to skip adding scorer spans when computing scores + */ + (| boolean + /** + * Whether to skip adding scorer spans when computing scores + */ + | null + ) + | undefined; + scope?: + | /** + * The scope at which to run the functions. Defaults to span-level execution. + */ + (SpanScopeType | TraceScopeType | GroupScopeType | null) + | undefined; +} | null; +export type OrganizationType = { + /** + * Unique identifier for the organization + */ + id: string; + /** + * Name of the organization + */ + name: string; + api_url?: (string | null) | undefined; + is_universal_api?: (boolean | null) | undefined; + is_dataplane_private?: (boolean | null) | undefined; + proxy_url?: (string | null) | undefined; + realtime_url?: (string | null) | undefined; + created?: + | /** + * Date of organization creation + */ + /** + * Date of organization creation + */ + (| string + /** + * Date of organization creation + */ + | null + ) + | undefined; + image_rendering_mode?: ImageRenderingModeType | undefined; +}; +export type RetentionObjectTypeType = + /** + * The object type that the retention policy applies to + * + * @enum project_logs, experiment, dataset + */ + "project_logs" | "experiment" | "dataset"; +export type OrgAutomationType = { + /** + * Unique identifier for the project automation + */ + id: string; + /** + * Unique identifier for the organization that the org automation belongs under + */ + org_id: string; + user_id?: + | /** + * Identifies the user who created the project automation + */ + /** + * Identifies the user who created the project automation + */ + (| string + /** + * Identifies the user who created the project automation + */ + | null + ) + | undefined; + created?: + | /** + * Date of project automation creation + */ + /** + * Date of project automation creation + */ + (| string + /** + * Date of project automation creation + */ + | null + ) + | undefined; + /** + * Name of the project automation + */ + name: string; + description?: + | /** + * Textual description of the project automation + */ + /** + * Textual description of the project automation + */ + (| string + /** + * Textual description of the project automation + */ + | null + ) + | undefined; + /** + * The configuration for the org automation rule + */ + config: { + /** + * The type of automation. + * + * @enum retention + */ + event_type: "retention"; + object_type: RetentionObjectTypeType; + /** + * The number of days to retain the object + * + * @minimum 0 + */ + retention_days: number; + }; +}; +export type ProjectSettingsType = Partial<{ + /** + * The key used to join two experiments (defaults to `input`) + */ + comparison_key: /** + * The key used to join two experiments (defaults to `input`) + */ + | string + /** + * The key used to join two experiments (defaults to `input`) + */ + | null; + /** + * The id of the experiment to use as the default baseline for comparisons + */ + baseline_experiment_id: /** + * The id of the experiment to use as the default baseline for comparisons + */ + | string + /** + * The id of the experiment to use as the default baseline for comparisons + */ + | null; + /** + * The order of the fields to display in the trace view + */ + spanFieldOrder: /** + * The order of the fields to display in the trace view + */ + | Array<{ + object_type: string; + column_id: string; + position: string; + layout?: + | ( + | /** + * @enum full + */ + "full" + /** + * @enum two_column + */ + | "two_column" + | null + ) + | undefined; + }> + /** + * The order of the fields to display in the trace view + */ + | null; + /** + * The remote eval sources to use for the project + */ + remote_eval_sources: /** + * The remote eval sources to use for the project + */ + | Array<{ + url: string; + name?: (string | null) | undefined; + description?: (string | null) | undefined; + }> + /** + * The remote eval sources to use for the project + */ + | null; + /** + * If true, disable real-time queries for this project. This can improve query performance for high-volume logs. + */ + disable_realtime_queries: /** + * If true, disable real-time queries for this project. This can improve query performance for high-volume logs. + */ + | boolean + /** + * If true, disable real-time queries for this project. This can improve query performance for high-volume logs. + */ + | null; + /** + * If true, use metrics.start rather than created for monitor chart time bucket dimensions. + */ + monitor_charts_use_metrics_start: /** + * If true, use metrics.start rather than created for monitor chart time bucket dimensions. + */ + | boolean + /** + * If true, use metrics.start rather than created for monitor chart time bucket dimensions. + */ + | null; + default_preprocessor: NullableSavedFunctionIdType; +}> | null; +export type ProjectType = { + /** + * Unique identifier for the project + */ + id: string; + /** + * Unique id for the organization that the project belongs under + */ + org_id: string; + /** + * Name of the project + */ + name: string; + description?: + | /** + * Textual description of the project + */ + /** + * Textual description of the project + */ + (| string + /** + * Textual description of the project + */ + | null + ) + | undefined; + created?: + | /** + * Date of project creation + */ + /** + * Date of project creation + */ + (| string + /** + * Date of project creation + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of project deletion, or null if the project is still active + */ + /** + * Date of project deletion, or null if the project is still active + */ + (| string + /** + * Date of project deletion, or null if the project is still active + */ + | null + ) + | undefined; + user_id?: + | /** + * Identifies the user who created the project + */ + /** + * Identifies the user who created the project + */ + (| string + /** + * Identifies the user who created the project + */ + | null + ) + | undefined; + settings?: ProjectSettingsType | undefined; +}; +export type WindowedAutomationConfigType = { + /** + * The type of automation. + * + * @enum windowed + */ + event_type: "windowed"; + product_origin?: + | /** + * The product surface that created and manages the automation + * + * @enum patterns + */ + (| /** + * The product surface that created and manages the automation + * + * @enum patterns + */ + "patterns" + /** + * The product surface that created and manages the automation + * + * @enum patterns + */ + | null + ) + | undefined; + status?: AutomationStatusType | undefined; + threshold?: /** + * Optional calculation and lifecycle policy that gate scheduled delivery + */ + | { + /** + * The calculation evaluated for each window + */ + calculation: { + /** + * @enum btql + */ + type: "btql"; + /** + * A project-scoped BTQL or SQL query without runtime-owned evaluation time bounds + * + * @minLength 1 + */ + btql_query: string; + output: { + /** + * @enum scalar + */ + type: "scalar"; + /** + * The numeric result column produced by the query + * + * @minLength 1 + */ + value_column: string; + }; + }; + /** + * The lifecycle policy applied to each calculation result + */ + policy: { + condition: { + /** + * @enum threshold + */ + type: "threshold"; + /** + * @enum lt, lte, gt, gte, eq, neq + */ + operator: "lt" | "lte" | "gt" | "gte" | "eq" | "neq"; + threshold: number; + }; + /** + * How long the condition must remain breached before firing + * + * @minimum 0 + * @maximum 2592000 + */ + pending_seconds: number; + /** + * How the lifecycle changes when the calculation returns no data + * + * @enum keep_last, resolve, alert + */ + no_data_behavior: "keep_last" | "resolve" | "alert"; + renotify_interval_seconds?: + | /** + * Optional reminder interval while the automation is firing + * + * @minimum 1 + * @maximum 2592000 + */ + /** + * Optional reminder interval while the automation is firing + * + * @minimum 1 + * @maximum 2592000 + */ + (| number + /** + * Optional reminder interval while the automation is firing + * + * @minimum 1 + * @maximum 2592000 + */ + | null + ) + | undefined; + /** + * Whether to deliver actions when a firing automation recovers + * + * @default true + */ + notify_on_recovery: boolean; + }; + } + | undefined; + window: { + /** + * How much recent data each scheduled run covers + * + * @minimum 1 + * @maximum 2592000 + */ + window_seconds: number; + /** + * How often the windowed automation runs: at a fixed interval or on a cron schedule + */ + schedule: + | { + /** + * @enum interval + */ + type: "interval"; + /** + * How often the automation runs + * + * @minimum 1 + * @maximum 2592000 + */ + evaluation_interval_seconds: number; + } + | { + /** + * @enum cron + */ + type: "cron"; + /** + * A standard five-field cron expression (minute hour day-of-month month day-of-week) controlling when the automation runs + * + * @minLength 1 + */ + cron_expression: string; + timezone?: + | /** + * IANA timezone used to interpret the cron expression (defaults to UTC) + * + * @minLength 1 + */ + /** + * IANA timezone used to interpret the cron expression (defaults to UTC) + * + * @minLength 1 + */ + (| string + /** + * IANA timezone used to interpret the cron expression (defaults to UTC) + * + * @minLength 1 + */ + | null + ) + | undefined; + }; + /** + * How far behind the present each evaluation window ends + * + * @minimum 0 + * @maximum 2592000 + */ + evaluation_delay_seconds: number; + }; + loop?: /** + * Optional Loop agent to run for each triggered window + */ + | { + /** + * Instructions for the Loop agent + * + * @minLength 1 + * @maxLength 10000 + */ + prompt: string; + /** + * Whether to include the automation trigger payload as input + * + * @default false + */ + include_trigger_input: boolean; + /** + * The Loop agent to run + * + * @minLength 1 + */ + agent_slug: string; + /** + * Write tools that may run without interactive approval + * + * @default [] + */ + auto_approve_tools: Array; + harness?: + | /** + * @enum native, codex, claude-code + */ + ("native" | "codex" | "claude-code") + | undefined; + model?: /** + * @minLength 1 + */ + string | undefined; + reasoning_effort?: + | /** + * @enum none, minimal, low, medium, high, xhigh, max + */ + ("none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max") + | undefined; + } + | undefined; + /** + * Delivery actions exposed to Loop as tools, or run directly when Loop is not configured + * + * @default [] + */ + actions: Array< + /** + * A delivery action available to an automation + */ + | { + /** + * The type of action to take + * + * @enum webhook + */ + type: "webhook"; + /** + * The webhook URL to send the request to + */ + url: string; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + } + | { + /** + * The type of action to take + * + * @enum slack + */ + type: "slack"; + /** + * The Slack workspace ID to post to + */ + workspace_id: string; + /** + * The Slack channel ID to post to + */ + channel: string; + message_template?: /** + * Custom message template for the alert + */ + string | undefined; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + } + >; +}; +export type TopicAutomationFacetModelType = + /** + * Optional facet model override for topic automation + * + * @enum brain-facet-latest, brain-facet-1, brain-facet-2 + */ + | /** + * Optional facet model override for topic automation + * + * @enum brain-facet-latest, brain-facet-1, brain-facet-2 + */ + ("brain-facet-latest" | "brain-facet-1" | "brain-facet-2") + /** + * Optional facet model override for topic automation + * + * @enum brain-facet-latest, brain-facet-1, brain-facet-2 + */ + | null; +export type TopicMapFunctionAutomationType = { + function: SavedFunctionIdType & + /** + * Topic map function + */ unknown; + btql_filter?: + | /** + * Per-topic-map BTQL filter. For trace scope, a topic map runs when max(filter) over the trace is truthy. For span scope, it runs when the current span matches. + */ + /** + * Per-topic-map BTQL filter. For trace scope, a topic map runs when max(filter) over the trace is truthy. For span scope, it runs when the current span matches. + */ + (| string + /** + * Per-topic-map BTQL filter. For trace scope, a topic map runs when max(filter) over the trace is truthy. For span scope, it runs when the current span matches. + */ + | null + ) + | undefined; +}; +export type TopicAutomationDataScopeType = + /** + * Optional data scope for topic automation. + */ + | { + /** + * @enum project_logs + */ + type: "project_logs"; + } + | { + /** + * @enum project_experiments + */ + type: "project_experiments"; + } + | { + /** + * @enum experiment + */ + type: "experiment"; + experiment_id: string; + } + | null; +export type TopicAutomationConfigType = { + /** + * The type of automation. + * + * @enum topic + */ + event_type: "topic"; + status?: AutomationStatusType | undefined; + /** + * The sampling rate for topic automation + * + * @minimum 0 + * @maximum 1 + */ + sampling_rate: number; + facet_model?: TopicAutomationFacetModelType | undefined; + /** + * Facet functions used by the topic automation + */ + facet_functions: Array; + /** + * Topic map functions with optional per-topic-map filters + */ + topic_map_functions: Array; + scope?: + | /** + * Execution scope for topic automation. Defaults to span-level execution. + */ + (SpanScopeType | TraceScopeType | GroupScopeType | null) + | undefined; + data_scope?: TopicAutomationDataScopeType | undefined; + btql_filter?: + | /** + * Optional BTQL filter applied before topic automation. + */ + /** + * Optional BTQL filter applied before topic automation. + */ + (| string + /** + * Optional BTQL filter applied before topic automation. + */ + | null + ) + | undefined; + rerun_seconds?: + | /** + * How often to recompute topic maps + * + * @minimum 600 + */ + /** + * How often to recompute topic maps + * + * @minimum 600 + */ + (| number + /** + * How often to recompute topic maps + * + * @minimum 600 + */ + | null + ) + | undefined; + relabel_overlap_seconds?: + | /** + * How much recent history to relabel after a new topic map version becomes active + * + * @minimum 60 + */ + /** + * How much recent history to relabel after a new topic map version becomes active + * + * @minimum 60 + */ + (| number + /** + * How much recent history to relabel after a new topic map version becomes active + * + * @minimum 60 + */ + | null + ) + | undefined; + backfill_time_range?: + | /** + * Topic window used for classification coverage and initial backfill. + */ + (| string + | { + from: string; + to: string; + } + | null + ) + | undefined; +}; +export type TopicDigestAutomationConfigType = { + /** + * The type of automation. + * + * @enum topic_digest + */ + event_type: "topic_digest"; + status?: AutomationStatusType | undefined; + /** + * How much recent history to include in each digest + * + * @default 86400 + * @minimum 3600 + * @maximum 2592000 + */ + window_seconds: number; + /** + * Minutes after midnight UTC when the digest should be sent + * + * @minimum 0 + * @maximum 1439 + */ + scheduled_time_minutes_utc: number; + /** + * The Slack action to take when the digest is sent + */ + action: { + /** + * The type of action to take + * + * @enum slack + */ + type: "slack"; + /** + * The Slack workspace ID to post to + */ + workspace_id: string; + /** + * The Slack channel ID to post to + */ + channel: string; + message_template?: /** + * Custom message template for the alert + */ + string | undefined; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + }; + topic_map_function_ids?: /** + * Optional topic map function IDs to include in the digest + */ + Array | undefined; +}; +export type ProjectAutomationType = { + /** + * Unique identifier for the project automation + */ + id: string; + /** + * Unique identifier for the project that the project automation belongs under + */ + project_id: string; + user_id?: + | /** + * Identifies the user who created the project automation + */ + /** + * Identifies the user who created the project automation + */ + (| string + /** + * Identifies the user who created the project automation + */ + | null + ) + | undefined; + created?: + | /** + * Date of project automation creation + */ + /** + * Date of project automation creation + */ + (| string + /** + * Date of project automation creation + */ + | null + ) + | undefined; + /** + * Name of the project automation + */ + name: string; + description?: + | /** + * Textual description of the project automation + */ + /** + * Textual description of the project automation + */ + (| string + /** + * Textual description of the project automation + */ + | null + ) + | undefined; + /** + * The configuration for the automation rule + */ + config: + | { + /** + * The type of automation. + * + * @enum logs + */ + event_type: "logs"; + status?: AutomationStatusType | undefined; + /** + * BTQL filter to identify rows for the automation rule + */ + btql_filter: string; + /** + * Perform the triggered action at most once in this interval of seconds + * + * @minimum 1 + * @maximum 2592000 + */ + interval_seconds: number; + /** + * The action to take when the automation rule is triggered + */ + action: + | { + /** + * The type of action to take + * + * @enum webhook + */ + type: "webhook"; + /** + * The webhook URL to send the request to + */ + url: string; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + } + | { + /** + * The type of action to take + * + * @enum slack + */ + type: "slack"; + /** + * The Slack workspace ID to post to + */ + workspace_id: string; + /** + * The Slack channel ID to post to + */ + channel: string; + message_template?: /** + * Custom message template for the alert + */ + string | undefined; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + }; + } + | { + /** + * The type of automation. + * + * @enum btql_export + */ + event_type: "btql_export"; + status?: AutomationStatusType | undefined; + /** + * The definition of what to export + */ + export_definition: + | { + /** + * @enum log_traces + */ + type: "log_traces"; + } + | { + /** + * @enum log_spans + */ + type: "log_spans"; + } + | { + /** + * @enum btql_query + */ + type: "btql_query"; + /** + * The BTQL query to export + */ + btql_query: string; + }; + scope?: + | /** + * Execution scope for export automation. Defaults to span-level execution. + */ + (SpanScopeType | TraceScopeType | GroupScopeType | null) + | undefined; + /** + * The path to export the results to. It should include the storage protocol and prefix, e.g. s3://bucket-name/path/to/export + */ + export_path: string; + /** + * The format to export the results in + * + * @enum jsonl, parquet + */ + format: "jsonl" | "parquet"; + /** + * Perform the triggered action at most once in this interval of seconds + * + * @minimum 1 + * @maximum 2592000 + */ + interval_seconds: number; + credentials: + | { + /** + * @enum aws_iam + */ + type: "aws_iam"; + /** + * The ARN of the IAM role to use + */ + role_arn: string; + /** + * The automation-specific external id component (auto-generated by default) + */ + external_id: string; + } + | { + /** + * @enum gcp_service_account + */ + type: "gcp_service_account"; + /** + * The GCP service account email to impersonate + */ + service_account_email: string; + }; + batch_size?: + | /** + * The number of rows to export in each batch + */ + /** + * The number of rows to export in each batch + */ + (| number + /** + * The number of rows to export in each batch + */ + | null + ) + | undefined; + } + | { + /** + * The type of automation. + * + * @enum async_query + */ + event_type: "async_query"; + status?: AutomationStatusType | undefined; + /** + * The user who submitted the async query + */ + created_by_user_id: string; + /** + * The source object type for the async query + * + * @enum project_logs, experiment, dataset, playground_logs + */ + object_type: + | "project_logs" + | "experiment" + | "dataset" + | "playground_logs"; + /** + * The source object ID for the async query + */ + object_id: string; + /** + * The SQL query to execute asynchronously + */ + query: string; + /** + * The materialized result format + * + * @enum jsonl + */ + format: "jsonl"; + batch_size?: + | /** + * The maximum number of result rows to write per async query batch + * + * @maximum 100000 + */ + /** + * The maximum number of result rows to write per async query batch + * + * @maximum 100000 + */ + (| number + /** + * The maximum number of result rows to write per async query batch + * + * @maximum 100000 + */ + | null + ) + | undefined; + } + | { + /** + * The type of automation. + * + * @enum retention + */ + event_type: "retention"; + object_type: RetentionObjectTypeType; + /** + * The number of days to retain the object + * + * @minimum 0 + */ + retention_days: number; + } + | { + /** + * The type of automation. + * + * @enum environment_update + */ + event_type: "environment_update"; + status?: AutomationStatusType | undefined; + environment_filter?: /** + * Optional list of environment slugs to filter by + */ + Array | undefined; + /** + * The action to take when the automation rule is triggered + */ + action: + | { + /** + * The type of action to take + * + * @enum webhook + */ + type: "webhook"; + /** + * The webhook URL to send the request to + */ + url: string; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + } + | { + /** + * The type of action to take + * + * @enum slack + */ + type: "slack"; + /** + * The Slack workspace ID to post to + */ + workspace_id: string; + /** + * The Slack channel ID to post to + */ + channel: string; + message_template?: /** + * Custom message template for the alert + */ + string | undefined; + formatting_prompt?: /** + * Instructions for Loop to format content sent to this destination + * + * @minLength 1 + * @maxLength 10000 + */ + string | undefined; + }; + } + | WindowedAutomationConfigType + | TopicAutomationConfigType + | TopicDigestAutomationConfigType; +}; +export type ProjectGroupType = { + /** + * Unique identifier for the project group + */ + id: string; + /** + * Unique id for the organization that the project group belongs under + + It is forbidden to change the org after creating a project group + */ + org_id: string; + user_id?: + | /** + * Identifies the user who created the project group + */ + /** + * Identifies the user who created the project group + */ + (| string + /** + * Identifies the user who created the project group + */ + | null + ) + | undefined; + created?: + | /** + * Date of project group creation + */ + /** + * Date of project group creation + */ + (| string + /** + * Date of project group creation + */ + | null + ) + | undefined; + /** + * Name of the project group + */ + name: string; + description?: + | /** + * Textual description of the project group + */ + /** + * Textual description of the project group + */ + (| string + /** + * Textual description of the project group + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of project group deletion, or null if the project group is still active + */ + /** + * Date of project group deletion, or null if the project group is still active + */ + (| string + /** + * Date of project group deletion, or null if the project group is still active + */ + | null + ) + | undefined; + /** + * Sorted ids of active projects in this project group + */ + member_projects: Array; +}; +export type ProjectLogsEventType = { + /** + * A unique identifier for the project logs event. If you don't provide one, Braintrust will generate one for you + */ + id: string; + /** + * 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) + */ + _xact_id: string; + _pagination_key?: + | /** + * A stable, time-ordered key that can be used to paginate over project logs events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + /** + * A stable, time-ordered key that can be used to paginate over project logs events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + (| string + /** + * A stable, time-ordered key that can be used to paginate over project logs events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + | null + ) + | undefined; + /** + * The timestamp the project logs event was created + */ + created: string; + /** + * Unique id for the organization that the project belongs under + */ + org_id: string; + /** + * Unique identifier for the project + */ + project_id: string; + /** + * A literal 'g' which identifies the log as a project log + * + * @enum g + */ + log_id: "g"; + input?: /** + * The arguments that uniquely define a user input (an arbitrary, JSON serializable object). + */ + unknown | undefined; + 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 `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. + */ + unknown | undefined; + expected?: /** + * 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. + */ + unknown | undefined; + error?: /** + * The error that occurred, if any. + */ + unknown | undefined; + 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 logs. + */ + /** + * 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. + */ + (| {} + /** + * 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. + */ + | null + ) + | undefined; + 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'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 + */ + /** + * 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 + */ + (| Partial< + { + /** + * The model used for this example + */ + model: /** + * The model used for this example + */ + | string + /** + * The model used for this example + */ + | null; + } & { + [key: string]: any; + } + > + /** + * 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 + */ + | null + ) + | undefined; + tags?: + | /** + * A list of tags to log + */ + /** + * A list of tags to log + */ + (| Array + /** + * A list of tags to log + */ + | null + ) + | undefined; + metrics?: + | /** + * 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 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 + */ + ({} & { + [key: string]: number; + }) + /** + * 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 + */ + | null + ) + | undefined; + context?: + | /** + * 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 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 + */ + (| Partial< + { + /** + * The function in code which created the project logs event + */ + caller_functionname: /** + * The function in code which created the project logs event + */ + | string + /** + * The function in code which created the project logs event + */ + | null; + /** + * Name of the file in code where the project logs event was created + */ + caller_filename: /** + * Name of the file in code where the project logs event was created + */ + | string + /** + * Name of the file in code where the project logs event was created + */ + | null; + /** + * Line of code where the project logs event was created + */ + caller_lineno: /** + * Line of code where the project logs event was created + */ + | number + /** + * Line of code where the project logs event was created + */ + | null; + } & { + [key: string]: any; + } + > + /** + * 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 + */ + | null + ) + | undefined; + /** + * A unique identifier used to link different project logs events together as part of a full trace. See the [tracing guide](https://www.braintrust.dev/docs/instrument) for full details on tracing + */ + span_id: string; + span_parents?: + | /** + * 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 + */ + /** + * 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 + */ + (| Array + /** + * 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 + */ + | null + ) + | undefined; + /** + * A unique identifier for the trace this project logs event belongs to + */ + root_span_id: string; + is_root?: + | /** + * Whether this span is a root span + */ + /** + * Whether this span is a root span + */ + (| boolean + /** + * Whether this span is a root span + */ + | null + ) + | undefined; + span_attributes?: SpanAttributesType | undefined; + origin?: ObjectReferenceNullishType | undefined; + comments?: + | /** + * Optional list of comments attached to this event + */ + /** + * Optional list of comments attached to this event + */ + (| Array + /** + * Optional list of comments attached to this event + */ + | null + ) + | undefined; + audit_data?: + | /** + * Optional list of audit entries attached to this event + */ + /** + * Optional list of audit entries attached to this event + */ + (| Array + /** + * Optional list of audit entries attached to this event + */ + | null + ) + | undefined; + _async_scoring_state?: /** + * The async scoring state for this event + */ + unknown | undefined; + facets?: + | /** + * Facets for categorization (dictionary from facet id to value) + */ + /** + * Facets for categorization (dictionary from facet id to value) + */ + (| {} + /** + * Facets for categorization (dictionary from facet id to value) + */ + | null + ) + | undefined; + classifications?: + | /** + * Classifications for this event (dictionary from classification name to items) + */ + /** + * Classifications for this event (dictionary from classification name to items) + */ + (| {} + /** + * Classifications for this event (dictionary from classification name to items) + */ + | null + ) + | undefined; +}; +export type ProjectScoreTypeType = + /** + * The type of the configured score + * + * @enum slider, categorical, weighted, minimum, maximum, online, free-form + */ + | "slider" + | "categorical" + | "weighted" + | "minimum" + | "maximum" + | "online" + | "free-form"; +export type ProjectScoreCategoryType = { + /** + * Name of the category + */ + name: string; + /** + * Numerical value of the category. Must be between 0 and 1, inclusive + */ + value: number; +}; +export type ProjectScoreCategoriesType = + /** + * For categorical-type project scores, the list of all categories + */ + | Array + /** + * For weighted-type project scores, the weights of each score + */ + | {} + /** + * For minimum-type project scores, the list of included scores + */ + | Array + | null; +export type ProjectScoreConditionType = { + when: Partial<{ + clauses: Array | null; + subspan_clauses: Array | null; + trace_clauses: Array | null; + }>; + /** + * @default "hidden" + * @enum hidden + */ + behavior: "hidden"; +} | null; +export type ProjectScoreConfigType = Partial<{ + multi_select: boolean | null; + destination: string | null; + visibility: Partial<{ + users: Array | null; + groups: Array | null; + }> | null; + online: OnlineScoreConfigType; + condition: ProjectScoreConditionType; + object_types: Array< + /** + * @enum project_logs, dataset, experiment + */ + "project_logs" | "dataset" | "experiment" + > | null; +}> | null; +export type ProjectScoreType = { + /** + * Unique identifier for the project score + */ + id: string; + /** + * Unique identifier for the project that the project score belongs under + */ + project_id: string; + user_id: string; + created?: + | /** + * Date of project score creation + */ + /** + * Date of project score creation + */ + (| string + /** + * Date of project score creation + */ + | null + ) + | undefined; + /** + * Name of the project score + */ + name: string; + description?: + | /** + * Textual description of the project score + */ + /** + * Textual description of the project score + */ + (| string + /** + * Textual description of the project score + */ + | null + ) + | undefined; + score_type: ProjectScoreTypeType; + categories?: ProjectScoreCategoriesType | undefined; + config?: ProjectScoreConfigType | undefined; + position?: + | /** + * An optional LexoRank-based string that sets the sort position for the score in the UI + */ + /** + * An optional LexoRank-based string that sets the sort position for the score in the UI + */ + (| string + /** + * An optional LexoRank-based string that sets the sort position for the score in the UI + */ + | null + ) + | undefined; +}; +export type ProjectTagType = { + /** + * Unique identifier for the project tag + */ + id: string; + /** + * Unique identifier for the project that the project tag belongs under + */ + project_id: string; + user_id: string; + created?: + | /** + * Date of project tag creation + */ + /** + * Date of project tag creation + */ + (| string + /** + * Date of project tag creation + */ + | null + ) + | undefined; + /** + * Name of the project tag + */ + name: string; + description?: + | /** + * Textual description of the project tag + */ + /** + * Textual description of the project tag + */ + (| string + /** + * Textual description of the project tag + */ + | null + ) + | undefined; + color?: + | /** + * Color of the tag for the UI + */ + /** + * Color of the tag for the UI + */ + (| string + /** + * Color of the tag for the UI + */ + | null + ) + | undefined; + position?: + | /** + * An optional LexoRank-based string that sets the sort position for the tag in the UI + */ + /** + * An optional LexoRank-based string that sets the sort position for the tag in the UI + */ + (| string + /** + * An optional LexoRank-based string that sets the sort position for the tag in the UI + */ + | null + ) + | undefined; +}; +export type PromptType = { + /** + * Unique identifier for the prompt + */ + id: string; + /** + * 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 prompt (see the `version` parameter) + */ + _xact_id: string; + /** + * Unique identifier for the project that the prompt belongs under + */ + project_id: string; + /** + * A literal 'p' which identifies the object as a project prompt + * + * @enum p + */ + log_id: "p"; + /** + * Unique identifier for the organization + */ + org_id: string; + /** + * Name of the prompt + */ + name: string; + /** + * Unique identifier for the prompt + */ + slug: string; + description?: + | /** + * Textual description of the prompt + */ + /** + * Textual description of the prompt + */ + (| string + /** + * Textual description of the prompt + */ + | null + ) + | undefined; + created?: + | /** + * Date of prompt creation + */ + /** + * Date of prompt creation + */ + (| string + /** + * Date of prompt creation + */ + | null + ) + | undefined; + prompt_data?: PromptDataNullishType | undefined; + tags?: + | /** + * A list of tags for the prompt + */ + /** + * A list of tags for the prompt + */ + (| Array + /** + * A list of tags for the prompt + */ + | null + ) + | undefined; + metadata?: + | /** + * User-controlled metadata about the prompt + */ + /** + * User-controlled metadata about the prompt + */ + (| {} + /** + * User-controlled metadata about the prompt + */ + | null + ) + | undefined; + function_type?: FunctionTypeEnumNullishType | undefined; +}; +export type PromptOptionsType = Partial<{ + model: string; + params: ModelParamsType; + position: string; + endpoint_name: string | null; +}>; +export type PromptSessionEventType = { + /** + * A unique identifier for the prompt session event. If you don't provide one, Braintrust will generate one for you + */ + id: string; + /** + * 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 prompt session (see the `version` parameter) + */ + _xact_id: string; + /** + * The timestamp the prompt session event was created + */ + created: string; + _pagination_key?: + | /** + * A stable, time-ordered key that can be used to paginate over prompt session events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + /** + * A stable, time-ordered key that can be used to paginate over prompt session events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + (| string + /** + * A stable, time-ordered key that can be used to paginate over prompt session events. This field is auto-generated by Braintrust and only exists in Brainstore. + */ + | null + ) + | undefined; + /** + * Unique identifier for the project that the prompt belongs under + */ + project_id: string; + /** + * Unique identifier for the prompt + */ + prompt_session_id: string; + prompt_session_data?: /** + * Data about the prompt session + */ + unknown | undefined; + prompt_data?: /** + * Data about the prompt + */ + unknown | undefined; + function_data?: /** + * Data about the function + */ + unknown | undefined; + function_type?: FunctionTypeEnumNullishType | undefined; + object_data?: /** + * Data about the mapped data + */ + unknown | undefined; + completion?: /** + * Data about the completion + */ + unknown | undefined; + tags?: + | /** + * A list of tags to log + */ + /** + * A list of tags to log + */ + (| Array + /** + * A list of tags to log + */ + | null + ) + | undefined; +}; +export type ResponseFormatType = + | { + /** + * @enum json_object + */ + type: "json_object"; + } + | { + /** + * @enum json_schema + */ + type: "json_schema"; + json_schema: ResponseFormatJsonSchemaType; + } + | { + /** + * @enum text + */ + type: "text"; + }; +export type RoleType = { + /** + * Unique identifier for the role + */ + id: string; + org_id?: + | /** + * Unique id for the organization that the role belongs under + + A null org_id indicates a system role, which may be assigned to anybody and inherited by any other role, but cannot be edited. + + It is forbidden to change the org after creating a role + */ + /** + * Unique id for the organization that the role belongs under + + A null org_id indicates a system role, which may be assigned to anybody and inherited by any other role, but cannot be edited. + + It is forbidden to change the org after creating a role + */ + (| string /** + * Unique id for the organization that the role belongs under + + A null org_id indicates a system role, which may be assigned to anybody and inherited by any other role, but cannot be edited. + + It is forbidden to change the org after creating a role + */ + | null + ) + | undefined; + user_id?: + | /** + * Identifies the user who created the role + */ + /** + * Identifies the user who created the role + */ + (| string + /** + * Identifies the user who created the role + */ + | null + ) + | undefined; + created?: + | /** + * Date of role creation + */ + /** + * Date of role creation + */ + (| string + /** + * Date of role creation + */ + | null + ) + | undefined; + /** + * Name of the role + */ + name: string; + description?: + | /** + * Textual description of the role + */ + /** + * Textual description of the role + */ + (| string + /** + * Textual description of the role + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of role deletion, or null if the role is still active + */ + /** + * Date of role deletion, or null if the role is still active + */ + (| string + /** + * Date of role deletion, or null if the role is still active + */ + | null + ) + | undefined; + member_permissions?: + | /** + * (permission, restrict_object_type) tuples which belong to this role + */ + /** + * (permission, restrict_object_type) tuples which belong to this role + */ + (| Array<{ + permission: PermissionType; + restrict_object_type?: AclObjectTypeType | undefined; + }> + /** + * (permission, restrict_object_type) tuples which belong to this role + */ + | null + ) + | undefined; + member_roles?: + | /** + * Ids of the roles this role inherits from + + An inheriting role has all the permissions contained in its member roles, as well as all of their inherited permissions + */ + /** + * Ids of the roles this role inherits from + + An inheriting role has all the permissions contained in its member roles, as well as all of their inherited permissions + */ + (| Array /** + * Ids of the roles this role inherits from + + An inheriting role has all the permissions contained in its member roles, as well as all of their inherited permissions + */ + | null + ) + | undefined; +}; +export type RunEvalType = { + /** + * Unique identifier for the project to run the eval in + */ + project_id: string; + /** + * The dataset to use + */ + data: /** + * Dataset id + */ + | { + dataset_id: string; + dataset_version?: + | /** + * The version of the dataset to evaluate + */ + /** + * The version of the dataset to evaluate + */ + (| string + /** + * The version of the dataset to evaluate + */ + | null + ) + | undefined; + dataset_environment?: + | /** + * The environment tag that resolves to the dataset version to evaluate + */ + /** + * The environment tag that resolves to the dataset version to evaluate + */ + (| string + /** + * The environment tag that resolves to the dataset version to evaluate + */ + | null + ) + | undefined; + _internal_btql?: ({} | null) | undefined; + } + /** + * Project and dataset name + */ + | { + project_name: string; + dataset_name: string; + dataset_version?: + | /** + * The version of the dataset to evaluate + */ + /** + * The version of the dataset to evaluate + */ + (| string + /** + * The version of the dataset to evaluate + */ + | null + ) + | undefined; + dataset_environment?: + | /** + * The environment tag that resolves to the dataset version to evaluate + */ + /** + * The environment tag that resolves to the dataset version to evaluate + */ + (| string + /** + * The environment tag that resolves to the dataset version to evaluate + */ + | null + ) + | undefined; + _internal_btql?: ({} | null) | undefined; + } + /** + * Dataset rows + */ + | { + data: Array; + }; + name?: /** + * The name of the eval to run when multiple evals available + */ + string | undefined; + parameters?: /** + * Values for any parameters used in the eval + */ + {} | undefined; + task: FunctionIdType & + /** + * The function to evaluate + */ unknown; + /** + * The functions to score the eval on + */ + scores: Array; + experiment_name?: /** + * An optional name for the experiment created by this eval. If it conflicts with an existing experiment, it will be suffixed with a unique identifier. + */ + string | undefined; + metadata?: /** + * Optional experiment-level metadata to store about the evaluation. You can later use this to slice & dice across experiments. + */ + {} | undefined; + parent?: + | (InvokeParentType & + /** + * Options for tracing the evaluation + */ unknown) + | undefined; + stream?: /** + * Whether to stream the results of the eval. If true, the request will return two events: one to indicate the experiment has started, and another upon completion. If false, the request will return the evaluation's summary upon completion. + */ + boolean | undefined; + trial_count?: + | /** + * The number of times to run the evaluator per input. This is useful for evaluating applications that have non-deterministic behavior and gives you both a stronger aggregate measure and a sense of the variance in the results. + */ + /** + * The number of times to run the evaluator per input. This is useful for evaluating applications that have non-deterministic behavior and gives you both a stronger aggregate measure and a sense of the variance in the results. + */ + (| number + /** + * The number of times to run the evaluator per input. This is useful for evaluating applications that have non-deterministic behavior and gives you both a stronger aggregate measure and a sense of the variance in the results. + */ + | null + ) + | undefined; + is_public?: + | /** + * Whether the experiment should be public. Defaults to false. + */ + /** + * Whether the experiment should be public. Defaults to false. + */ + (| boolean + /** + * Whether the experiment should be public. Defaults to false. + */ + | null + ) + | undefined; + timeout?: + | /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which case there is no timeout. + */ + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which case there is no timeout. + */ + (| number + /** + * The maximum duration, in milliseconds, to run the evaluation. Defaults to undefined, in which case there is no timeout. + */ + | null + ) + | undefined; + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to 10. If null is provided, no max concurrency will be used. + * + * @default 10 + */ + max_concurrency: /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to 10. If null is provided, no max concurrency will be used. + * + * @default 10 + */ + | number + /** + * The maximum number of tasks/scorers that will be run concurrently. Defaults to 10. If null is provided, no max concurrency will be used. + * + * @default 10 + */ + | null; + base_experiment_name?: + | /** + * An optional experiment name to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + /** + * An optional experiment name to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + (| string + /** + * An optional experiment name to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + | null + ) + | undefined; + base_experiment_id?: + | /** + * An optional experiment id to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + /** + * An optional experiment id to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + (| string + /** + * An optional experiment id to use as a base. If specified, the new experiment will be summarized and compared to this experiment. + */ + | null + ) + | undefined; + git_metadata_settings?: + | (GitMetadataSettingsType & + /** + * Optional settings for collecting git metadata. By default, will collect git metadata fields allowed in org-level settings, excluding diff content unless the org opts in. + */ /** + * Optional settings for collecting git metadata. By default, will collect git metadata fields allowed in org-level settings, excluding diff content unless the org opts in. + */ + (| {} + /** + * Optional settings for collecting git metadata. By default, will collect git metadata fields allowed in org-level settings, excluding diff content unless the org opts in. + */ + | null + )) + | undefined; + repo_info?: + | (RepoInfoType & + /** + * Optionally explicitly specify the git metadata for this experiment. This takes precedence over `gitMetadataSettings` if specified. + */ unknown) + | undefined; + strict?: + | /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + (| boolean + /** + * If true, throw an error if one of the variables in the prompt is not present in the input + */ + | null + ) + | undefined; + stop_token?: + | /** + * The token to stop the run + */ + /** + * The token to stop the run + */ + (| string + /** + * The token to stop the run + */ + | null + ) + | undefined; + extra_messages?: /** + * A template path of extra messages to append to the conversion. These messages will be appended to the end of the conversation, after the last message. + */ + string | undefined; + tags?: /** + * Optional tags that will be added to the experiment. + */ + Array | undefined; + mcp_auth?: {} | undefined; + endpoint_name?: + | /** + * Name of the AI provider secret to pin this run to. + */ + /** + * Name of the AI provider secret to pin this run to. + */ + (| string + /** + * Name of the AI provider secret to pin this run to. + */ + | null + ) + | undefined; +}; +export type ServiceTokenType = { + /** + * Unique identifier for the service token + */ + id: string; + created?: + | /** + * Date of service token creation + */ + /** + * Date of service token creation + */ + (| string + /** + * Date of service token creation + */ + | null + ) + | undefined; + /** + * Name of the service token + */ + name: string; + preview_name: string; + service_account_id?: + | /** + * Unique identifier for the service token + */ + /** + * Unique identifier for the service token + */ + (| string + /** + * Unique identifier for the service token + */ + | null + ) + | undefined; + service_account_email?: + | /** + * The service account email (not routable) + */ + /** + * The service account email (not routable) + */ + (| string + /** + * The service account email (not routable) + */ + | null + ) + | undefined; + service_account_name?: + | /** + * The service account name + */ + /** + * The service account name + */ + (| string + /** + * The service account name + */ + | null + ) + | undefined; + org_id?: + | /** + * Unique identifier for the organization + */ + /** + * Unique identifier for the organization + */ + (| string + /** + * Unique identifier for the organization + */ + | null + ) + | undefined; + expires_at?: + | /** + * Date and time at which the service token expires. If null, the token never expires. + */ + /** + * Date and time at which the service token expires. If null, the token never expires. + */ + (| string + /** + * Date and time at which the service token expires. If null, the token never expires. + */ + | null + ) + | undefined; +}; +export type SpanIFrameType = { + /** + * Unique identifier for the span iframe + */ + id: string; + /** + * Unique identifier for the project that the span iframe belongs under + */ + project_id: string; + user_id?: + | /** + * Identifies the user who created the span iframe + */ + /** + * Identifies the user who created the span iframe + */ + (| string + /** + * Identifies the user who created the span iframe + */ + | null + ) + | undefined; + created?: + | /** + * Date of span iframe creation + */ + /** + * Date of span iframe creation + */ + (| string + /** + * Date of span iframe creation + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of span iframe deletion, or null if the span iframe is still active + */ + /** + * Date of span iframe deletion, or null if the span iframe is still active + */ + (| string + /** + * Date of span iframe deletion, or null if the span iframe is still active + */ + | null + ) + | undefined; + /** + * Name of the span iframe + */ + name: string; + description?: + | /** + * Textual description of the span iframe + */ + /** + * Textual description of the span iframe + */ + (| string + /** + * Textual description of the span iframe + */ + | null + ) + | undefined; + /** + * URL to embed the project viewer in an iframe + */ + url: string; + post_message?: + | /** + * Whether to post messages to the iframe containing the span's data. This is useful when you want to render more data than fits in the URL. + */ + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you want to render more data than fits in the URL. + */ + (| boolean + /** + * Whether to post messages to the iframe containing the span's data. This is useful when you want to render more data than fits in the URL. + */ + | null + ) + | undefined; +}; +export type SSEConsoleEventDataType = { + /** + * @enum stderr, stdout + */ + stream: "stderr" | "stdout"; + message: string; +}; +export type SSEProgressEventDataType = { + /** + * The id of the span this event is for + */ + id: string; + object_type: FunctionObjectTypeType; + origin?: + | (ObjectReferenceNullishType & + /** + * The origin of the event + */ unknown) + | undefined; + format: FunctionFormatType; + output_type: FunctionOutputTypeType; + name: string; + /** + * @enum reasoning_delta, text_delta, json_delta, error, console, start, done, progress + */ + event: + | "reasoning_delta" + | "text_delta" + | "json_delta" + | "error" + | "console" + | "start" + | "done" + | "progress"; + data: string; +}; +export type ToolFunctionDefinitionType = { + /** + * @enum function + */ + type: "function"; + function: { + name: string; + description?: string | undefined; + parameters?: {} | undefined; + strict?: (boolean | null) | undefined; + }; +}; +export type UserType = { + /** + * Unique identifier for the user + */ + id: string; + given_name?: + | /** + * Given name of the user + */ + /** + * Given name of the user + */ + (| string + /** + * Given name of the user + */ + | null + ) + | undefined; + family_name?: + | /** + * Family name of the user + */ + /** + * Family name of the user + */ + (| string + /** + * Family name of the user + */ + | null + ) + | undefined; + email?: + | /** + * The user's email + */ + /** + * The user's email + */ + (| string + /** + * The user's email + */ + | null + ) + | undefined; + avatar_url?: + | /** + * URL of the user's Avatar image + */ + /** + * URL of the user's Avatar image + */ + (| string + /** + * URL of the user's Avatar image + */ + | null + ) + | undefined; + created?: + | /** + * Date of user creation + */ + /** + * Date of user creation + */ + (| string + /** + * Date of user creation + */ + | null + ) + | undefined; +}; +export type ViewDataSearchType = Partial<{ + filter: Array | null; + tag: Array | null; + match: Array | null; + sort: Array | null; +}> | null; +export type ViewDataType = + /** + * The view definition + */ + /** + * The view definition + */ + | Partial<{ + search: ViewDataSearchType; + custom_charts: unknown; + }> + /** + * The view definition + */ + | null; +export type ViewOptionsType = + /** + * Options for the view in the app + */ + | { + /** + * @enum monitor + */ + viewType: "monitor"; + options: Partial<{ + /** + * @enum range, frame + */ + spanType: + | /** + * @enum range, frame + */ + ("range" | "frame") + /** + * @enum range, frame + */ + | null; + rangeValue: string | null; + frameStart: string | null; + frameEnd: string | null; + tzUTC: boolean | null; + chartVisibility: {} | null; + projectId: string | null; + /** + * @enum project, experiment + */ + type: + | /** + * @enum project, experiment + */ + ("project" | "experiment") + /** + * @enum project, experiment + */ + | null; + groupBy: string | null; + }>; + freezeColumns?: (boolean | null) | undefined; + } + | Partial<{ + columnVisibility: {} | null; + columnOrder: Array | null; + columnSizing: {} | null; + grouping: string | null; + rowHeight: string | null; + tallGroupRows: boolean | null; + layout: string | null; + topicMapReportKey: string | null; + chartHeight: number | null; + excludedMeasures: Array<{ + /** + * @enum none, score, metric, metadata + */ + type: "none" | "score" | "metric" | "metadata"; + value: string; + }> | null; + yMetric: { + /** + * @enum none, score, metric, metadata + */ + type: "none" | "score" | "metric" | "metadata"; + value: string; + } | null; + xAxis: { + /** + * @enum none, score, metric, metadata + */ + type: "none" | "score" | "metric" | "metadata"; + value: string; + } | null; + symbolGrouping: { + /** + * @enum none, score, metric, metadata + */ + type: "none" | "score" | "metric" | "metadata"; + value: string; + } | null; + pointSizeMetric: { + /** + * @enum none, score, metric, metadata + */ + type: "none" | "score" | "metric" | "metadata"; + value: string; + } | null; + /** + * One of 'avg', 'sum', 'min', 'max', 'median', 'all' + */ + xAxisAggregation: /** + * One of 'avg', 'sum', 'min', 'max', 'median', 'all' + */ + | string + /** + * One of 'avg', 'sum', 'min', 'max', 'median', 'all' + */ + | null; + chartAnnotations: Array<{ + id: string; + text: string; + }> | null; + timeRangeFilter: + | string + | { + from: string; + to: string; + } + | null; + /** + * @enum traces, spans, topics + */ + queryShape: + | /** + * @enum traces, spans, topics + */ + ("traces" | "spans" | "topics") + /** + * @enum traces, spans, topics + */ + | null; + cluster: string | null; + freezeColumns: boolean | null; + }> + | null; +export type ViewType = { + /** + * Unique identifier for the view + */ + id: string; + object_type: AclObjectTypeType & string; + /** + * The id of the object the view applies to + */ + object_id: string; + /** + * Type of object that the view corresponds to. + * + * @enum projects, experiments, experiment, playgrounds, playground, datasets, dataset, prompts, parameters, tools, scorers, classifiers, logs, monitor, for_review_project_log, for_review_experiments, for_review_datasets + */ + view_type: + | "projects" + | "experiments" + | "experiment" + | "playgrounds" + | "playground" + | "datasets" + | "dataset" + | "prompts" + | "parameters" + | "tools" + | "scorers" + | "classifiers" + | "logs" + | "monitor" + | "for_review_project_log" + | "for_review_experiments" + | "for_review_datasets"; + /** + * Name of the view + */ + name: string; + description?: + | /** + * Textual description of the view + */ + /** + * Textual description of the view + */ + (| string + /** + * Textual description of the view + */ + | null + ) + | undefined; + created?: + | /** + * Date of view creation + */ + /** + * Date of view creation + */ + (| string + /** + * Date of view creation + */ + | null + ) + | undefined; + updated_at?: + | /** + * Date of last view update + */ + /** + * Date of last view update + */ + (| string + /** + * Date of last view update + */ + | null + ) + | undefined; + view_data?: ViewDataType | undefined; + options?: ViewOptionsType | undefined; + user_id?: + | /** + * Identifies the user who created the view + */ + /** + * Identifies the user who created the view + */ + (| string + /** + * Identifies the user who created the view + */ + | null + ) + | undefined; + deleted_at?: + | /** + * Date of role deletion, or null if the role is still active + */ + /** + * Date of role deletion, or null if the role is still active + */ + (| string + /** + * Date of role deletion, or null if the role is still active + */ + | null + ) + | undefined; +}; diff --git a/js/util/generated_types.ts b/js/util/generated_types.ts index e24a44951..fd807dcc5 100644 --- a/js/util/generated_types.ts +++ b/js/util/generated_types.ts @@ -1,4 +1,4 @@ -// Auto-generated file (internal git SHA 10d02c4e14f09ae288e6bd5af3cebe98cf1dbf83) -- do not modify +// Auto-generated file (content hash 776b6c295e852681) -- do not modify import { z } from "zod/v3"; @@ -15,6 +15,8 @@ export const AclObjectType = z.union([ "org_member", "project_log", "org_project", + "org_audit_logs", + "project_group", ]), z.null(), ]); @@ -43,16 +45,32 @@ export const Acl = z.object({ created: z.union([z.string(), z.null()]).optional(), }); export type AclType = z.infer; +export const Agent = z.object({ + id: z.string().uuid(), + project_id: z.string().uuid(), + user_id: z.string().uuid(), + created: z.union([z.string(), z.null()]).optional(), + name: z.string(), + slug: z.string(), + kind: z.string(), + description: z.union([z.string(), z.null()]).optional(), + metadata: z + .union([z.object({}).partial().passthrough(), z.null()]) + .optional(), +}); +export type AgentType = z.infer; export const AISecret = z.object({ id: z.string().uuid(), created: z.union([z.string(), z.null()]).optional(), updated_at: z.union([z.string(), z.null()]).optional(), + secret_updated_at: z.union([z.string(), z.null()]).optional(), org_id: z.string().uuid(), name: z.string(), type: z.union([z.string(), z.null()]).optional(), metadata: z .union([z.object({}).partial().passthrough(), z.null()]) .optional(), + secret_updated_by_user_id: z.union([z.string(), z.null()]).optional(), preview_secret: z.union([z.string(), z.null()]).optional(), }); export type AISecretType = z.infer; @@ -105,10 +123,14 @@ export const AnyModelParams = z.object({ .optional(), n: z.number().optional(), stop: z.array(z.string()).optional(), - reasoning_effort: z.enum(["minimal", "low", "medium", "high"]).optional(), + reasoning_effort: z + .enum(["none", "minimal", "low", "medium", "high"]) + .optional(), verbosity: z.enum(["low", "medium", "high"]).optional(), top_k: z.number().optional(), stop_sequences: z.array(z.string()).optional(), + reasoning_enabled: z.boolean().optional(), + reasoning_budget: z.number().optional(), max_tokens_to_sample: z.number().optional(), maxOutputTokens: z.number().optional(), topP: z.number().optional(), @@ -126,14 +148,33 @@ export const ApiKey = z.object({ user_given_name: z.union([z.string(), z.null()]).optional(), user_family_name: z.union([z.string(), z.null()]).optional(), org_id: z.union([z.string(), z.null()]).optional(), + expires_at: z.union([z.string(), z.null()]).optional(), }); export type ApiKeyType = z.infer; +export const TriggeredFunctionState = z.object({ + triggered_xact_id: z.string(), + completed_xact_id: z.union([z.string(), z.null()]).optional(), + idempotency_key: z.union([z.string(), z.null()]).optional(), + attempts: z.number().int().gte(0).optional().default(0), + scope: z.union([ + z.object({ type: z.literal("span") }), + z.object({ type: z.literal("trace") }), + z.object({ type: z.literal("group"), key: z.string(), value: z.string() }), + ]), +}); +export type TriggeredFunctionStateType = z.infer; export const AsyncScoringState = z.union([ z.object({ status: z.literal("enabled"), token: z.string(), - function_ids: z.array(z.unknown()).min(1), + function_ids: z.array(z.unknown()), skip_logging: z.union([z.boolean(), z.null()]).optional(), + triggered_functions: z + .union([z.record(TriggeredFunctionState), z.null()]) + .optional(), + last_triggered_xact_id: z + .union([z.string(), z.number(), z.null()]) + .optional(), }), z.object({ status: z.literal("disabled") }), z.null(), @@ -141,22 +182,34 @@ export const AsyncScoringState = z.union([ ]); export type AsyncScoringStateType = z.infer; export const AsyncScoringControl = z.union([ - z.object({ - kind: z.literal("score_update"), - token: z.string().optional(), - }), + z.object({ kind: z.literal("score_update"), token: z.string().optional() }), z.object({ kind: z.literal("state_override"), state: AsyncScoringState }), z.object({ kind: z.literal("state_force_reselect") }), z.object({ kind: z.literal("state_enabled_force_rescore") }), z.object({ - kind: z.literal("add_triggered_functions"), - triggered_function_ids: z.array(z.unknown()).min(1), + kind: z.literal("trigger_functions"), + triggered_functions: z + .array( + z.object({ + function_id: z.unknown().optional(), + scope: z.union([ + z.object({ type: z.literal("span") }), + z.object({ type: z.literal("trace") }), + ]), + idempotency_key: z.string().optional(), + }), + ) + .min(1), }), z.object({ kind: z.literal("complete_triggered_functions"), function_ids: z.array(z.unknown()).min(1), triggered_xact_id: z.string(), }), + z.object({ + kind: z.literal("mark_attempt_failed"), + function_ids: z.array(z.unknown()).min(1), + }), ]); export type AsyncScoringControlType = z.infer; export const BraintrustAttachmentReference = z.object({ @@ -189,8 +242,96 @@ export const AttachmentStatus = z.object({ error_message: z.string().optional(), }); export type AttachmentStatusType = z.infer; +export const AutomationStatus = z.enum(["active", "paused"]); +export type AutomationStatusType = z.infer; +export const FunctionTypeEnum = z.enum([ + "llm", + "scorer", + "task", + "tool", + "custom_view", + "preprocessor", + "facet", + "classifier", + "tag", + "parameters", + "sandbox", +]); +export type FunctionTypeEnumType = z.infer; +export const FacetPreprocessorId = z.union([ + z.object({ + type: z.literal("function"), + id: z.string(), + version: z.string().optional(), + }), + z.object({ + type: z.literal("global"), + name: z.string(), + function_type: FunctionTypeEnum.optional().default("scorer"), + }), + z.object({ type: z.literal("inline"), code: z.string().min(1) }), + z.null(), +]); +export type FacetPreprocessorIdType = z.infer; +export const TopicMapGenerationSettings = z.object({ + algorithm: z.enum(["hdbscan", "kmeans", "community"]), + dimension_reduction: z.enum(["umap", "pca", "none"]), + sample_size: z.number().int().gt(0).optional(), + n_clusters: z.number().int().gt(0).optional(), + min_cluster_size: z.number().int().gt(0).optional(), + min_samples: z.number().int().gt(0).optional(), + hierarchy_threshold: z.number().int().gt(0).optional(), + naming_model: z.string().optional(), +}); +export type TopicMapGenerationSettingsType = z.infer< + typeof TopicMapGenerationSettings +>; +export const TopicMapData = z.object({ + type: z.literal("topic_map"), + source_facet: z.string(), + embedding_model: z.string(), + bundle_key: z.string().optional(), + report_key: z.string().optional(), + topic_names: z.record(z.string()).optional(), + generation_settings: TopicMapGenerationSettings.optional(), + disable_reconciliation: z.boolean().optional(), + reconcile_mode: z.enum(["evolve", "names_only"]).optional(), + distance_threshold: z.number().optional(), + btql_filter: z.string().optional(), + automation_btql_filter: z.string().optional(), +}); +export type TopicMapDataType = z.infer; +export const BatchedFacetData = z.object({ + type: z.literal("batched_facet"), + preprocessor: FacetPreprocessorId.optional(), + facets: z.array( + z.object({ + name: z.string(), + prompt: z.string(), + model: z.string().optional(), + embedding_model: z.string().optional(), + no_match_pattern: z.string().optional(), + }), + ), + topic_maps: z + .record( + z.array( + z.object({ + function_name: z.string(), + topic_map_id: z.string().optional(), + topic_map_data: TopicMapData, + }), + ), + ) + .optional(), +}); +export type BatchedFacetDataType = z.infer; export const BraintrustModelParams = z - .object({ use_cache: z.boolean() }) + .object({ + use_cache: z.boolean(), + reasoning_enabled: z.boolean(), + reasoning_budget: z.number(), + }) .partial(); export type BraintrustModelParamsType = z.infer; export const CallEvent = z.union([ @@ -239,7 +380,12 @@ export type CallEventType = z.infer; export const ChatCompletionContentPartTextWithTitle = z.object({ text: z.string().default(""), type: z.literal("text"), - cache_control: z.object({ type: z.literal("ephemeral") }).optional(), + cache_control: z + .object({ + type: z.literal("ephemeral"), + ttl: z.enum(["5m", "1h"]).optional(), + }) + .optional(), }); export type ChatCompletionContentPartTextWithTitleType = z.infer< typeof ChatCompletionContentPartTextWithTitle @@ -252,13 +398,39 @@ export const ChatCompletionContentPartImageWithTitle = z.object({ .optional(), }), type: z.literal("image_url"), + cache_control: z + .object({ + type: z.literal("ephemeral"), + ttl: z.enum(["5m", "1h"]).optional(), + }) + .optional(), }); export type ChatCompletionContentPartImageWithTitleType = z.infer< typeof ChatCompletionContentPartImageWithTitle >; +export const ChatCompletionContentPartFileFile = z + .object({ file_data: z.string(), filename: z.string(), file_id: z.string() }) + .partial(); +export type ChatCompletionContentPartFileFileType = z.infer< + typeof ChatCompletionContentPartFileFile +>; +export const ChatCompletionContentPartFileWithTitle = z.object({ + file: ChatCompletionContentPartFileFile, + type: z.literal("file"), + cache_control: z + .object({ + type: z.literal("ephemeral"), + ttl: z.enum(["5m", "1h"]).optional(), + }) + .optional(), +}); +export type ChatCompletionContentPartFileWithTitleType = z.infer< + typeof ChatCompletionContentPartFileWithTitle +>; export const ChatCompletionContentPart = z.union([ ChatCompletionContentPartTextWithTitle, ChatCompletionContentPartImageWithTitle, + ChatCompletionContentPartFileWithTitle, ]); export type ChatCompletionContentPartType = z.infer< typeof ChatCompletionContentPart @@ -266,7 +438,12 @@ export type ChatCompletionContentPartType = z.infer< export const ChatCompletionContentPartText = z.object({ text: z.string().default(""), type: z.literal("text"), - cache_control: z.object({ type: z.literal("ephemeral") }).optional(), + cache_control: z + .object({ + type: z.literal("ephemeral"), + ttl: z.enum(["5m", "1h"]).optional(), + }) + .optional(), }); export type ChatCompletionContentPartTextType = z.infer< typeof ChatCompletionContentPartText @@ -307,6 +484,7 @@ export const ChatCompletionMessageParam = z.union([ name: z.string().optional(), tool_calls: z.array(ChatCompletionMessageToolCall).optional(), reasoning: z.array(ChatCompletionMessageReasoning).optional(), + reasoning_signature: z.string().optional(), }), z.object({ content: z.union([z.string(), z.array(ChatCompletionContentPartText)]), @@ -353,6 +531,7 @@ export const ChatCompletionOpenAIMessageParam = z.union([ name: z.string().optional(), tool_calls: z.array(ChatCompletionMessageToolCall).optional(), reasoning: z.array(ChatCompletionMessageReasoning).optional(), + reasoning_signature: z.string().optional(), }), z.object({ content: z.union([z.string(), z.array(ChatCompletionContentPartText)]), @@ -384,7 +563,7 @@ export const ChatCompletionTool = z.object({ export type ChatCompletionToolType = z.infer; export const CodeBundle = z.object({ runtime_context: z.object({ - runtime: z.enum(["node", "python"]), + runtime: z.enum(["node", "python", "browser", "quickjs"]), version: z.string(), }), location: z.union([ @@ -394,11 +573,26 @@ export const CodeBundle = z.object({ position: z.union([ z.object({ type: z.literal("task") }), z.object({ type: z.literal("scorer"), index: z.number().int().gte(0) }), + z.object({ + type: z.literal("classifier"), + index: z.number().int().gte(0), + }), ]), }), z.object({ type: z.literal("function"), index: z.number().int().gte(0) }), + z.object({ + type: z.literal("sandbox"), + sandbox_spec: z.union([ + z.object({ provider: z.literal("modal"), snapshot_ref: z.string() }), + z.object({ provider: z.literal("lambda") }), + ]), + entrypoints: z.array(z.string()).optional(), + eval_name: z.string(), + parameters: z.object({}).partial().passthrough().optional(), + evaluator_definition: z.unknown().optional(), + }), ]), - bundle_id: z.string(), + bundle_id: z.union([z.string(), z.null()]).optional(), preview: z.union([z.string(), z.null()]).optional(), }); export type CodeBundleType = z.infer; @@ -410,9 +604,11 @@ export const Dataset = z.object({ created: z.union([z.string(), z.null()]).optional(), deleted_at: z.union([z.string(), z.null()]).optional(), user_id: z.union([z.string(), z.null()]).optional(), + tags: z.union([z.array(z.string()), z.null()]).optional(), metadata: z .union([z.object({}).partial().passthrough(), z.null()]) .optional(), + url_slug: z.string(), }); export type DatasetType = z.infer; export const ObjectReferenceNullish = z.union([ @@ -433,6 +629,19 @@ export const ObjectReferenceNullish = z.union([ z.null(), ]); export type ObjectReferenceNullishType = z.infer; +export const SavedFunctionId = z.union([ + z.object({ + type: z.literal("function"), + id: z.string(), + version: z.string().optional(), + }), + z.object({ + type: z.literal("global"), + name: z.string(), + function_type: FunctionTypeEnum.optional().default("scorer"), + }), +]); +export type SavedFunctionIdType = z.infer; export const DatasetEvent = z.object({ id: z.string(), _xact_id: z.string(), @@ -456,15 +665,72 @@ export const DatasetEvent = z.object({ root_span_id: z.string(), is_root: z.union([z.boolean(), z.null()]).optional(), origin: ObjectReferenceNullish.optional(), + comments: z.union([z.array(z.unknown()), z.null()]).optional(), + audit_data: z.union([z.array(z.unknown()), z.null()]).optional(), + facets: z + .union([z.record(z.union([z.string(), z.null()])), z.null()]) + .optional(), + classifications: z + .union([ + z.record( + z.array( + z.object({ + id: z.string(), + label: z.string().optional(), + confidence: z.union([z.number(), z.null()]).optional(), + metadata: z + .union([z.object({}).partial().passthrough(), z.null()]) + .optional(), + source: SavedFunctionId.and( + z.union([ + z.object({ + type: z.literal("function"), + id: z.string(), + version: z.string().optional(), + }), + z.object({ + type: z.literal("global"), + name: z.string(), + function_type: FunctionTypeEnum.optional().default("scorer"), + }), + z.null(), + ]), + ).optional(), + }), + ), + ), + z.null(), + ]) + .optional(), }); export type DatasetEventType = z.infer; +export const DatasetSnapshot = z.object({ + id: z.string().uuid(), + dataset_id: z.string().uuid(), + name: z.string(), + description: z.union([z.string(), z.null()]), + xact_id: z.string(), + created: z.union([z.string(), z.null()]), +}); +export type DatasetSnapshotType = z.infer; export const EnvVar = z.object({ id: z.string().uuid(), object_type: z.enum(["organization", "project", "function"]), object_id: z.string().uuid(), name: z.string(), created: z.union([z.string(), z.null()]).optional(), + secret_updated_at: z.union([z.string(), z.null()]).optional(), + secret_updated_by_user_id: z.union([z.string(), z.null()]).optional(), used: z.union([z.string(), z.null()]).optional(), + metadata: z + .union([z.object({}).partial().passthrough(), z.null()]) + .optional(), + preview_secret: z.union([z.string(), z.null()]).optional(), + secret_type: z.union([z.string(), z.null()]).optional(), + secret_category: z + .enum(["env_var", "ai_provider", "sandbox_provider"]) + .optional() + .default("env_var"), }); export type EnvVarType = z.infer; export const RepoInfo = z.union([ @@ -496,6 +762,20 @@ export const Experiment = z.object({ deleted_at: z.union([z.string(), z.null()]).optional(), dataset_id: z.union([z.string(), z.null()]).optional(), dataset_version: z.union([z.string(), z.null()]).optional(), + internal_metadata: z + .union([ + z + .object({ + dataset_filter: z.union([ + z.object({}).partial().passthrough(), + z.null(), + ]), + }) + .partial() + .passthrough(), + z.null(), + ]) + .optional(), parameters_id: z.union([z.string(), z.null()]).optional(), parameters_version: z.union([z.string(), z.null()]).optional(), public: z.boolean(), @@ -507,13 +787,29 @@ export const Experiment = z.object({ }); export type ExperimentType = z.infer; export const SpanType = z.union([ - z.enum(["llm", "score", "function", "eval", "task", "tool"]), + z.enum([ + "llm", + "score", + "function", + "eval", + "task", + "tool", + "automation", + "facet", + "preprocessor", + "classifier", + "review", + ]), z.null(), ]); export type SpanTypeType = z.infer; export const SpanAttributes = z.union([ z - .object({ name: z.union([z.string(), z.null()]), type: SpanType }) + .object({ + name: z.union([z.string(), z.null()]), + type: SpanType, + purpose: z.union([z.literal("scorer"), z.null()]), + }) .partial() .passthrough(), z.null(), @@ -563,11 +859,56 @@ export const ExperimentEvent = z.object({ span_attributes: SpanAttributes.optional(), is_root: z.union([z.boolean(), z.null()]).optional(), origin: ObjectReferenceNullish.optional(), + comments: z.union([z.array(z.unknown()), z.null()]).optional(), + audit_data: z.union([z.array(z.unknown()), z.null()]).optional(), + facets: z + .union([z.record(z.union([z.string(), z.null()])), z.null()]) + .optional(), + classifications: z + .union([ + z.record( + z.array( + z.object({ + id: z.string(), + label: z.string().optional(), + confidence: z.union([z.number(), z.null()]).optional(), + metadata: z + .union([z.object({}).partial().passthrough(), z.null()]) + .optional(), + source: SavedFunctionId.and( + z.union([ + z.object({ + type: z.literal("function"), + id: z.string(), + version: z.string().optional(), + }), + z.object({ + type: z.literal("global"), + name: z.string(), + function_type: FunctionTypeEnum.optional().default("scorer"), + }), + z.null(), + ]), + ).optional(), + }), + ), + ), + z.null(), + ]) + .optional(), }); export type ExperimentEventType = z.infer; export const ExtendedSavedFunctionId = z.union([ - z.object({ type: z.literal("function"), id: z.string() }), - z.object({ type: z.literal("global"), name: z.string() }), + z.object({ + type: z.literal("function"), + id: z.string(), + version: z.string().optional(), + }), + z.object({ + type: z.literal("global"), + name: z.string(), + function_type: FunctionTypeEnum.optional().default("scorer"), + }), z.object({ type: z.literal("slug"), project_id: z.string(), @@ -577,13 +918,22 @@ export const ExtendedSavedFunctionId = z.union([ export type ExtendedSavedFunctionIdType = z.infer< typeof ExtendedSavedFunctionId >; +export const FacetData = z.object({ + type: z.literal("facet"), + preprocessor: FacetPreprocessorId.optional(), + prompt: z.string(), + model: z.string().optional(), + embedding_model: z.string().optional(), + no_match_pattern: z.string().optional(), +}); +export type FacetDataType = z.infer; export const PromptBlockDataNullish = z.union([ - z.object({ type: z.literal("completion"), content: z.string() }), z.object({ type: z.literal("chat"), messages: z.array(ChatCompletionMessageParam), tools: z.string().optional(), }), + z.object({ type: z.literal("completion"), content: z.string() }), z.null(), ]); export type PromptBlockDataNullishType = z.infer; @@ -591,6 +941,8 @@ export const ModelParams = z.union([ z .object({ use_cache: z.boolean(), + reasoning_enabled: z.boolean(), + reasoning_budget: z.number(), temperature: z.number(), top_p: z.number(), max_tokens: z.number(), @@ -614,7 +966,7 @@ export const ModelParams = z.union([ ]), n: z.number(), stop: z.array(z.string()), - reasoning_effort: z.enum(["minimal", "low", "medium", "high"]), + reasoning_effort: z.enum(["none", "minimal", "low", "medium", "high"]), verbosity: z.enum(["low", "medium", "high"]), }) .partial() @@ -622,6 +974,8 @@ export const ModelParams = z.union([ z .object({ use_cache: z.boolean().optional(), + reasoning_enabled: z.boolean().optional(), + reasoning_budget: z.number().optional(), max_tokens: z.number(), temperature: z.number(), top_p: z.number().optional(), @@ -633,6 +987,8 @@ export const ModelParams = z.union([ z .object({ use_cache: z.boolean(), + reasoning_enabled: z.boolean(), + reasoning_budget: z.number(), temperature: z.number(), maxOutputTokens: z.number(), topP: z.number(), @@ -643,17 +999,31 @@ export const ModelParams = z.union([ z .object({ use_cache: z.boolean(), + reasoning_enabled: z.boolean(), + reasoning_budget: z.number(), temperature: z.number(), topK: z.number(), }) .partial() .passthrough(), - z.object({ use_cache: z.boolean() }).partial().passthrough(), + z + .object({ + use_cache: z.boolean(), + reasoning_enabled: z.boolean(), + reasoning_budget: z.number(), + }) + .partial() + .passthrough(), ]); export type ModelParamsType = z.infer; export const PromptOptionsNullish = z.union([ z - .object({ model: z.string(), params: ModelParams, position: z.string() }) + .object({ + model: z.string(), + params: ModelParams, + position: z.string(), + endpoint_name: z.union([z.string(), z.null()]), + }) .partial(), z.null(), ]); @@ -662,23 +1032,65 @@ export const PromptParserNullish = z.union([ z.object({ type: z.literal("llm_classifier"), use_cot: z.boolean(), - choice_scores: z.record(z.number().gte(0).lte(1)), + choice_scores: z.record(z.number().gte(0).lte(1)).optional(), + choice: z.array(z.string()).optional(), + allow_no_match: z.boolean().optional(), + allow_skip: z.boolean().optional(), }), z.null(), ]); export type PromptParserNullishType = z.infer; -export const SavedFunctionId = z.union([ - z.object({ type: z.literal("function"), id: z.string() }), - z.object({ type: z.literal("global"), name: z.string() }), +export const PreprocessorSavedFunctionId = z.union([ + z.object({ + type: z.literal("function"), + id: z.string(), + version: z.string().optional(), + }), + z.object({ + type: z.literal("global"), + name: z.string(), + function_type: z.literal("preprocessor").optional().default("preprocessor"), + }), + z.null(), ]); -export type SavedFunctionIdType = z.infer; +export type PreprocessorSavedFunctionIdType = z.infer< + typeof PreprocessorSavedFunctionId +>; export const PromptDataNullish = z.union([ z .object({ prompt: PromptBlockDataNullish, options: PromptOptionsNullish, parser: PromptParserNullish, + preprocessor: PreprocessorSavedFunctionId, tool_functions: z.union([z.array(SavedFunctionId), z.null()]), + template_format: z.union([ + z.enum(["mustache", "nunjucks", "none"]), + z.null(), + ]), + mcp: z.union([ + z.record( + z.union([ + z.object({ + type: z.literal("id"), + id: z.string().uuid(), + is_disabled: z.boolean().optional(), + enabled_tools: z + .union([z.array(z.string()), z.null()]) + .optional(), + }), + z.object({ + type: z.literal("url"), + url: z.string(), + is_disabled: z.boolean().optional(), + enabled_tools: z + .union([z.array(z.string()), z.null()]) + .optional(), + }), + ]), + ), + z.null(), + ]), origin: z.union([ z .object({ @@ -695,7 +1107,19 @@ export const PromptDataNullish = z.union([ ]); export type PromptDataNullishType = z.infer; export const FunctionTypeEnumNullish = z.union([ - z.enum(["llm", "scorer", "task", "tool", "custom_view"]), + z.enum([ + "llm", + "scorer", + "task", + "tool", + "custom_view", + "preprocessor", + "facet", + "classifier", + "tag", + "parameters", + "sandbox", + ]), z.null(), ]); export type FunctionTypeEnumNullishType = z.infer< @@ -704,12 +1128,12 @@ export type FunctionTypeEnumNullishType = z.infer< export const FunctionIdRef = z.object({}).partial().passthrough(); export type FunctionIdRefType = z.infer; export const PromptBlockData = z.union([ - z.object({ type: z.literal("completion"), content: z.string() }), z.object({ type: z.literal("chat"), messages: z.array(ChatCompletionMessageParam), tools: z.string().optional(), }), + z.object({ type: z.literal("completion"), content: z.string() }), ]); export type PromptBlockDataType = z.infer; export const GraphNode = z.union([ @@ -797,10 +1221,11 @@ export const FunctionData = z.union([ z.object({ type: z.literal("inline"), runtime_context: z.object({ - runtime: z.enum(["node", "python"]), + runtime: z.enum(["node", "python", "browser", "quickjs"]), version: z.string(), }), code: z.string(), + code_hash: z.string().optional(), }), ]), }), @@ -810,8 +1235,29 @@ export const FunctionData = z.union([ endpoint: z.string(), eval_name: z.string(), parameters: z.object({}).partial().passthrough(), + parameters_version: z.union([z.string(), z.null()]).optional(), + }), + z.object({ + type: z.literal("global"), + name: z.string(), + function_type: FunctionTypeEnum.optional().default("scorer"), + config: z + .union([z.object({}).partial().passthrough(), z.null()]) + .optional(), }), - z.object({ type: z.literal("global"), name: z.string() }), + FacetData, + BatchedFacetData, + z.object({ + type: z.literal("parameters"), + data: z.object({}).partial().passthrough(), + __schema: z.object({ + type: z.literal("object"), + properties: z.record(z.object({}).partial().passthrough()), + required: z.array(z.string()).optional(), + additionalProperties: z.boolean().optional(), + }), + }), + TopicMapData.and(z.unknown()), ]); export type FunctionDataType = z.infer; export const Function = z.object({ @@ -849,14 +1295,44 @@ export const Function = z.object({ .optional(), }); export type FunctionType = z.infer; -export const FunctionFormat = z.enum(["llm", "code", "global", "graph"]); +export const FunctionFormat = z.enum([ + "llm", + "code", + "global", + "graph", + "topic_map", +]); export type FunctionFormatType = z.infer; export const PromptData = z .object({ prompt: PromptBlockDataNullish, options: PromptOptionsNullish, parser: PromptParserNullish, + preprocessor: PreprocessorSavedFunctionId, tool_functions: z.union([z.array(SavedFunctionId), z.null()]), + template_format: z.union([ + z.enum(["mustache", "nunjucks", "none"]), + z.null(), + ]), + mcp: z.union([ + z.record( + z.union([ + z.object({ + type: z.literal("id"), + id: z.string().uuid(), + is_disabled: z.boolean().optional(), + enabled_tools: z.union([z.array(z.string()), z.null()]).optional(), + }), + z.object({ + type: z.literal("url"), + url: z.string(), + is_disabled: z.boolean().optional(), + enabled_tools: z.union([z.array(z.string()), z.null()]).optional(), + }), + ]), + ), + z.null(), + ]), origin: z.union([ z .object({ @@ -870,8 +1346,6 @@ export const PromptData = z }) .partial(); export type PromptDataType = z.infer; -export const FunctionTypeEnum = z.enum(["llm", "scorer", "task", "tool"]); -export type FunctionTypeEnumType = z.infer; export const FunctionId = z.union([ z.object({ function_id: z.string(), version: z.string().optional() }), z.object({ @@ -879,7 +1353,10 @@ export const FunctionId = z.union([ slug: z.string(), version: z.string().optional(), }), - z.object({ global_function: z.string() }), + z.object({ + global_function: z.string(), + function_type: FunctionTypeEnum.optional().default("scorer"), + }), z.object({ prompt_session_id: z.string(), prompt_session_function_id: z.string(), @@ -887,28 +1364,47 @@ export const FunctionId = z.union([ }), z.object({ inline_context: z.object({ - runtime: z.enum(["node", "python"]), + runtime: z.enum(["node", "python", "browser", "quickjs"]), version: z.string(), }), code: z.string(), + function_type: FunctionTypeEnum.and(z.unknown()).optional(), name: z.union([z.string(), z.null()]).optional(), }), z.object({ inline_prompt: PromptData.optional(), inline_function: z.object({}).partial().passthrough(), - function_type: FunctionTypeEnum.optional(), + function_type: FunctionTypeEnum.optional().default("scorer"), name: z.union([z.string(), z.null()]).optional(), }), z.object({ inline_prompt: PromptData, - function_type: FunctionTypeEnum.optional(), + function_type: FunctionTypeEnum.optional().default("scorer"), name: z.union([z.string(), z.null()]).optional(), }), ]); export type FunctionIdType = z.infer; -export const FunctionObjectType = z.enum(["prompt", "tool", "scorer", "task"]); +export const FunctionObjectType = z.enum([ + "prompt", + "tool", + "scorer", + "task", + "workflow", + "custom_view", + "preprocessor", + "facet", + "classifier", + "parameters", + "sandbox", +]); export type FunctionObjectTypeType = z.infer; -export const FunctionOutputType = z.enum(["completion", "score", "any"]); +export const FunctionOutputType = z.enum([ + "completion", + "score", + "facet", + "classification", + "any", +]); export type FunctionOutputTypeType = z.infer; export const GitMetadataSettings = z.object({ collect: z.enum(["all", "none", "some"]), @@ -941,8 +1437,22 @@ export const Group = z.object({ member_groups: z.union([z.array(z.string().uuid()), z.null()]).optional(), }); export type GroupType = z.infer; +export const GroupScope = z.object({ + type: z.literal("group"), + group_by: z.string(), + interval_seconds: z.number().gte(1).optional(), + max_traces: z.number().int().gte(1).lte(64).optional(), + placement: z.enum(["first", "each"]), + idle_seconds: z.number().optional(), +}); +export type GroupScopeType = z.infer; export const IfExists = z.enum(["error", "ignore", "replace"]); export type IfExistsType = z.infer; +export const ImageRenderingMode = z.union([ + z.enum(["auto", "click_to_load", "blocked"]), + z.null(), +]); +export type ImageRenderingModeType = z.infer; export const InvokeParent = z.union([ z.object({ object_type: z.enum(["project_logs", "experiment", "playground_logs"]), @@ -964,7 +1474,10 @@ export const InvokeParent = z.union([ z.string(), ]); export type InvokeParentType = z.infer; -export const StreamingMode = z.union([z.enum(["auto", "parallel"]), z.null()]); +export const StreamingMode = z.union([ + z.enum(["auto", "parallel", "json", "text"]), + z.null(), +]); export type StreamingModeType = z.infer; export const InvokeFunction = FunctionId.and( z @@ -978,10 +1491,24 @@ export const InvokeFunction = FunctionId.and( stream: z.union([z.boolean(), z.null()]), mode: StreamingMode, strict: z.union([z.boolean(), z.null()]), + mcp_auth: z.record(z.object({ oauth_token: z.string() }).partial()), + overrides: z.union([z.object({}).partial().passthrough(), z.null()]), + endpoint_name: z.union([z.string(), z.null()]), }) .partial(), ); export type InvokeFunctionType = z.infer; +export const MCPServer = z.object({ + id: z.string().uuid(), + project_id: z.string().uuid(), + user_id: z.union([z.string(), z.null()]).optional(), + created: z.union([z.string(), z.null()]).optional(), + deleted_at: z.union([z.string(), z.null()]).optional(), + name: z.string(), + description: z.union([z.string(), z.null()]).optional(), + url: z.string(), +}); +export type MCPServerType = z.infer; export const MessageRole = z.enum([ "system", "user", @@ -992,6 +1519,22 @@ export const MessageRole = z.enum([ "developer", ]); export type MessageRoleType = z.infer; +export const NullableSavedFunctionId = z.union([ + z.object({ + type: z.literal("function"), + id: z.string(), + version: z.string().optional(), + }), + z.object({ + type: z.literal("global"), + name: z.string(), + function_type: FunctionTypeEnum.optional().default("scorer"), + }), + z.null(), +]); +export type NullableSavedFunctionIdType = z.infer< + typeof NullableSavedFunctionId +>; export const ObjectReference = z.object({ object_type: z.enum([ "project_logs", @@ -1007,14 +1550,23 @@ export const ObjectReference = z.object({ created: z.union([z.string(), z.null()]).optional(), }); export type ObjectReferenceType = z.infer; +export const SpanScope = z.object({ type: z.literal("span") }); +export type SpanScopeType = z.infer; +export const TraceScope = z.object({ + type: z.literal("trace"), + idle_seconds: z.number().optional(), +}); +export type TraceScopeType = z.infer; export const OnlineScoreConfig = z.union([ z.object({ + status: AutomationStatus.optional(), sampling_rate: z.number().gte(0).lte(1), scorers: z.array(SavedFunctionId), btql_filter: z.union([z.string(), z.null()]).optional(), apply_to_root_span: z.union([z.boolean(), z.null()]).optional(), apply_to_span_names: z.union([z.array(z.string()), z.null()]).optional(), skip_logging: z.union([z.boolean(), z.null()]).optional(), + scope: z.union([SpanScope, TraceScope, GroupScope, z.null()]).optional(), }), z.null(), ]); @@ -1024,11 +1576,33 @@ export const Organization = z.object({ name: z.string(), api_url: z.union([z.string(), z.null()]).optional(), is_universal_api: z.union([z.boolean(), z.null()]).optional(), + is_dataplane_private: z.union([z.boolean(), z.null()]).optional(), proxy_url: z.union([z.string(), z.null()]).optional(), realtime_url: z.union([z.string(), z.null()]).optional(), created: z.union([z.string(), z.null()]).optional(), + image_rendering_mode: ImageRenderingMode.optional(), }); export type OrganizationType = z.infer; +export const RetentionObjectType = z.enum([ + "project_logs", + "experiment", + "dataset", +]); +export type RetentionObjectTypeType = z.infer; +export const OrgAutomation = z.object({ + id: z.string().uuid(), + org_id: z.string().uuid(), + user_id: z.union([z.string(), z.null()]).optional(), + created: z.union([z.string(), z.null()]).optional(), + name: z.string(), + description: z.union([z.string(), z.null()]).optional(), + config: z.object({ + event_type: z.literal("retention"), + object_type: RetentionObjectType, + retention_days: z.number().int().gte(0), + }), +}); +export type OrgAutomationType = z.infer; export const ProjectSettings = z.union([ z .object({ @@ -1051,12 +1625,15 @@ export const ProjectSettings = z.union([ z.array( z.object({ url: z.string(), - name: z.string(), + name: z.union([z.string(), z.null()]).optional(), description: z.union([z.string(), z.null()]).optional(), }), ), z.null(), ]), + disable_realtime_queries: z.union([z.boolean(), z.null()]), + monitor_charts_use_metrics_start: z.union([z.boolean(), z.null()]), + default_preprocessor: NullableSavedFunctionId, }) .partial(), z.null(), @@ -1066,18 +1643,159 @@ export const Project = z.object({ id: z.string().uuid(), org_id: z.string().uuid(), name: z.string(), + description: z.union([z.string(), z.null()]).optional(), created: z.union([z.string(), z.null()]).optional(), deleted_at: z.union([z.string(), z.null()]).optional(), user_id: z.union([z.string(), z.null()]).optional(), settings: ProjectSettings.optional(), }); export type ProjectType = z.infer; -export const RetentionObjectType = z.enum([ - "project_logs", - "experiment", - "dataset", +export const WindowedAutomationConfig = z.object({ + event_type: z.literal("windowed"), + product_origin: z.union([z.literal("patterns"), z.null()]).optional(), + status: AutomationStatus.optional(), + threshold: z + .object({ + calculation: z.object({ + type: z.literal("btql"), + btql_query: z.string().min(1), + output: z.object({ + type: z.literal("scalar"), + value_column: z.string().min(1), + }), + }), + policy: z.object({ + condition: z.object({ + type: z.literal("threshold"), + operator: z.enum(["lt", "lte", "gt", "gte", "eq", "neq"]), + threshold: z.number(), + }), + pending_seconds: z.number().int().gte(0).lte(2592000), + no_data_behavior: z.enum(["keep_last", "resolve", "alert"]), + renotify_interval_seconds: z.union([z.number(), z.null()]).optional(), + notify_on_recovery: z.boolean().optional().default(true), + }), + }) + .optional(), + window: z.object({ + window_seconds: z.number().int().gte(1).lte(2592000), + schedule: z.union([ + z.object({ + type: z.literal("interval"), + evaluation_interval_seconds: z.number().int().gte(1).lte(2592000), + }), + z.object({ + type: z.literal("cron"), + cron_expression: z.string().min(1), + timezone: z.union([z.string(), z.null()]).optional(), + }), + ]), + evaluation_delay_seconds: z.number().int().gte(0).lte(2592000), + }), + loop: z + .object({ + prompt: z.string().min(1).max(10000), + include_trigger_input: z.boolean().optional().default(false), + agent_slug: z.string().min(1), + auto_approve_tools: z.array(z.string().min(1)).optional().default([]), + harness: z.enum(["native", "codex", "claude-code"]).optional(), + model: z.string().min(1).optional(), + reasoning_effort: z + .enum(["none", "minimal", "low", "medium", "high", "xhigh", "max"]) + .optional(), + }) + .optional(), + actions: z + .array( + z.union([ + z.object({ + type: z.literal("webhook"), + url: z.string(), + formatting_prompt: z.string().min(1).max(10000).optional(), + }), + z.object({ + type: z.literal("slack"), + workspace_id: z.string(), + channel: z.string(), + message_template: z.string().optional(), + formatting_prompt: z.string().min(1).max(10000).optional(), + }), + ]), + ) + .max(20) + .optional() + .default([]), +}); +export type WindowedAutomationConfigType = z.infer< + typeof WindowedAutomationConfig +>; +export const TopicAutomationFacetModel = z.union([ + z.enum(["brain-facet-latest", "brain-facet-1", "brain-facet-2"]), + z.null(), ]); -export type RetentionObjectTypeType = z.infer; +export type TopicAutomationFacetModelType = z.infer< + typeof TopicAutomationFacetModel +>; +export const TopicMapFunctionAutomation = z.object({ + function: SavedFunctionId.and(z.unknown()), + btql_filter: z.union([z.string(), z.null()]).optional(), +}); +export type TopicMapFunctionAutomationType = z.infer< + typeof TopicMapFunctionAutomation +>; +export const TopicAutomationDataScope = z.union([ + z.object({ type: z.literal("project_logs") }), + z.object({ type: z.literal("project_experiments") }), + z.object({ type: z.literal("experiment"), experiment_id: z.string() }), + z.null(), +]); +export type TopicAutomationDataScopeType = z.infer< + typeof TopicAutomationDataScope +>; +export const TopicAutomationConfig = z.object({ + event_type: z.literal("topic"), + status: AutomationStatus.optional(), + sampling_rate: z.number().gte(0).lte(1), + facet_model: TopicAutomationFacetModel.optional(), + facet_functions: z.array(SavedFunctionId), + topic_map_functions: z.array(TopicMapFunctionAutomation), + scope: z.union([SpanScope, TraceScope, GroupScope, z.null()]).optional(), + data_scope: TopicAutomationDataScope.optional(), + btql_filter: z.union([z.string(), z.null()]).optional(), + rerun_seconds: z.union([z.number(), z.null()]).optional(), + relabel_overlap_seconds: z.union([z.number(), z.null()]).optional(), + backfill_time_range: z + .union([ + z.string(), + z.object({ from: z.string(), to: z.string() }), + z.null(), + ]) + .optional(), +}); +export type TopicAutomationConfigType = z.infer; +export const TopicDigestAutomationConfig = z.object({ + event_type: z.literal("topic_digest"), + status: AutomationStatus.optional(), + window_seconds: z + .number() + .int() + .gte(3600) + .lte(2592000) + .optional() + .default(86400), + scheduled_time_minutes_utc: z.number().int().gte(0).lte(1439), + action: z.object({ + type: z.literal("slack"), + workspace_id: z.string(), + channel: z.string(), + message_template: z.string().optional(), + formatting_prompt: z.string().min(1).max(10000).optional(), + }), + topic_map_function_ids: z.array(z.string()).max(10).optional(), +}); +export type TopicDigestAutomationConfigType = z.infer< + typeof TopicDigestAutomationConfig +>; export const ProjectAutomation = z.object({ id: z.string().uuid(), project_id: z.string().uuid(), @@ -1088,35 +1806,105 @@ export const ProjectAutomation = z.object({ config: z.union([ z.object({ event_type: z.literal("logs"), + status: AutomationStatus.optional(), btql_filter: z.string(), interval_seconds: z.number().gte(1).lte(2592000), - action: z.object({ type: z.literal("webhook"), url: z.string() }), + action: z.union([ + z.object({ + type: z.literal("webhook"), + url: z.string(), + formatting_prompt: z.string().min(1).max(10000).optional(), + }), + z.object({ + type: z.literal("slack"), + workspace_id: z.string(), + channel: z.string(), + message_template: z.string().optional(), + formatting_prompt: z.string().min(1).max(10000).optional(), + }), + ]), }), z.object({ event_type: z.literal("btql_export"), + status: AutomationStatus.optional(), export_definition: z.union([ z.object({ type: z.literal("log_traces") }), z.object({ type: z.literal("log_spans") }), z.object({ type: z.literal("btql_query"), btql_query: z.string() }), ]), + scope: z.union([SpanScope, TraceScope, GroupScope, z.null()]).optional(), export_path: z.string(), format: z.enum(["jsonl", "parquet"]), interval_seconds: z.number().gte(1).lte(2592000), - credentials: z.object({ - type: z.literal("aws_iam"), - role_arn: z.string(), - external_id: z.string(), - }), + credentials: z.union([ + z.object({ + type: z.literal("aws_iam"), + role_arn: z.string(), + external_id: z.string(), + }), + z.object({ + type: z.literal("gcp_service_account"), + service_account_email: z.string(), + }), + ]), + batch_size: z.union([z.number(), z.null()]).optional(), + }), + z.object({ + event_type: z.literal("async_query"), + status: AutomationStatus.optional(), + created_by_user_id: z.string().uuid(), + object_type: z.enum([ + "project_logs", + "experiment", + "dataset", + "playground_logs", + ]), + object_id: z.string(), + query: z.string(), + format: z.literal("jsonl"), batch_size: z.union([z.number(), z.null()]).optional(), }), z.object({ event_type: z.literal("retention"), object_type: RetentionObjectType, - retention_days: z.number().gte(0), + retention_days: z.number().int().gte(0), }), + z.object({ + event_type: z.literal("environment_update"), + status: AutomationStatus.optional(), + environment_filter: z.array(z.string()).optional(), + action: z.union([ + z.object({ + type: z.literal("webhook"), + url: z.string(), + formatting_prompt: z.string().min(1).max(10000).optional(), + }), + z.object({ + type: z.literal("slack"), + workspace_id: z.string(), + channel: z.string(), + message_template: z.string().optional(), + formatting_prompt: z.string().min(1).max(10000).optional(), + }), + ]), + }), + WindowedAutomationConfig, + TopicAutomationConfig, + TopicDigestAutomationConfig, ]), }); export type ProjectAutomationType = z.infer; +export const ProjectGroup = z.object({ + id: z.string().uuid(), + org_id: z.string().uuid(), + user_id: z.union([z.string(), z.null()]).optional(), + created: z.union([z.string(), z.null()]).optional(), + name: z.string(), + description: z.union([z.string(), z.null()]).optional(), + deleted_at: z.union([z.string(), z.null()]).optional(), + member_projects: z.array(z.string().uuid()).max(10000), +}); +export type ProjectGroupType = z.infer; export const ProjectLogsEvent = z.object({ id: z.string(), _xact_id: z.string(), @@ -1162,6 +1950,44 @@ export const ProjectLogsEvent = z.object({ is_root: z.union([z.boolean(), z.null()]).optional(), span_attributes: SpanAttributes.optional(), origin: ObjectReferenceNullish.optional(), + comments: z.union([z.array(z.unknown()), z.null()]).optional(), + audit_data: z.union([z.array(z.unknown()), z.null()]).optional(), + _async_scoring_state: z.unknown().optional(), + facets: z + .union([z.record(z.union([z.string(), z.null()])), z.null()]) + .optional(), + classifications: z + .union([ + z.record( + z.array( + z.object({ + id: z.string(), + label: z.string().optional(), + confidence: z.union([z.number(), z.null()]).optional(), + metadata: z + .union([z.object({}).partial().passthrough(), z.null()]) + .optional(), + source: SavedFunctionId.and( + z.union([ + z.object({ + type: z.literal("function"), + id: z.string(), + version: z.string().optional(), + }), + z.object({ + type: z.literal("global"), + name: z.string(), + function_type: FunctionTypeEnum.optional().default("scorer"), + }), + z.null(), + ]), + ).optional(), + }), + ), + ), + z.null(), + ]) + .optional(), }); export type ProjectLogsEventType = z.infer; export const ProjectScoreType = z.enum([ @@ -1186,12 +2012,40 @@ export const ProjectScoreCategories = z.union([ z.null(), ]); export type ProjectScoreCategoriesType = z.infer; +export const ProjectScoreCondition = z.union([ + z.object({ + when: z + .object({ + clauses: z.union([z.array(z.string()), z.null()]), + subspan_clauses: z.union([z.array(z.string()), z.null()]), + trace_clauses: z.union([z.array(z.string()), z.null()]), + }) + .partial(), + behavior: z.literal("hidden").optional().default("hidden"), + }), + z.null(), +]); +export type ProjectScoreConditionType = z.infer; export const ProjectScoreConfig = z.union([ z .object({ multi_select: z.union([z.boolean(), z.null()]), destination: z.union([z.string(), z.null()]), + visibility: z.union([ + z + .object({ + users: z.union([z.array(z.string()), z.null()]), + groups: z.union([z.array(z.string()), z.null()]), + }) + .partial(), + z.null(), + ]), online: OnlineScoreConfig, + condition: ProjectScoreCondition, + object_types: z.union([ + z.array(z.enum(["project_logs", "dataset", "experiment"])), + z.null(), + ]), }) .partial(), z.null(), @@ -1240,7 +2094,12 @@ export const Prompt = z.object({ }); export type PromptType = z.infer; export const PromptOptions = z - .object({ model: z.string(), params: ModelParams, position: z.string() }) + .object({ + model: z.string(), + params: ModelParams, + position: z.string(), + endpoint_name: z.union([z.string(), z.null()]), + }) .partial(); export type PromptOptionsType = z.infer; export const PromptSessionEvent = z.object({ @@ -1295,6 +2154,8 @@ export const RunEval = z.object({ data: z.union([ z.object({ dataset_id: z.string(), + dataset_version: z.union([z.string(), z.null()]).optional(), + dataset_environment: z.union([z.string(), z.null()]).optional(), _internal_btql: z .union([z.object({}).partial().passthrough(), z.null()]) .optional(), @@ -1302,12 +2163,16 @@ export const RunEval = z.object({ z.object({ project_name: z.string(), dataset_name: z.string(), + dataset_version: z.union([z.string(), z.null()]).optional(), + dataset_environment: z.union([z.string(), z.null()]).optional(), _internal_btql: z .union([z.object({}).partial().passthrough(), z.null()]) .optional(), }), z.object({ data: z.array(z.unknown()) }), ]), + name: z.string().optional(), + parameters: z.object({}).partial().passthrough().optional(), task: FunctionId.and(z.unknown()), scores: z.array(FunctionId), experiment_name: z.string().optional(), @@ -1328,6 +2193,10 @@ export const RunEval = z.object({ stop_token: z.union([z.string(), z.null()]).optional(), extra_messages: z.string().optional(), tags: z.array(z.string()).optional(), + mcp_auth: z + .record(z.object({ oauth_token: z.string() }).partial()) + .optional(), + endpoint_name: z.union([z.string(), z.null()]).optional(), }); export type RunEvalType = z.infer; export const ServiceToken = z.object({ @@ -1339,6 +2208,7 @@ export const ServiceToken = z.object({ service_account_email: z.union([z.string(), z.null()]).optional(), service_account_name: z.union([z.string(), z.null()]).optional(), org_id: z.union([z.string(), z.null()]).optional(), + expires_at: z.union([z.string(), z.null()]).optional(), }); export type ServiceTokenType = z.infer; export const SpanIFrame = z.object({ @@ -1410,7 +2280,7 @@ export const ViewDataSearch = z.union([ ]); export type ViewDataSearchType = z.infer; export const ViewData = z.union([ - z.object({ search: ViewDataSearch }).partial(), + z.object({ search: ViewDataSearch, custom_charts: z.unknown() }).partial(), z.null(), ]); export type ViewDataType = z.infer; @@ -1430,6 +2300,7 @@ export const ViewOptions = z.union([ groupBy: z.union([z.string(), z.null()]), }) .partial(), + freezeColumns: z.union([z.boolean(), z.null()]).optional(), }), z .object({ @@ -1440,6 +2311,7 @@ export const ViewOptions = z.union([ rowHeight: z.union([z.string(), z.null()]), tallGroupRows: z.union([z.boolean(), z.null()]), layout: z.union([z.string(), z.null()]), + topicMapReportKey: z.union([z.string(), z.null()]), chartHeight: z.union([z.number(), z.null()]), excludedMeasures: z.union([ z.array( @@ -1471,6 +2343,13 @@ export const ViewOptions = z.union([ }), z.null(), ]), + pointSizeMetric: z.union([ + z.object({ + type: z.enum(["none", "score", "metric", "metadata"]), + value: z.string(), + }), + z.null(), + ]), xAxisAggregation: z.union([z.string(), z.null()]), chartAnnotations: z.union([ z.array(z.object({ id: z.string(), text: z.string() })), @@ -1481,6 +2360,9 @@ export const ViewOptions = z.union([ z.object({ from: z.string(), to: z.string() }), z.null(), ]), + queryShape: z.union([z.enum(["traces", "spans", "topics"]), z.null()]), + cluster: z.union([z.string(), z.null()]), + freezeColumns: z.union([z.boolean(), z.null()]), }) .partial(), z.null(), @@ -1499,13 +2381,20 @@ export const View = z.object({ "datasets", "dataset", "prompts", + "parameters", "tools", "scorers", + "classifiers", "logs", "monitor", + "for_review_project_log", + "for_review_experiments", + "for_review_datasets", ]), name: z.string(), + description: z.union([z.string(), z.null()]).optional(), created: z.union([z.string(), z.null()]).optional(), + updated_at: z.union([z.string(), z.null()]).optional(), view_data: ViewData.optional(), options: ViewOptions.optional(), user_id: z.union([z.string(), z.null()]).optional(), diff --git a/knip.jsonc b/knip.jsonc index 9752cb9a2..40f840f2d 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -9,7 +9,7 @@ "integrations/val.town/vals/tutorial/code.ts", ], "ignoreIssues": { - "**/generated_types.ts": ["exports", "types"], + "**/generated*_types.ts": ["files", "exports", "types"], }, "workspaces": { "dev-packages/seinfeld": {