braintrust
Advanced tools
Comparing version 0.0.42 to 0.0.43
@@ -1,4 +0,4 @@ | ||
function z(e,t){return function(){return e.apply(t,arguments)}}var{toString:Dt}=Object.prototype,{getPrototypeOf:be}=Object,Z=(e=>t=>{let r=Dt.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),A=e=>(e=e.toLowerCase(),t=>Z(t)===e),ee=e=>t=>typeof t===e,{isArray:j}=Array,H=ee("undefined");function Ut(e){return e!==null&&!H(e)&&e.constructor!==null&&!H(e.constructor)&&_(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var $e=A("ArrayBuffer");function jt(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&$e(e.buffer),t}var kt=ee("string"),_=ee("function"),Ke=ee("number"),te=e=>e!==null&&typeof e=="object",Lt=e=>e===!0||e===!1,Y=e=>{if(Z(e)!=="object")return!1;let t=be(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Ft=A("Date"),It=A("File"),Bt=A("Blob"),vt=A("FileList"),zt=e=>te(e)&&_(e.pipe),Ht=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_(e.append)&&((t=Z(e))==="formdata"||t==="object"&&_(e.toString)&&e.toString()==="[object FormData]"))},qt=A("URLSearchParams"),Mt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function q(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),j(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{let i=r?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length,u;for(n=0;n<s;n++)u=i[n],t.call(null,e[u],u,e)}}function We(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}var Ge=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),Xe=e=>!H(e)&&e!==Ge;function we(){let{caseless:e}=Xe(this)&&this||{},t={},r=(n,o)=>{let i=e&&We(t,o)||o;Y(t[i])&&Y(n)?t[i]=we(t[i],n):Y(n)?t[i]=we({},n):j(n)?t[i]=n.slice():t[i]=n};for(let n=0,o=arguments.length;n<o;n++)arguments[n]&&q(arguments[n],r);return t}var Jt=(e,t,r,{allOwnKeys:n}={})=>(q(t,(o,i)=>{r&&_(o)?e[i]=z(o,r):e[i]=o},{allOwnKeys:n}),e),Vt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),$t=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Kt=(e,t,r,n)=>{let o,i,s,u={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!n||n(s,e,t))&&!u[s]&&(t[s]=e[s],u[s]=!0);e=r!==!1&&be(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Wt=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},Gt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!Ke(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Xt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&be(Uint8Array)),Qt=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),o;for(;(o=n.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},Yt=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Zt=A("HTMLFormElement"),er=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Je=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),tr=A("RegExp"),Qe=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};q(r,(o,i)=>{t(o,i,e)!==!1&&(n[i]=o)}),Object.defineProperties(e,n)},rr=e=>{Qe(e,(t,r)=>{if(_(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(_(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},nr=(e,t)=>{let r={},n=o=>{o.forEach(i=>{r[i]=!0})};return j(e)?n(e):n(String(e).split(t)),r},or=()=>{},ir=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ye="abcdefghijklmnopqrstuvwxyz",Ve="0123456789",Ye={DIGIT:Ve,ALPHA:ye,ALPHA_DIGIT:ye+ye.toUpperCase()+Ve},sr=(e=16,t=Ye.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function ar(e){return!!(e&&_(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var ur=e=>{let t=new Array(10),r=(n,o)=>{if(te(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[o]=n;let i=j(n)?[]:{};return q(n,(s,u)=>{let d=r(s,o+1);!H(d)&&(i[u]=d)}),t[o]=void 0,i}}return n};return r(e,0)},cr=A("AsyncFunction"),lr=e=>e&&(te(e)||_(e))&&_(e.then)&&_(e.catch),a={isArray:j,isArrayBuffer:$e,isBuffer:Ut,isFormData:Ht,isArrayBufferView:jt,isString:kt,isNumber:Ke,isBoolean:Lt,isObject:te,isPlainObject:Y,isUndefined:H,isDate:Ft,isFile:It,isBlob:Bt,isRegExp:tr,isFunction:_,isStream:zt,isURLSearchParams:qt,isTypedArray:Xt,isFileList:vt,forEach:q,merge:we,extend:Jt,trim:Mt,stripBOM:Vt,inherits:$t,toFlatObject:Kt,kindOf:Z,kindOfTest:A,endsWith:Wt,toArray:Gt,forEachEntry:Qt,matchAll:Yt,isHTMLForm:Zt,hasOwnProperty:Je,hasOwnProp:Je,reduceDescriptors:Qe,freezeMethods:rr,toObjectSet:nr,toCamelCase:er,noop:or,toFiniteNumber:ir,findKey:We,global:Ge,isContextDefined:Xe,ALPHABET:Ye,generateString:sr,isSpecCompliantForm:ar,toJSONObject:ur,isAsyncFn:cr,isThenable:lr};function k(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}a.inherits(k,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var Ze=k.prototype,et={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{et[e]={value:e}});Object.defineProperties(k,et);Object.defineProperty(Ze,"isAxiosError",{value:!0});k.from=(e,t,r,n,o,i)=>{let s=Object.create(Ze);return a.toFlatObject(e,s,function(d){return d!==Error.prototype},u=>u!=="isAxiosError"),k.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};var m=k;var re=null;function xe(e){return a.isPlainObject(e)||a.isArray(e)}function rt(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,r){return e?e.concat(t).map(function(o,i){return o=rt(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function dr(e){return a.isArray(e)&&!e.some(xe)}var fr=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function pr(e,t,r){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new(re||FormData),r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,O){return!a.isUndefined(O[h])});let n=r.metaTokens,o=r.visitor||l,i=r.dots,s=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(o))throw new TypeError("visitor must be a function");function c(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(!d&&a.isBlob(f))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,h,O){let S=f;if(f&&!O&&typeof f=="object"){if(a.endsWith(h,"{}"))h=n?h:h.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&dr(f)||(a.isFileList(f)||a.endsWith(h,"[]"))&&(S=a.toArray(f)))return h=rt(h),S.forEach(function(Q,Ct){!(a.isUndefined(Q)||Q===null)&&t.append(s===!0?tt([h],Ct,i):s===null?h:h+"[]",c(Q))}),!1}return xe(f)?!0:(t.append(tt(O,h,i),c(f)),!1)}let p=[],y=Object.assign(fr,{defaultVisitor:l,convertValue:c,isVisitable:xe});function g(f,h){if(!a.isUndefined(f)){if(p.indexOf(f)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(f),a.forEach(f,function(S,U){(!(a.isUndefined(S)||S===null)&&o.call(t,S,a.isString(U)?U.trim():U,h,y))===!0&&g(S,h?h.concat(U):[U])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return g(e),t}var P=pr;function nt(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function ot(e,t){this._pairs=[],e&&P(e,this,t)}var it=ot.prototype;it.append=function(t,r){this._pairs.push([t,r])};it.toString=function(t){let r=t?function(n){return t.call(this,n,nt)}:nt;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var ne=ot;function mr(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function M(e,t,r){if(!t)return e;let n=r&&r.encode||mr,o=r&&r.serialize,i;if(o?i=o(t,r):i=a.isURLSearchParams(t)?t.toString():new ne(t,r).toString(n),i){let s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}var Ee=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(n){n!==null&&t(n)})}},_e=Ee;var oe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var st=typeof URLSearchParams<"u"?URLSearchParams:ne;var at=typeof FormData<"u"?FormData:null;var ut=typeof Blob<"u"?Blob:null;var hr=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),gr=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),x={isBrowser:!0,classes:{URLSearchParams:st,FormData:at,Blob:ut},isStandardBrowserEnv:hr,isStandardBrowserWebWorkerEnv:gr,protocols:["http","https","file","blob","url","data"]};function Se(e,t){return P(e,new x.classes.URLSearchParams,Object.assign({visitor:function(r,n,o,i){return x.isNode&&a.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function yr(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function wr(e){let t={},r=Object.keys(e),n,o=r.length,i;for(n=0;n<o;n++)i=r[n],t[i]=e[i];return t}function br(e){function t(r,n,o,i){let s=r[i++],u=Number.isFinite(+s),d=i>=r.length;return s=!s&&a.isArray(o)?o.length:s,d?(a.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!u):((!o[s]||!a.isObject(o[s]))&&(o[s]=[]),t(r,n,o[s],i)&&a.isArray(o[s])&&(o[s]=wr(o[s])),!u)}if(a.isFormData(e)&&a.isFunction(e.entries)){let r={};return a.forEachEntry(e,(n,o)=>{t(yr(n),o,r,0)}),r}return null}var ie=br;var xr={"Content-Type":void 0};function Er(e,t,r){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var se={transitional:oe,adapter:["xhr","http"],transformRequest:[function(t,r){let n=r.getContentType()||"",o=n.indexOf("application/json")>-1,i=a.isObject(t);if(i&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return o&&o?JSON.stringify(ie(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Se(t,this.formSerializer).toString();if((u=a.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return P(u?{"files[]":t}:t,d&&new d,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),Er(t)):t}],transformResponse:[function(t){let r=this.transitional||se.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(t&&a.isString(t)&&(n&&!this.responseType||o)){let s=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(u){if(s)throw u.name==="SyntaxError"?m.from(u,m.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:x.classes.FormData,Blob:x.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};a.forEach(["delete","get","head"],function(t){se.headers[t]={}});a.forEach(["post","put","patch"],function(t){se.headers[t]=a.merge(xr)});var L=se;var _r=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ct=e=>{let t={},r,n,o;return e&&e.split(` | ||
`).forEach(function(s){o=s.indexOf(":"),r=s.substring(0,o).trim().toLowerCase(),n=s.substring(o+1).trim(),!(!r||t[r]&&_r[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var lt=Symbol("internals");function J(e){return e&&String(e).trim().toLowerCase()}function ae(e){return e===!1||e==null?e:a.isArray(e)?e.map(ae):String(e)}function Sr(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var Rr=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Re(e,t,r,n,o){if(a.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!a.isString(t)){if(a.isString(n))return t.indexOf(n)!==-1;if(a.isRegExp(n))return n.test(t)}}function Ar(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function Or(e,t){let r=a.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,i,s){return this[n].call(this,t,o,i,s)},configurable:!0})})}var F=class{constructor(t){t&&this.set(t)}set(t,r,n){let o=this;function i(u,d,c){let l=J(d);if(!l)throw new Error("header name must be a non-empty string");let p=a.findKey(o,l);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||d]=ae(u))}let s=(u,d)=>a.forEach(u,(c,l)=>i(c,l,d));return a.isPlainObject(t)||t instanceof this.constructor?s(t,r):a.isString(t)&&(t=t.trim())&&!Rr(t)?s(ct(t),r):t!=null&&i(r,t,n),this}get(t,r){if(t=J(t),t){let n=a.findKey(this,t);if(n){let o=this[n];if(!r)return o;if(r===!0)return Sr(o);if(a.isFunction(r))return r.call(this,o,n);if(a.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=J(t),t){let n=a.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Re(this,this[n],n,r)))}return!1}delete(t,r){let n=this,o=!1;function i(s){if(s=J(s),s){let u=a.findKey(n,s);u&&(!r||Re(n,n[u],u,r))&&(delete n[u],o=!0)}}return a.isArray(t)?t.forEach(i):i(t),o}clear(t){let r=Object.keys(this),n=r.length,o=!1;for(;n--;){let i=r[n];(!t||Re(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){let r=this,n={};return a.forEach(this,(o,i)=>{let s=a.findKey(n,i);if(s){r[s]=ae(o),delete r[i];return}let u=t?Ar(i):String(i).trim();u!==i&&delete r[i],r[u]=ae(o),n[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return a.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&a.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(` | ||
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){let n=(this[lt]=this[lt]={accessors:{}}).accessors,o=this.prototype;function i(s){let u=J(s);n[u]||(Or(o,s),n[u]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};F.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.freezeMethods(F.prototype);a.freezeMethods(F);var E=F;function V(e,t){let r=this||L,n=t||r,o=E.from(n.headers),i=n.data;return a.forEach(e,function(u){i=u.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function $(e){return!!(e&&e.__CANCEL__)}function dt(e,t,r){m.call(this,e??"canceled",m.ERR_CANCELED,t,r),this.name="CanceledError"}a.inherits(dt,m,{__CANCEL__:!0});var T=dt;function Ae(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new m("Request failed with status code "+r.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}var ft=x.isStandardBrowserEnv?function(){return{write:function(r,n,o,i,s,u){let d=[];d.push(r+"="+encodeURIComponent(n)),a.isNumber(o)&&d.push("expires="+new Date(o).toGMTString()),a.isString(i)&&d.push("path="+i),a.isString(s)&&d.push("domain="+s),u===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(r){let n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Oe(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ne(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function K(e,t){return e&&!Oe(t)?Ne(e,t):t}var pt=x.isStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function o(i){let s=i;return t&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=o(window.location.href),function(s){let u=a.isString(s)?o(s):s;return u.protocol===n.protocol&&u.host===n.host}}():function(){return function(){return!0}}();function Pe(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Nr(e,t){e=e||10;let r=new Array(e),n=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(d){let c=Date.now(),l=n[i];s||(s=c),r[o]=d,n[o]=c;let p=i,y=0;for(;p!==o;)y+=r[p++],p=p%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-s<t)return;let g=l&&c-l;return g?Math.round(y*1e3/g):void 0}}var mt=Nr;function ht(e,t){let r=0,n=mt(50,250);return o=>{let i=o.loaded,s=o.lengthComputable?o.total:void 0,u=i-r,d=n(u),c=i<=s;r=i;let l={loaded:i,total:s,progress:s?i/s:void 0,bytes:u,rate:d||void 0,estimated:d&&s&&c?(s-i)/d:void 0,event:o};l[t?"download":"upload"]=!0,e(l)}}var Pr=typeof XMLHttpRequest<"u",gt=Pr&&function(e){return new Promise(function(r,n){let o=e.data,i=E.from(e.headers).normalize(),s=e.responseType,u;function d(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}a.isFormData(o)&&(x.isStandardBrowserEnv||x.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){let g=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(g+":"+f))}let l=K(e.baseURL,e.url);c.open(e.method.toUpperCase(),M(l,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function p(){if(!c)return;let g=E.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),h={data:!s||s==="text"||s==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:g,config:e,request:c};Ae(function(S){r(S),d()},function(S){n(S),d()},h),c=null}if("onloadend"in c?c.onloadend=p:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(p)},c.onabort=function(){c&&(n(new m("Request aborted",m.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new m("Network Error",m.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let f=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",h=e.transitional||oe;e.timeoutErrorMessage&&(f=e.timeoutErrorMessage),n(new m(f,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,c)),c=null},x.isStandardBrowserEnv){let g=(e.withCredentials||pt(l))&&e.xsrfCookieName&&ft.read(e.xsrfCookieName);g&&i.set(e.xsrfHeaderName,g)}o===void 0&&i.setContentType(null),"setRequestHeader"in c&&a.forEach(i.toJSON(),function(f,h){c.setRequestHeader(h,f)}),a.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),s&&s!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",ht(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",ht(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=g=>{c&&(n(!g||g.type?new T(null,e,c):g),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));let y=Pe(l);if(y&&x.protocols.indexOf(y)===-1){n(new m("Unsupported protocol "+y+":",m.ERR_BAD_REQUEST,e));return}c.send(o||null)})};var ue={http:re,xhr:gt};a.forEach(ue,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var yt={getAdapter:e=>{e=a.isArray(e)?e:[e];let{length:t}=e,r,n;for(let o=0;o<t&&(r=e[o],!(n=a.isString(r)?ue[r.toLowerCase()]:r));o++);if(!n)throw n===!1?new m(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(a.hasOwnProp(ue,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!a.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:ue};function Te(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new T(null,e)}function ce(e){return Te(e),e.headers=E.from(e.headers),e.data=V.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),yt.getAdapter(e.adapter||L.adapter)(e).then(function(n){return Te(e),n.data=V.call(e,e.transformResponse,n),n.headers=E.from(n.headers),n},function(n){return $(n)||(Te(e),n&&n.response&&(n.response.data=V.call(e,e.transformResponse,n.response),n.response.headers=E.from(n.response.headers))),Promise.reject(n)})}var wt=e=>e instanceof E?e.toJSON():e;function N(e,t){t=t||{};let r={};function n(c,l,p){return a.isPlainObject(c)&&a.isPlainObject(l)?a.merge.call({caseless:p},c,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function o(c,l,p){if(a.isUndefined(l)){if(!a.isUndefined(c))return n(void 0,c,p)}else return n(c,l,p)}function i(c,l){if(!a.isUndefined(l))return n(void 0,l)}function s(c,l){if(a.isUndefined(l)){if(!a.isUndefined(c))return n(void 0,c)}else return n(void 0,l)}function u(c,l,p){if(p in t)return n(c,l);if(p in e)return n(void 0,c)}let d={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:u,headers:(c,l)=>o(wt(c),wt(l),!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(l){let p=d[l]||o,y=p(e[l],t[l],l);a.isUndefined(y)&&p!==u||(r[l]=y)}),r}var le="1.4.0";var Ce={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ce[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var bt={};Ce.transitional=function(t,r,n){function o(i,s){return"[Axios v"+le+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,u)=>{if(t===!1)throw new m(o(s," has been removed"+(r?" in "+r:"")),m.ERR_DEPRECATED);return r&&!bt[s]&&(bt[s]=!0,console.warn(o(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,s,u):!0}};function Tr(e,t,r){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),o=n.length;for(;o-- >0;){let i=n[o],s=t[i];if(s){let u=e[i],d=u===void 0||s(u,i,e);if(d!==!0)throw new m("option "+i+" must be "+d,m.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}}var de={assertOptions:Tr,validators:Ce};var C=de.validators,I=class{constructor(t){this.defaults=t,this.interceptors={request:new _e,response:new _e}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=N(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&de.assertOptions(n,{silentJSONParsing:C.transitional(C.boolean),forcedJSONParsing:C.transitional(C.boolean),clarifyTimeoutError:C.transitional(C.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:de.assertOptions(o,{encode:C.function,serialize:C.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s;s=i&&a.merge(i.common,i[r.method]),s&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),r.headers=E.concat(s,i);let u=[],d=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(d=d&&h.synchronous,u.unshift(h.fulfilled,h.rejected))});let c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let l,p=0,y;if(!d){let f=[ce.bind(this),void 0];for(f.unshift.apply(f,u),f.push.apply(f,c),y=f.length,l=Promise.resolve(r);p<y;)l=l.then(f[p++],f[p++]);return l}y=u.length;let g=r;for(p=0;p<y;){let f=u[p++],h=u[p++];try{g=f(g)}catch(O){h.call(this,O);break}}try{l=ce.call(this,g)}catch(f){return Promise.reject(f)}for(p=0,y=c.length;p<y;)l=l.then(c[p++],c[p++]);return l}getUri(t){t=N(this.defaults,t);let r=K(t.baseURL,t.url);return M(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){I.prototype[t]=function(r,n){return this.request(N(n||{},{method:t,url:r,data:(n||{}).data}))}});a.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,u){return this.request(N(u||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}I.prototype[t]=r(),I.prototype[t+"Form"]=r(!0)});var W=I;var De=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(u=>{n.subscribe(u),i=u}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},t(function(i,s,u){n.reason||(n.reason=new T(i,s,u),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new e(function(o){t=o}),cancel:t}}},xt=De;function Ue(e){return function(r){return e.apply(null,r)}}function je(e){return a.isObject(e)&&e.isAxiosError===!0}var ke={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ke).forEach(([e,t])=>{ke[t]=e});var Et=ke;function _t(e){let t=new W(e),r=z(W.prototype.request,t);return a.extend(r,W.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return _t(N(e,o))},r}var w=_t(L);w.Axios=W;w.CanceledError=T;w.CancelToken=xt;w.isCancel=$;w.VERSION=le;w.toFormData=P;w.AxiosError=m;w.Cancel=w.CanceledError;w.all=function(t){return Promise.all(t)};w.spread=Ue;w.isAxiosError=je;w.mergeConfig=N;w.AxiosHeaders=E;w.formToJSON=e=>ie(a.isHTMLForm(e)?new FormData(e):e);w.HttpStatusCode=Et;w.default=w;var B=w;var{Axios:hi,AxiosError:gi,CanceledError:yi,isCancel:wi,CancelToken:bi,VERSION:xi,all:Ei,Cancel:_i,isAxiosError:Si,spread:Ri,toFormData:Ai,AxiosHeaders:Oi,HttpStatusCode:Ni,formToJSON:Pi,mergeConfig:Ti}=B;var fe,Cr=new Uint8Array(16);function Le(){if(!fe&&(fe=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!fe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return fe(Cr)}var b=[];for(let e=0;e<256;++e)b.push((e+256).toString(16).slice(1));function St(e,t=0){return(b[e[t+0]]+b[e[t+1]]+b[e[t+2]]+b[e[t+3]]+"-"+b[e[t+4]]+b[e[t+5]]+"-"+b[e[t+6]]+b[e[t+7]]+"-"+b[e[t+8]]+b[e[t+9]]+"-"+b[e[t+10]]+b[e[t+11]]+b[e[t+12]]+b[e[t+13]]+b[e[t+14]]+b[e[t+15]]).toLowerCase()}var Dr=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Fe={randomUUID:Dr};function Ur(e,t,r){if(Fe.randomUUID&&!t&&!e)return Fe.randomUUID();e=e||{};let n=e.random||(e.rng||Le)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let o=0;o<16;++o)t[r+o]=n[o];return t}return St(n)}var pe=Ur;var jr={makeAxios:e=>B.create({...e}),getRepoStatus:async()=>{},getPastNAncestors:async()=>[],getEnv:e=>{}},v=jr;var D={current_project:null,current_experiment:null},X=null,me=null,Me=null,Ot=null,Rt=!1,kr="_xact_id",he=class{constructor(t){this.base_url=t,this.token=null,this.session=null,this._reset()}async ping(){try{let t=await this.get("ping");return G===null&&(G=t.data),t.status===200}catch{return!1}}make_long_lived(){this._reset()}set_token(t){t=t.trim(),this.token=t,this._reset()}_reset(){let t={};this.token&&(t.Authorization=`Bearer ${this.token}`),this.session=v.makeAxios({headers:t})}async get(t,r=void 0){return await this.session.get(ze(this.base_url,t),{params:r})}async post(t,r=void 0){return await this.session.post(ze(this.base_url,t),r)}async get_json(t,r=void 0,n=0){let o=n+1;for(let i=0;i<o;i++)try{return(await this.get(`${t}`,r)).data}catch(s){if(i<o-1){console.log(`Retrying API request ${t} ${r} ${s.status} ${s.text}`);continue}throw s}}async post_json(t,r=void 0){return(await this.post(`${t}`,r)).data}},Ie=null;function Nt(){return Ie||(Ie=new he(X)),Ie}var Be=null;function R(){return Be||(Be=new he(Ot)),Be}var G=null;async function Pt(){return G===null&&(G=await R().get_json("ping")),G}var At=class{constructor(t,r,n){this.name=t,this.id=r,this.org_id=n}},ve="projects";async function Lr(e){let t={name:e,org_id:me},r=[];for(let n=0;n<2&&(r=await R().get_json(ve,t),!(r.length>0));n++)try{r=await R().post_json(ve,t)}catch{continue}if(r)return r[0];throw new Error(`Unable to find record in ${ve}`)}var ge=class{constructor(){this.items=[];this.active_flush=Promise.resolve([]);this.active_flush_resolved=!0}log(t){this.items.push(...t),this.active_flush_resolved&&(this.active_flush_resolved=!1,this.active_flush=this.flush_once())}async flush_once(){this.active_flush_resolved=!1;let t=this.items;this.items=[];let r=[];return t.length>0&&(r=(await R().post_json("logs",t)).data),this.items.length>0?this.active_flush=this.flush_once():this.active_flush_resolved=!0,r}async flush(){for(;await this.active_flush,!this.active_flush_resolved;);}};async function Wi(e,t={}){let{experiment:r,description:n,dataset:o,baseExperiment:i,update:s,apiUrl:u,apiKey:d,orgName:c,disableCache:l}=t||{};return await Tt({orgName:c,disableCache:l,apiKey:d,apiUrl:u}),D.current_project=await Lr(e),D.current_experiment=await Ir(D.current_project,{name:r,description:n,dataset:o,update:s,baseExperiment:i}),D.current_experiment}async function Gi(e,t={}){let{dataset:r,description:n,version:o,apiUrl:i,apiKey:s,orgName:u,disableCache:d}=t||{};return await Tt({orgName:u,disableCache:d,apiKey:s,apiUrl:i}),await Br(e,{name:r,description:n,version:o})}async function Tt(e={}){let{apiUrl:t=v.getEnv("BRAINTRUST_API_URL")||"https://www.braintrustdata.com",apiKey:r=v.getEnv("BRAINTRUST_API_KEY"),orgName:n=void 0,disableCache:o=!1,forceLogin:i=!1}=e||{};if(Rt&&!i)return;X=t;let s=null,u=!1,d=null;if(r!==void 0){let l=(await B.post(ze(X,"/api/apikey/login"),{token:r})).data;Fr(l.org_info,n),d=R(),d.set_token(r),u=await d.ping()}else throw new Error("Please specify an api key. Token based login is not yet implemented in the JS client.");if(!d)throw new Error("Conn should be set at this point (a bug)");u||await d.get("ping"),d.make_long_lived(),Nt().set_token(r),Rt=!0}function Xi(e){if(!D.current_experiment)throw new Error("Not initialized. Please call init() first");return D.current_experiment.log(e)}async function Qi(e={}){if(!D.current_experiment)throw new Error("Not initialized. Please call init() first");return await D.current_experiment.summarize(e)}function Fr(e,t){if(e.length===0)throw new Error("This user is not part of any organizations.");for(let r of e)if(t===void 0||r.name===t){me=r.id,Me=r.name,Ot=r.api_url;break}if(me===void 0)throw new Error(`Organization ${t} not found. Must be one of ${e.map(r=>r.name).join(", ")}`)}function ze(...e){return e.map(t=>t.replace(/^\//,"")).join("/")}async function Ir(e,{name:t,description:r,dataset:n,update:o,baseExperiment:i}={name:void 0,description:void 0,baseExperiment:void 0}){let s={project_id:e.id};t&&(s.name=t),r&&(s.description=r),o&&(s.update=o);let u=await v.getRepoStatus();u&&(s.repo_info=u);let d=R(),c;if(i!==void 0){let g=(await d.get("experiments",{project_id:e.id,name:i})).data;if(g.length>0)c=g[0].id;else throw new Error(`Base experiment ${i} not found`)}c===void 0&&(c=(await d.post("experiments-by-commits",{project_id:e.id,commits:await v.getPastNAncestors()})).data.experiment_id),c!==void 0&&(s.base_exp_id=c),n!==void 0&&(s.dataset_id=n.id,s.dataset_version=await n.version());let l=(await R().post_json("register-experiment",s))[0],p=(await Pt()).id;return new He(e,l.id,l.name,p,n)}var He=class{constructor(t,r,n,o,i){this.project=t,this.id=r,this.name=n,this.user_id=o,this.dataset=i,this.logger=new ge}log({input:t,output:r,expected:n,scores:o,metadata:i,id:s,datasetRecordId:u,allowLarge:d=!1,inputs:c}){if(t===void 0&&c===void 0)throw new Error("Either input or inputs (deprecated) must be specified. Prefer input.");if(t!==void 0&&c!==void 0)throw new Error("Only one of input or inputs (deprecated) can be specified. Prefer input.");for(let[p,y]of Object.entries(o)){if(typeof p!="string")throw new Error("score names must be strings");if(typeof y!="number")throw new Error("score values must be numbers");if(y<0||y>1)throw new Error("score values must be between 0 and 1")}if(i!==void 0){for(let p of Object.keys(i))if(typeof p!="string")throw new Error("metadata keys must be strings")}if(this.dataset&&u===void 0)throw new Error("datasetRecordId must be specified when using a dataset");if(!this.dataset&&u!==void 0)throw new Error("datasetRecordId cannot be specified when not using a dataset");let l={id:s||pe(),inputs:t??c,output:r,expected:n,scores:o,project_id:this.project.id,experiment_id:this.id,user_id:this.user_id,created:new Date().toISOString(),dataset_record_id:u,metadata:i};if(!d)for(let[p,y]of Object.entries(l)){let g=JSON.stringify(y);if(g&&g.length>65535)throw new Error(`Events must be less than 64KB in size. Please reduce the size of your ${p}.`)}return this.logger.log([l]),l.id}async summarize(t={}){let{summarizeScores:r=!0,comparisonExperimentId:n=void 0}=t||{};await this.logger.flush();let o=`${X}/app/${encodeURIComponent(Me)}/p/${encodeURIComponent(this.project.name)}`,i=`${o}/${encodeURIComponent(this.name)}`,s,u;if(r){if(n===void 0){let l=(await R().get("/crud/base_experiments",{id:this.id})).data;l.length>0&&(n=l[0].base_exp_id,u=l[0].base_exp_name)}n!==void 0&&(s=await R().get_json("/experiment-comparison",{experiment_id:this.id,base_experiment_id:n},3))}return{projectName:this.project.name,experimentName:this.name,projectUrl:o,experimentUrl:i,comparisonExperimentName:u,scores:s}}};async function Br(e,{name:t,description:r,version:n}={}){let o={org_id:me,project_name:e,dataset_name:t,description:r},i=await Nt().post_json("api/dataset/register",o),s=i.project,u=i.dataset,d=(await Pt()).id;return new qe(s,u.id,u.name,d,n)}var qe=class{constructor(t,r,n,o,i){this._fetchedData=void 0;this.project=t,this.id=r,this.name=n,this.user_id=o,this.pinnedVersion=i,this.logger=new ge}insert({input:t,output:r,metadata:n,id:o,allowLarge:i=!1}){if(n!==void 0){for(let u of Object.keys(n))if(typeof u!="string")throw new Error("metadata keys must be strings")}let s={id:o||pe(),inputs:t,output:r,project_id:this.project.id,dataset_id:this.id,user_id:this.user_id,created:new Date().toISOString(),metadata:n};if(!i)for(let[u,d]of Object.entries(s)){let c=JSON.stringify(d);if(c&&c.length>65535)throw new Error(`Records must be less than 64KB in size. Please reduce the size of your ${u}.`)}return this.logger.log([s]),s.id}delete(t){let r=this.user_id,n={id:t,project_id:this.project.id,dataset_id:this.id,user_id:r,created:new Date().toISOString(),_object_delete:!0};return this.logger.log([n]),n.id}async summarize(t={}){let{summarizeData:r=!0}=t||{};await this.logger.flush();let n=`${X}/app/${encodeURIComponent(Me)}/p/${encodeURIComponent(this.project.name)}`,o=`${n}/d/${encodeURIComponent(this.name)}`,i;return r&&(i=await R().get_json("dataset-summary",{dataset_id:this.id},3)),{projectName:this.project.name,datasetName:this.name,projectUrl:n,datasetUrl:o,dataSummary:i}}async*fetch(){let t=await this.fetchedData();for(let r of t)yield{id:r.id,input:r.input&&JSON.parse(r.input),output:r.input&&JSON.parse(r.output),metadata:r.metadata&&JSON.parse(r.metadata)};this.clearCache()}[Symbol.asyncIterator](){return this.fetch()}async fetchedData(){if(this._fetchedData===void 0){let r=await(await R().get("object/dataset",{id:this.id,fmt:"json",version:this.pinnedVersion})).data;this._fetchedData=r.split(` | ||
`).filter(n=>n.trim()!=="").map(n=>JSON.parse(n))}return this._fetchedData||[]}clearCache(){this._fetchedData=void 0}async version(){if(this.pinnedVersion!==void 0)return this.pinnedVersion;{let t=await this.fetchedData(),r;for(let n of t){let o=n[kr];(r===void 0||(o??o>r))&&(r=o)}return r}}};export{qe as Dataset,He as Experiment,At as Project,Wi as init,Gi as initDataset,Xi as log,Tt as login,Qi as summarize}; | ||
function v(e,t){return function(){return e.apply(t,arguments)}}var{toString:Ct}=Object.prototype,{getPrototypeOf:xe}=Object,Z=(e=>t=>{let r=Ct.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),R=e=>(e=e.toLowerCase(),t=>Z(t)===e),ee=e=>t=>typeof t===e,{isArray:U}=Array,H=ee("undefined");function Dt(e){return e!==null&&!H(e)&&e.constructor!==null&&!H(e.constructor)&&_(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var $e=R("ArrayBuffer");function Ut(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&$e(e.buffer),t}var jt=ee("string"),_=ee("function"),Ke=ee("number"),te=e=>e!==null&&typeof e=="object",kt=e=>e===!0||e===!1,Y=e=>{if(Z(e)!=="object")return!1;let t=xe(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Lt=R("Date"),Ft=R("File"),It=R("Blob"),Bt=R("FileList"),vt=e=>te(e)&&_(e.pipe),Ht=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||_(e.append)&&((t=Z(e))==="formdata"||t==="object"&&_(e.toString)&&e.toString()==="[object FormData]"))},zt=R("URLSearchParams"),qt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function z(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,o;if(typeof e!="object"&&(e=[e]),U(e))for(n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else{let i=r?Object.getOwnPropertyNames(e):Object.keys(e),s=i.length,u;for(n=0;n<s;n++)u=i[n],t.call(null,e[u],u,e)}}function We(e,t){t=t.toLowerCase();let r=Object.keys(e),n=r.length,o;for(;n-- >0;)if(o=r[n],t===o.toLowerCase())return o;return null}var Ge=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),Xe=e=>!H(e)&&e!==Ge;function we(){let{caseless:e}=Xe(this)&&this||{},t={},r=(n,o)=>{let i=e&&We(t,o)||o;Y(t[i])&&Y(n)?t[i]=we(t[i],n):Y(n)?t[i]=we({},n):U(n)?t[i]=n.slice():t[i]=n};for(let n=0,o=arguments.length;n<o;n++)arguments[n]&&z(arguments[n],r);return t}var Mt=(e,t,r,{allOwnKeys:n}={})=>(z(t,(o,i)=>{r&&_(o)?e[i]=v(o,r):e[i]=o},{allOwnKeys:n}),e),Jt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Vt=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},$t=(e,t,r,n)=>{let o,i,s,u={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),i=o.length;i-- >0;)s=o[i],(!n||n(s,e,t))&&!u[s]&&(t[s]=e[s],u[s]=!0);e=r!==!1&&xe(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Kt=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;let n=e.indexOf(t,r);return n!==-1&&n===r},Wt=e=>{if(!e)return null;if(U(e))return e;let t=e.length;if(!Ke(t))return null;let r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Gt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&xe(Uint8Array)),Xt=(e,t)=>{let n=(e&&e[Symbol.iterator]).call(e),o;for(;(o=n.next())&&!o.done;){let i=o.value;t.call(e,i[0],i[1])}},Qt=(e,t)=>{let r,n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Yt=R("HTMLFormElement"),Zt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,o){return n.toUpperCase()+o}),Je=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),er=R("RegExp"),Qe=(e,t)=>{let r=Object.getOwnPropertyDescriptors(e),n={};z(r,(o,i)=>{t(o,i,e)!==!1&&(n[i]=o)}),Object.defineProperties(e,n)},tr=e=>{Qe(e,(t,r)=>{if(_(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;let n=e[r];if(_(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},rr=(e,t)=>{let r={},n=o=>{o.forEach(i=>{r[i]=!0})};return U(e)?n(e):n(String(e).split(t)),r},nr=()=>{},or=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ye="abcdefghijklmnopqrstuvwxyz",Ve="0123456789",Ye={DIGIT:Ve,ALPHA:ye,ALPHA_DIGIT:ye+ye.toUpperCase()+Ve},ir=(e=16,t=Ye.ALPHA_DIGIT)=>{let r="",{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function sr(e){return!!(e&&_(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}var ar=e=>{let t=new Array(10),r=(n,o)=>{if(te(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[o]=n;let i=U(n)?[]:{};return z(n,(s,u)=>{let d=r(s,o+1);!H(d)&&(i[u]=d)}),t[o]=void 0,i}}return n};return r(e,0)},ur=R("AsyncFunction"),cr=e=>e&&(te(e)||_(e))&&_(e.then)&&_(e.catch),a={isArray:U,isArrayBuffer:$e,isBuffer:Dt,isFormData:Ht,isArrayBufferView:Ut,isString:jt,isNumber:Ke,isBoolean:kt,isObject:te,isPlainObject:Y,isUndefined:H,isDate:Lt,isFile:Ft,isBlob:It,isRegExp:er,isFunction:_,isStream:vt,isURLSearchParams:zt,isTypedArray:Gt,isFileList:Bt,forEach:z,merge:we,extend:Mt,trim:qt,stripBOM:Jt,inherits:Vt,toFlatObject:$t,kindOf:Z,kindOfTest:R,endsWith:Kt,toArray:Wt,forEachEntry:Xt,matchAll:Qt,isHTMLForm:Yt,hasOwnProperty:Je,hasOwnProp:Je,reduceDescriptors:Qe,freezeMethods:tr,toObjectSet:rr,toCamelCase:Zt,noop:nr,toFiniteNumber:or,findKey:We,global:Ge,isContextDefined:Xe,ALPHABET:Ye,generateString:ir,isSpecCompliantForm:sr,toJSONObject:ar,isAsyncFn:ur,isThenable:cr};function j(e,t,r,n,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}a.inherits(j,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var Ze=j.prototype,et={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{et[e]={value:e}});Object.defineProperties(j,et);Object.defineProperty(Ze,"isAxiosError",{value:!0});j.from=(e,t,r,n,o,i)=>{let s=Object.create(Ze);return a.toFlatObject(e,s,function(d){return d!==Error.prototype},u=>u!=="isAxiosError"),j.call(s,e.message,t,r,n,o),s.cause=e,s.name=e.name,i&&Object.assign(s,i),s};var m=j;var re=null;function Ee(e){return a.isPlainObject(e)||a.isArray(e)}function rt(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function tt(e,t,r){return e?e.concat(t).map(function(o,i){return o=rt(o),!r&&i?"["+o+"]":o}).join(r?".":""):t}function lr(e){return a.isArray(e)&&!e.some(Ee)}var dr=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function fr(e,t,r){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new(re||FormData),r=a.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,A){return!a.isUndefined(A[h])});let n=r.metaTokens,o=r.visitor||l,i=r.dots,s=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(o))throw new TypeError("visitor must be a function");function c(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(!d&&a.isBlob(f))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,h,A){let S=f;if(f&&!A&&typeof f=="object"){if(a.endsWith(h,"{}"))h=n?h:h.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&lr(f)||(a.isFileList(f)||a.endsWith(h,"[]"))&&(S=a.toArray(f)))return h=rt(h),S.forEach(function(Q,Tt){!(a.isUndefined(Q)||Q===null)&&t.append(s===!0?tt([h],Tt,i):s===null?h:h+"[]",c(Q))}),!1}return Ee(f)?!0:(t.append(tt(A,h,i),c(f)),!1)}let p=[],w=Object.assign(dr,{defaultVisitor:l,convertValue:c,isVisitable:Ee});function g(f,h){if(!a.isUndefined(f)){if(p.indexOf(f)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(f),a.forEach(f,function(S,D){(!(a.isUndefined(S)||S===null)&&o.call(t,S,a.isString(D)?D.trim():D,h,w))===!0&&g(S,h?h.concat(D):[D])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return g(e),t}var N=fr;function nt(e){let t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function ot(e,t){this._pairs=[],e&&N(e,this,t)}var it=ot.prototype;it.append=function(t,r){this._pairs.push([t,r])};it.toString=function(t){let r=t?function(n){return t.call(this,n,nt)}:nt;return this._pairs.map(function(o){return r(o[0])+"="+r(o[1])},"").join("&")};var ne=ot;function pr(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function q(e,t,r){if(!t)return e;let n=r&&r.encode||pr,o=r&&r.serialize,i;if(o?i=o(t,r):i=a.isURLSearchParams(t)?t.toString():new ne(t,r).toString(n),i){let s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}var be=class{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(n){n!==null&&t(n)})}},_e=be;var oe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var st=typeof URLSearchParams<"u"?URLSearchParams:ne;var at=typeof FormData<"u"?FormData:null;var ut=typeof Blob<"u"?Blob:null;var mr=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),hr=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),E={isBrowser:!0,classes:{URLSearchParams:st,FormData:at,Blob:ut},isStandardBrowserEnv:mr,isStandardBrowserWebWorkerEnv:hr,protocols:["http","https","file","blob","url","data"]};function Se(e,t){return N(e,new E.classes.URLSearchParams,Object.assign({visitor:function(r,n,o,i){return E.isNode&&a.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function gr(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function yr(e){let t={},r=Object.keys(e),n,o=r.length,i;for(n=0;n<o;n++)i=r[n],t[i]=e[i];return t}function wr(e){function t(r,n,o,i){let s=r[i++],u=Number.isFinite(+s),d=i>=r.length;return s=!s&&a.isArray(o)?o.length:s,d?(a.hasOwnProp(o,s)?o[s]=[o[s],n]:o[s]=n,!u):((!o[s]||!a.isObject(o[s]))&&(o[s]=[]),t(r,n,o[s],i)&&a.isArray(o[s])&&(o[s]=yr(o[s])),!u)}if(a.isFormData(e)&&a.isFunction(e.entries)){let r={};return a.forEachEntry(e,(n,o)=>{t(gr(n),o,r,0)}),r}return null}var ie=wr;var xr={"Content-Type":void 0};function Er(e,t,r){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}var se={transitional:oe,adapter:["xhr","http"],transformRequest:[function(t,r){let n=r.getContentType()||"",o=n.indexOf("application/json")>-1,i=a.isObject(t);if(i&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return o&&o?JSON.stringify(ie(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Se(t,this.formSerializer).toString();if((u=a.isFileList(t))||n.indexOf("multipart/form-data")>-1){let d=this.env&&this.env.FormData;return N(u?{"files[]":t}:t,d&&new d,this.formSerializer)}}return i||o?(r.setContentType("application/json",!1),Er(t)):t}],transformResponse:[function(t){let r=this.transitional||se.transitional,n=r&&r.forcedJSONParsing,o=this.responseType==="json";if(t&&a.isString(t)&&(n&&!this.responseType||o)){let s=!(r&&r.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(u){if(s)throw u.name==="SyntaxError"?m.from(u,m.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:E.classes.FormData,Blob:E.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};a.forEach(["delete","get","head"],function(t){se.headers[t]={}});a.forEach(["post","put","patch"],function(t){se.headers[t]=a.merge(xr)});var k=se;var br=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ct=e=>{let t={},r,n,o;return e&&e.split(` | ||
`).forEach(function(s){o=s.indexOf(":"),r=s.substring(0,o).trim().toLowerCase(),n=s.substring(o+1).trim(),!(!r||t[r]&&br[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};var lt=Symbol("internals");function M(e){return e&&String(e).trim().toLowerCase()}function ae(e){return e===!1||e==null?e:a.isArray(e)?e.map(ae):String(e)}function _r(e){let t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}var Sr=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Re(e,t,r,n,o){if(a.isFunction(n))return n.call(this,t,r);if(o&&(t=r),!!a.isString(t)){if(a.isString(n))return t.indexOf(n)!==-1;if(a.isRegExp(n))return n.test(t)}}function Rr(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function Ar(e,t){let r=a.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(o,i,s){return this[n].call(this,t,o,i,s)},configurable:!0})})}var L=class{constructor(t){t&&this.set(t)}set(t,r,n){let o=this;function i(u,d,c){let l=M(d);if(!l)throw new Error("header name must be a non-empty string");let p=a.findKey(o,l);(!p||o[p]===void 0||c===!0||c===void 0&&o[p]!==!1)&&(o[p||d]=ae(u))}let s=(u,d)=>a.forEach(u,(c,l)=>i(c,l,d));return a.isPlainObject(t)||t instanceof this.constructor?s(t,r):a.isString(t)&&(t=t.trim())&&!Sr(t)?s(ct(t),r):t!=null&&i(r,t,n),this}get(t,r){if(t=M(t),t){let n=a.findKey(this,t);if(n){let o=this[n];if(!r)return o;if(r===!0)return _r(o);if(a.isFunction(r))return r.call(this,o,n);if(a.isRegExp(r))return r.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=M(t),t){let n=a.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Re(this,this[n],n,r)))}return!1}delete(t,r){let n=this,o=!1;function i(s){if(s=M(s),s){let u=a.findKey(n,s);u&&(!r||Re(n,n[u],u,r))&&(delete n[u],o=!0)}}return a.isArray(t)?t.forEach(i):i(t),o}clear(t){let r=Object.keys(this),n=r.length,o=!1;for(;n--;){let i=r[n];(!t||Re(this,this[i],i,t,!0))&&(delete this[i],o=!0)}return o}normalize(t){let r=this,n={};return a.forEach(this,(o,i)=>{let s=a.findKey(n,i);if(s){r[s]=ae(o),delete r[i];return}let u=t?Rr(i):String(i).trim();u!==i&&delete r[i],r[u]=ae(o),n[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){let r=Object.create(null);return a.forEach(this,(n,o)=>{n!=null&&n!==!1&&(r[o]=t&&a.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(` | ||
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){let n=new this(t);return r.forEach(o=>n.set(o)),n}static accessor(t){let n=(this[lt]=this[lt]={accessors:{}}).accessors,o=this.prototype;function i(s){let u=M(s);n[u]||(Ar(o,s),n[u]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};L.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);a.freezeMethods(L.prototype);a.freezeMethods(L);var b=L;function J(e,t){let r=this||k,n=t||r,o=b.from(n.headers),i=n.data;return a.forEach(e,function(u){i=u.call(r,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function V(e){return!!(e&&e.__CANCEL__)}function dt(e,t,r){m.call(this,e??"canceled",m.ERR_CANCELED,t,r),this.name="CanceledError"}a.inherits(dt,m,{__CANCEL__:!0});var P=dt;function Ae(e,t,r){let n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new m("Request failed with status code "+r.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}var ft=E.isStandardBrowserEnv?function(){return{write:function(r,n,o,i,s,u){let d=[];d.push(r+"="+encodeURIComponent(n)),a.isNumber(o)&&d.push("expires="+new Date(o).toGMTString()),a.isString(i)&&d.push("path="+i),a.isString(s)&&d.push("domain="+s),u===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(r){let n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Oe(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ne(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function $(e,t){return e&&!Oe(t)?Ne(e,t):t}var pt=E.isStandardBrowserEnv?function(){let t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function o(i){let s=i;return t&&(r.setAttribute("href",s),s=r.href),r.setAttribute("href",s),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=o(window.location.href),function(s){let u=a.isString(s)?o(s):s;return u.protocol===n.protocol&&u.host===n.host}}():function(){return function(){return!0}}();function Pe(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Or(e,t){e=e||10;let r=new Array(e),n=new Array(e),o=0,i=0,s;return t=t!==void 0?t:1e3,function(d){let c=Date.now(),l=n[i];s||(s=c),r[o]=d,n[o]=c;let p=i,w=0;for(;p!==o;)w+=r[p++],p=p%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-s<t)return;let g=l&&c-l;return g?Math.round(w*1e3/g):void 0}}var mt=Or;function ht(e,t){let r=0,n=mt(50,250);return o=>{let i=o.loaded,s=o.lengthComputable?o.total:void 0,u=i-r,d=n(u),c=i<=s;r=i;let l={loaded:i,total:s,progress:s?i/s:void 0,bytes:u,rate:d||void 0,estimated:d&&s&&c?(s-i)/d:void 0,event:o};l[t?"download":"upload"]=!0,e(l)}}var Nr=typeof XMLHttpRequest<"u",gt=Nr&&function(e){return new Promise(function(r,n){let o=e.data,i=b.from(e.headers).normalize(),s=e.responseType,u;function d(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}a.isFormData(o)&&(E.isStandardBrowserEnv||E.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(e.auth){let g=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(g+":"+f))}let l=$(e.baseURL,e.url);c.open(e.method.toUpperCase(),q(l,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function p(){if(!c)return;let g=b.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),h={data:!s||s==="text"||s==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:g,config:e,request:c};Ae(function(S){r(S),d()},function(S){n(S),d()},h),c=null}if("onloadend"in c?c.onloadend=p:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(p)},c.onabort=function(){c&&(n(new m("Request aborted",m.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new m("Network Error",m.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let f=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",h=e.transitional||oe;e.timeoutErrorMessage&&(f=e.timeoutErrorMessage),n(new m(f,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,c)),c=null},E.isStandardBrowserEnv){let g=(e.withCredentials||pt(l))&&e.xsrfCookieName&&ft.read(e.xsrfCookieName);g&&i.set(e.xsrfHeaderName,g)}o===void 0&&i.setContentType(null),"setRequestHeader"in c&&a.forEach(i.toJSON(),function(f,h){c.setRequestHeader(h,f)}),a.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),s&&s!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",ht(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",ht(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=g=>{c&&(n(!g||g.type?new P(null,e,c):g),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));let w=Pe(l);if(w&&E.protocols.indexOf(w)===-1){n(new m("Unsupported protocol "+w+":",m.ERR_BAD_REQUEST,e));return}c.send(o||null)})};var ue={http:re,xhr:gt};a.forEach(ue,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});var yt={getAdapter:e=>{e=a.isArray(e)?e:[e];let{length:t}=e,r,n;for(let o=0;o<t&&(r=e[o],!(n=a.isString(r)?ue[r.toLowerCase()]:r));o++);if(!n)throw n===!1?new m(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(a.hasOwnProp(ue,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!a.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:ue};function Te(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new P(null,e)}function ce(e){return Te(e),e.headers=b.from(e.headers),e.data=J.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),yt.getAdapter(e.adapter||k.adapter)(e).then(function(n){return Te(e),n.data=J.call(e,e.transformResponse,n),n.headers=b.from(n.headers),n},function(n){return V(n)||(Te(e),n&&n.response&&(n.response.data=J.call(e,e.transformResponse,n.response),n.response.headers=b.from(n.response.headers))),Promise.reject(n)})}var wt=e=>e instanceof b?e.toJSON():e;function O(e,t){t=t||{};let r={};function n(c,l,p){return a.isPlainObject(c)&&a.isPlainObject(l)?a.merge.call({caseless:p},c,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function o(c,l,p){if(a.isUndefined(l)){if(!a.isUndefined(c))return n(void 0,c,p)}else return n(c,l,p)}function i(c,l){if(!a.isUndefined(l))return n(void 0,l)}function s(c,l){if(a.isUndefined(l)){if(!a.isUndefined(c))return n(void 0,c)}else return n(void 0,l)}function u(c,l,p){if(p in t)return n(c,l);if(p in e)return n(void 0,c)}let d={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:u,headers:(c,l)=>o(wt(c),wt(l),!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(l){let p=d[l]||o,w=p(e[l],t[l],l);a.isUndefined(w)&&p!==u||(r[l]=w)}),r}var le="1.4.0";var Ce={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ce[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var xt={};Ce.transitional=function(t,r,n){function o(i,s){return"[Axios v"+le+"] Transitional option '"+i+"'"+s+(n?". "+n:"")}return(i,s,u)=>{if(t===!1)throw new m(o(s," has been removed"+(r?" in "+r:"")),m.ERR_DEPRECATED);return r&&!xt[s]&&(xt[s]=!0,console.warn(o(s," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,s,u):!0}};function Pr(e,t,r){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);let n=Object.keys(e),o=n.length;for(;o-- >0;){let i=n[o],s=t[i];if(s){let u=e[i],d=u===void 0||s(u,i,e);if(d!==!0)throw new m("option "+i+" must be "+d,m.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}}var de={assertOptions:Pr,validators:Ce};var T=de.validators,F=class{constructor(t){this.defaults=t,this.interceptors={request:new _e,response:new _e}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=O(this.defaults,r);let{transitional:n,paramsSerializer:o,headers:i}=r;n!==void 0&&de.assertOptions(n,{silentJSONParsing:T.transitional(T.boolean),forcedJSONParsing:T.transitional(T.boolean),clarifyTimeoutError:T.transitional(T.boolean)},!1),o!=null&&(a.isFunction(o)?r.paramsSerializer={serialize:o}:de.assertOptions(o,{encode:T.function,serialize:T.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let s;s=i&&a.merge(i.common,i[r.method]),s&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),r.headers=b.concat(s,i);let u=[],d=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(d=d&&h.synchronous,u.unshift(h.fulfilled,h.rejected))});let c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let l,p=0,w;if(!d){let f=[ce.bind(this),void 0];for(f.unshift.apply(f,u),f.push.apply(f,c),w=f.length,l=Promise.resolve(r);p<w;)l=l.then(f[p++],f[p++]);return l}w=u.length;let g=r;for(p=0;p<w;){let f=u[p++],h=u[p++];try{g=f(g)}catch(A){h.call(this,A);break}}try{l=ce.call(this,g)}catch(f){return Promise.reject(f)}for(p=0,w=c.length;p<w;)l=l.then(c[p++],c[p++]);return l}getUri(t){t=O(this.defaults,t);let r=$(t.baseURL,t.url);return q(r,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){F.prototype[t]=function(r,n){return this.request(O(n||{},{method:t,url:r,data:(n||{}).data}))}});a.forEach(["post","put","patch"],function(t){function r(n){return function(i,s,u){return this.request(O(u||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}F.prototype[t]=r(),F.prototype[t+"Form"]=r(!0)});var K=F;var De=class e{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});let n=this;this.promise.then(o=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](o);n._listeners=null}),this.promise.then=o=>{let i,s=new Promise(u=>{n.subscribe(u),i=u}).then(o);return s.cancel=function(){n.unsubscribe(i)},s},t(function(i,s,u){n.reason||(n.reason=new P(i,s,u),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;let r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}static source(){let t;return{token:new e(function(o){t=o}),cancel:t}}},Et=De;function Ue(e){return function(r){return e.apply(null,r)}}function je(e){return a.isObject(e)&&e.isAxiosError===!0}var ke={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ke).forEach(([e,t])=>{ke[t]=e});var bt=ke;function _t(e){let t=new K(e),r=v(K.prototype.request,t);return a.extend(r,K.prototype,t,{allOwnKeys:!0}),a.extend(r,t,null,{allOwnKeys:!0}),r.create=function(o){return _t(O(e,o))},r}var y=_t(k);y.Axios=K;y.CanceledError=P;y.CancelToken=Et;y.isCancel=V;y.VERSION=le;y.toFormData=N;y.AxiosError=m;y.Cancel=y.CanceledError;y.all=function(t){return Promise.all(t)};y.spread=Ue;y.isAxiosError=je;y.mergeConfig=O;y.AxiosHeaders=b;y.formToJSON=e=>ie(a.isHTMLForm(e)?new FormData(e):e);y.HttpStatusCode=bt;y.default=y;var I=y;var{Axios:pi,AxiosError:mi,CanceledError:hi,isCancel:gi,CancelToken:yi,VERSION:wi,all:xi,Cancel:Ei,isAxiosError:bi,spread:_i,toFormData:Si,AxiosHeaders:Ri,HttpStatusCode:Ai,formToJSON:Oi,mergeConfig:Ni}=I;var fe,Tr=new Uint8Array(16);function Le(){if(!fe&&(fe=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!fe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return fe(Tr)}var x=[];for(let e=0;e<256;++e)x.push((e+256).toString(16).slice(1));function St(e,t=0){return(x[e[t+0]]+x[e[t+1]]+x[e[t+2]]+x[e[t+3]]+"-"+x[e[t+4]]+x[e[t+5]]+"-"+x[e[t+6]]+x[e[t+7]]+"-"+x[e[t+8]]+x[e[t+9]]+"-"+x[e[t+10]]+x[e[t+11]]+x[e[t+12]]+x[e[t+13]]+x[e[t+14]]+x[e[t+15]]).toLowerCase()}var Cr=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Fe={randomUUID:Cr};function Dr(e,t,r){if(Fe.randomUUID&&!t&&!e)return Fe.randomUUID();e=e||{};let n=e.random||(e.rng||Le)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){r=r||0;for(let o=0;o<16;++o)t[r+o]=n[o];return t}return St(n)}var pe=Dr;var Ur={makeAxios:e=>I.create({...e}),getRepoStatus:async()=>{},getPastNAncestors:async()=>[],getEnv:e=>{}},B=Ur;var G={current_project:null,current_experiment:null},X=null,me=null,qe=null,Ot=null,Rt=!1,jr="_xact_id",he=class{constructor(t){this.base_url=t,this.token=null,this.session=null,this._reset()}async ping(){try{let t=await this.get("ping");return W===null&&(W=t.data),t.status===200}catch{return!1}}make_long_lived(){this._reset()}set_token(t){t=t.trim(),this.token=t,this._reset()}_reset(){let t={};this.token&&(t.Authorization=`Bearer ${this.token}`),this.session=B.makeAxios({headers:t})}async get(t,r=void 0){return await this.session.get(ve(this.base_url,t),{params:r})}async post(t,r=void 0){return await this.session.post(ve(this.base_url,t),r)}async get_json(t,r=void 0,n=0){let o=n+1;for(let i=0;i<o;i++)try{return(await this.get(`${t}`,r)).data}catch(s){if(i<o-1){console.log(`Retrying API request ${t} ${r} ${s.status} ${s.text}`);continue}throw s}}async post_json(t,r=void 0){return(await this.post(`${t}`,r)).data}},Ie=null;function Me(){return Ie||(Ie=new he(X)),Ie}var Be=null;function C(){return Be||(Be=new he(Ot)),Be}var W=null;async function Nt(){return W===null&&(W=await C().get_json("ping")),W}var At=class{constructor(t,r,n){this.name=t,this.id=r,this.org_id=n}};var ge=class{constructor(){this.items=[];this.active_flush=Promise.resolve([]);this.active_flush_resolved=!0}log(t){this.items.push(...t),this.active_flush_resolved&&(this.active_flush_resolved=!1,this.active_flush=this.flush_once())}async flush_once(){this.active_flush_resolved=!1;let t=this.items;this.items=[];let r=[];return t.length>0&&(r=(await C().post_json("logs",t)).data),this.items.length>0?this.active_flush=this.flush_once():this.active_flush_resolved=!0,r}async flush(){for(;await this.active_flush,!this.active_flush_resolved;);}};async function $i(e,t={}){let{experiment:r,description:n,dataset:o,baseExperiment:i,update:s,apiUrl:u,apiKey:d,orgName:c,disableCache:l}=t||{};await Pt({orgName:c,disableCache:l,apiKey:d,apiUrl:u});let p=await Lr(e,{experimentName:r,description:n,dataset:o,update:s,baseExperiment:i});return G.current_experiment=p,p}async function Ki(e,t={}){let{dataset:r,description:n,version:o,apiUrl:i,apiKey:s,orgName:u,disableCache:d}=t||{};return await Pt({orgName:u,disableCache:d,apiKey:s,apiUrl:i}),await Fr(e,{name:r,description:n,version:o})}async function Pt(e={}){let{apiUrl:t=B.getEnv("BRAINTRUST_API_URL")||"https://www.braintrustdata.com",apiKey:r=B.getEnv("BRAINTRUST_API_KEY"),orgName:n=void 0,disableCache:o=!1,forceLogin:i=!1}=e||{};if(Rt&&!i)return;X=t;let s=null,u=!1,d=null;if(r!==void 0){let l=(await I.post(ve(X,"/api/apikey/login"),{token:r})).data;kr(l.org_info,n),d=C(),d.set_token(r),u=await d.ping()}else throw new Error("Please specify an api key. Token based login is not yet implemented in the JS client.");if(!d)throw new Error("Conn should be set at this point (a bug)");u||await d.get("ping"),d.make_long_lived(),Me().set_token(r),Rt=!0}function Wi(e){if(!G.current_experiment)throw new Error("Not initialized. Please call init() first");return G.current_experiment.log(e)}async function Gi(e={}){if(!G.current_experiment)throw new Error("Not initialized. Please call init() first");return await G.current_experiment.summarize(e)}function kr(e,t){if(e.length===0)throw new Error("This user is not part of any organizations.");for(let r of e)if(t===void 0||r.name===t){me=r.id,qe=r.name,Ot=r.api_url;break}if(me===void 0)throw new Error(`Organization ${t} not found. Must be one of ${e.map(r=>r.name).join(", ")}`)}function ve(...e){return e.map(t=>t.replace(/^\//,"")).join("/")}async function Lr(e,{experimentName:t,description:r,dataset:n,update:o,baseExperiment:i}={experimentName:void 0,description:void 0,baseExperiment:void 0}){let s={project_name:e,org_id:me};t&&(s.experiment_name=t),r&&(s.description=r),o&&(s.update=o);let u=await B.getRepoStatus();u&&(s.repo_info=u),i?s.base_experiment=i:s.ancestor_commits=await B.getPastNAncestors(),n!==void 0&&(s.dataset_id=n.id,s.dataset_version=await n.version());let d=await Me().post_json("api/experiment/register",s),c=d.project,l=d.experiment,p=(await Nt()).id;return new He(c,l.id,l.name,p,n)}var He=class{constructor(t,r,n,o,i){this.project=t,this.id=r,this.name=n,this.user_id=o,this.dataset=i,this.logger=new ge}log({input:t,output:r,expected:n,scores:o,metadata:i,id:s,datasetRecordId:u,inputs:d}){if(t===void 0&&d===void 0)throw new Error("Either input or inputs (deprecated) must be specified. Prefer input.");if(t!==void 0&&d!==void 0)throw new Error("Only one of input or inputs (deprecated) can be specified. Prefer input.");for(let[l,p]of Object.entries(o)){if(typeof l!="string")throw new Error("score names must be strings");if(typeof p!="number")throw new Error("score values must be numbers");if(p<0||p>1)throw new Error("score values must be between 0 and 1")}if(i!==void 0){for(let l of Object.keys(i))if(typeof l!="string")throw new Error("metadata keys must be strings")}if(this.dataset&&u===void 0)throw new Error("datasetRecordId must be specified when using a dataset");if(!this.dataset&&u!==void 0)throw new Error("datasetRecordId cannot be specified when not using a dataset");let c={id:s||pe(),inputs:t??d,output:r,expected:n,scores:o,project_id:this.project.id,experiment_id:this.id,user_id:this.user_id,created:new Date().toISOString(),dataset_record_id:u,metadata:i};return this.logger.log([c]),c.id}async summarize(t={}){let{summarizeScores:r=!0,comparisonExperimentId:n=void 0}=t||{};await this.logger.flush();let o=`${X}/app/${encodeURIComponent(qe)}/p/${encodeURIComponent(this.project.name)}`,i=`${o}/${encodeURIComponent(this.name)}`,s,u;if(r){if(n===void 0){let l=(await C().get("/crud/base_experiments",{id:this.id})).data;l.length>0&&(n=l[0].base_exp_id,u=l[0].base_exp_name)}n!==void 0&&(s=await C().get_json("/experiment-comparison",{experiment_id:this.id,base_experiment_id:n},3))}return{projectName:this.project.name,experimentName:this.name,projectUrl:o,experimentUrl:i,comparisonExperimentName:u,scores:s}}};async function Fr(e,{name:t,description:r,version:n}={}){let o={org_id:me,project_name:e,dataset_name:t,description:r},i=await Me().post_json("api/dataset/register",o),s=i.project,u=i.dataset,d=(await Nt()).id;return new ze(s,u.id,u.name,d,n)}var ze=class{constructor(t,r,n,o,i){this._fetchedData=void 0;this.project=t,this.id=r,this.name=n,this.user_id=o,this.pinnedVersion=i,this.logger=new ge}insert({input:t,output:r,metadata:n,id:o}){if(n!==void 0){for(let s of Object.keys(n))if(typeof s!="string")throw new Error("metadata keys must be strings")}let i={id:o||pe(),inputs:t,output:r,project_id:this.project.id,dataset_id:this.id,user_id:this.user_id,created:new Date().toISOString(),metadata:n};return this.logger.log([i]),i.id}delete(t){let r=this.user_id,n={id:t,project_id:this.project.id,dataset_id:this.id,user_id:r,created:new Date().toISOString(),_object_delete:!0};return this.logger.log([n]),n.id}async summarize(t={}){let{summarizeData:r=!0}=t||{};await this.logger.flush();let n=`${X}/app/${encodeURIComponent(qe)}/p/${encodeURIComponent(this.project.name)}`,o=`${n}/d/${encodeURIComponent(this.name)}`,i;return r&&(i=await C().get_json("dataset-summary",{dataset_id:this.id},3)),{projectName:this.project.name,datasetName:this.name,projectUrl:n,datasetUrl:o,dataSummary:i}}async*fetch(){let t=await this.fetchedData();for(let r of t)yield{id:r.id,input:r.input&&JSON.parse(r.input),output:r.input&&JSON.parse(r.output),metadata:r.metadata&&JSON.parse(r.metadata)};this.clearCache()}[Symbol.asyncIterator](){return this.fetch()}async fetchedData(){if(this._fetchedData===void 0){let r=await(await C().get("object/dataset",{id:this.id,fmt:"json",version:this.pinnedVersion})).data;this._fetchedData=r.split(` | ||
`).filter(n=>n.trim()!=="").map(n=>JSON.parse(n))}return this._fetchedData||[]}clearCache(){this._fetchedData=void 0}async version(){if(this.pinnedVersion!==void 0)return this.pinnedVersion;{let t=await this.fetchedData(),r;for(let n of t){let o=n[jr];(r===void 0||(o??o>r))&&(r=o)}return r}}};export{ze as Dataset,He as Experiment,At as Project,$i as init,Ki as initDataset,Wi as log,Pt as login,Gi as summarize}; |
@@ -183,8 +183,6 @@ export declare class Project { | ||
* @param event.id (Optional) a unique identifier for the event. If you don't provide one, Braintrust will generate one for you. | ||
* @param event.allowLarge: (Optional) Allow large objects (greater than 64KB) to be uploaded. Proceed with caution, as they may cause issues with the | ||
* upload pipeline or be truncated. | ||
* @param event.inputs (Deprecated) the same as `input` (will be removed in a future version) | ||
* @returns The `id` of the logged event. | ||
*/ | ||
log({ input, output, expected, scores, metadata, id, datasetRecordId, allowLarge, inputs, }: { | ||
log({ input, output, expected, scores, metadata, id, datasetRecordId, inputs, }: { | ||
readonly input?: unknown; | ||
@@ -197,3 +195,2 @@ readonly output: unknown; | ||
readonly datasetRecordId?: string; | ||
readonly allowLarge?: boolean; | ||
readonly inputs?: unknown; | ||
@@ -242,7 +239,5 @@ }): string; | ||
* @param event.id (Optional) a unique identifier for the event. If you don't provide one, Braintrust will generate one for you. | ||
* @param event.allowLarge (Optional) Allow large objects (greater than 64KB) to be uploaded. Proceed with caution, as they may cause issues with the | ||
* upload pipeline or be truncated. | ||
* @returns The `id` of the logged record. | ||
*/ | ||
insert({ input, output, metadata, id, allowLarge, }: { | ||
insert({ input, output, metadata, id, }: { | ||
readonly input?: unknown; | ||
@@ -252,3 +247,2 @@ readonly output: unknown; | ||
readonly id?: string; | ||
readonly allowLarge?: boolean; | ||
}): string; | ||
@@ -255,0 +249,0 @@ delete(id: string): string; |
{ | ||
"name": "braintrust", | ||
"version": "0.0.42", | ||
"version": "0.0.43", | ||
"description": "SDK for integrating Braintrust", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1511030
47692