UNPKG

langsmith

Version:

Client library to connect to the LangSmith Observability and Evaluation Platform.

759 lines (758 loc) 33.3 kB
"use strict"; // @ts-nocheck // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _Langsmith_instances, _a, _Langsmith_encoder, _Langsmith_baseURLOverridden; Object.defineProperty(exports, "__esModule", { value: true }); exports.Langsmith = void 0; const uuid_js_1 = require("./internal/utils/uuid.cjs"); const values_js_1 = require("./internal/utils/values.cjs"); const sleep_js_1 = require("./internal/utils/sleep.cjs"); const errors_js_1 = require("./internal/errors.cjs"); const detect_platform_js_1 = require("./internal/detect-platform.cjs"); const Shims = __importStar(require("./internal/shims.cjs")); const Opts = __importStar(require("./internal/request-options.cjs")); const query_js_1 = require("./internal/utils/query.cjs"); const version_js_1 = require("./version.cjs"); const Errors = __importStar(require("./core/error.cjs")); const Pagination = __importStar(require("./core/pagination.cjs")); const Uploads = __importStar(require("./core/uploads.cjs")); const API = __importStar(require("./resources/index.cjs")); const api_promise_js_1 = require("./core/api-promise.cjs"); const info_js_1 = require("./resources/info.cjs"); const issues_js_1 = require("./resources/issues.cjs"); const online_evaluators_js_1 = require("./resources/online-evaluators.cjs"); const runs_js_1 = require("./resources/runs.cjs"); const threads_js_1 = require("./resources/threads.cjs"); const traces_js_1 = require("./resources/traces.cjs"); const datasets_js_1 = require("./resources/datasets/datasets.cjs"); const sandboxes_js_1 = require("./resources/sandboxes/sandboxes.cjs"); const headers_js_1 = require("./internal/headers.cjs"); const env_js_1 = require("./internal/utils/env.cjs"); const log_js_1 = require("./internal/utils/log.cjs"); const values_js_2 = require("./internal/utils/values.cjs"); /** * API Client for interfacing with the LangChain API. */ class Langsmith { /** * API Client for interfacing with the LangChain API. * * @param {string | null | undefined} [opts.apiKey=process.env['LANGSMITH_API_KEY'] ?? null] * @param {string | null | undefined} [opts.tenantID=process.env['LANGSMITH_TENANT_ID'] ?? null] * @param {string} [opts.baseURL=process.env['LANGCHAIN_BASE_URL'] ?? https://api.smith.langchain.com/] - Override the default base URL for the API. * @param {number} [opts.timeout=1.5 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls. * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API. * @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API. */ constructor({ baseURL = (0, env_js_1.readEnv)('LANGCHAIN_BASE_URL'), apiKey = (0, env_js_1.readEnv)('LANGSMITH_API_KEY') ?? null, tenantID = (0, env_js_1.readEnv)('LANGSMITH_TENANT_ID') ?? null, ...opts } = {}) { _Langsmith_instances.add(this); Object.defineProperty(this, "apiKey", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "tenantID", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "baseURL", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "maxRetries", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "timeout", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "logger", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "logLevel", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "fetchOptions", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "fetch", { enumerable: true, configurable: true, writable: true, value: void 0 }); _Langsmith_encoder.set(this, void 0); Object.defineProperty(this, "idempotencyHeader", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "_options", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "datasets", { enumerable: true, configurable: true, writable: true, value: new API.Datasets(this) }); Object.defineProperty(this, "runs", { enumerable: true, configurable: true, writable: true, value: new API.Runs(this) }); Object.defineProperty(this, "threads", { enumerable: true, configurable: true, writable: true, value: new API.Threads(this) }); Object.defineProperty(this, "traces", { enumerable: true, configurable: true, writable: true, value: new API.Traces(this) }); Object.defineProperty(this, "onlineEvaluators", { enumerable: true, configurable: true, writable: true, value: new API.OnlineEvaluators(this) }); Object.defineProperty(this, "info", { enumerable: true, configurable: true, writable: true, value: new API.Info(this) }); Object.defineProperty(this, "issues", { enumerable: true, configurable: true, writable: true, value: new API.Issues(this) }); Object.defineProperty(this, "sandboxes", { enumerable: true, configurable: true, writable: true, value: new API.Sandboxes(this) }); const options = { apiKey, tenantID, ...opts, baseURL: baseURL || `https://api.smith.langchain.com/`, }; this.baseURL = options.baseURL; this.timeout = options.timeout ?? _a.DEFAULT_TIMEOUT /* 1.5 minutes */; this.logger = options.logger ?? console; const defaultLogLevel = 'warn'; // Set default logLevel early so that we can log a warning in parseLogLevel. this.logLevel = defaultLogLevel; this.logLevel = (0, log_js_1.parseLogLevel)(options.logLevel, 'ClientOptions.logLevel', this) ?? (0, log_js_1.parseLogLevel)((0, env_js_1.readEnv)('LANGCHAIN_LOG'), "process.env['LANGCHAIN_LOG']", this) ?? defaultLogLevel; this.fetchOptions = options.fetchOptions; this.maxRetries = options.maxRetries ?? 2; this.fetch = options.fetch ?? Shims.getDefaultFetch(); __classPrivateFieldSet(this, _Langsmith_encoder, Opts.FallbackEncoder, "f"); const customHeadersEnv = (0, env_js_1.readEnv)('LANGCHAIN_CUSTOM_HEADERS'); if (customHeadersEnv) { const parsed = {}; for (const line of customHeadersEnv.split('\n')) { const colon = line.indexOf(':'); if (colon >= 0) { parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim(); } } options.defaultHeaders = { ...parsed, ...options.defaultHeaders }; } this._options = options; this.apiKey = apiKey; this.tenantID = tenantID; } /** * Create a new client instance re-using the same options given to the current client with optional overriding. */ withOptions(options) { const client = new this.constructor({ ...this._options, baseURL: this.baseURL, maxRetries: this.maxRetries, timeout: this.timeout, logger: this.logger, logLevel: this.logLevel, fetch: this.fetch, fetchOptions: this.fetchOptions, apiKey: this.apiKey, tenantID: this.tenantID, ...options, }); return client; } defaultQuery() { return this._options.defaultQuery; } validateHeaders({ values, nulls }) { if (this.apiKey && values.get('x-api-key')) { return; } if (nulls.has('x-api-key')) { return; } if (this.tenantID && values.get('x-tenant-id')) { return; } if (nulls.has('x-tenant-id')) { return; } throw new Error('Could not resolve authentication method. Expected either apiKey or tenantID to be set. Or for one of the "X-API-Key" or "X-Tenant-Id" headers to be explicitly omitted'); } async authHeaders(opts) { return (0, headers_js_1.buildHeaders)([await this.apiKeyAuth(opts), await this.tenantIDAuth(opts)]); } async apiKeyAuth(opts) { if (this.apiKey == null) { return undefined; } return (0, headers_js_1.buildHeaders)([{ 'X-API-Key': this.apiKey }]); } async tenantIDAuth(opts) { if (this.tenantID == null) { return undefined; } return (0, headers_js_1.buildHeaders)([{ 'X-Tenant-Id': this.tenantID }]); } stringifyQuery(query) { return (0, query_js_1.stringifyQuery)(query); } getUserAgent() { return `${this.constructor.name}/JS ${version_js_1.VERSION}`; } defaultIdempotencyKey() { return `stainless-node-retry-${(0, uuid_js_1.uuid4)()}`; } makeStatusError(status, error, message, headers) { return Errors.APIError.generate(status, error, message, headers); } buildURL(path, query, defaultBaseURL) { const baseURL = (!__classPrivateFieldGet(this, _Langsmith_instances, "m", _Langsmith_baseURLOverridden).call(this) && defaultBaseURL) || this.baseURL; const url = (0, values_js_1.isAbsoluteURL)(path) ? new URL(path) : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path)); const defaultQuery = this.defaultQuery(); const pathQuery = Object.fromEntries(url.searchParams); if (!(0, values_js_2.isEmptyObj)(defaultQuery) || !(0, values_js_2.isEmptyObj)(pathQuery)) { query = { ...pathQuery, ...defaultQuery, ...query }; } if (typeof query === 'object' && query && !Array.isArray(query)) { url.search = this.stringifyQuery(query); } return url.toString(); } /** * Used as a callback for mutating the given `FinalRequestOptions` object. */ async prepareOptions(options) { } /** * Used as a callback for mutating the given `RequestInit` object. * * This is useful for cases where you want to add certain headers based off of * the request properties, e.g. `method` or `url`. */ async prepareRequest(request, { url, options }) { } get(path, opts) { return this.methodRequest('get', path, opts); } post(path, opts) { return this.methodRequest('post', path, opts); } patch(path, opts) { return this.methodRequest('patch', path, opts); } put(path, opts) { return this.methodRequest('put', path, opts); } delete(path, opts) { return this.methodRequest('delete', path, opts); } methodRequest(method, path, opts) { return this.request(Promise.resolve(opts).then((opts) => { return { method, path, ...opts }; })); } request(options, remainingRetries = null) { return new api_promise_js_1.APIPromise(this, this.makeRequest(options, remainingRetries, undefined)); } async makeRequest(optionsInput, retriesRemaining, retryOfRequestLogID) { const options = await optionsInput; const maxRetries = options.maxRetries ?? this.maxRetries; if (retriesRemaining == null) { retriesRemaining = maxRetries; } await this.prepareOptions(options); const { req, url, timeout } = await this.buildRequest(options, { retryCount: maxRetries - retriesRemaining, }); await this.prepareRequest(req, { url, options }); /** Not an API request ID, just for correlating local log entries. */ const requestLogID = 'log_' + ((Math.random() * (1 << 24)) | 0).toString(16).padStart(6, '0'); const retryLogStr = retryOfRequestLogID === undefined ? '' : `, retryOf: ${retryOfRequestLogID}`; const startTime = Date.now(); (0, log_js_1.loggerFor)(this).debug(`[${requestLogID}] sending request`, (0, log_js_1.formatRequestDetails)({ retryOfRequestLogID, method: options.method, url, options, headers: req.headers, })); if (options.signal?.aborted) { throw new Errors.APIUserAbortError(); } const controller = new AbortController(); const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(errors_js_1.castToError); const headersTime = Date.now(); if (response instanceof globalThis.Error) { const retryMessage = `retrying, ${retriesRemaining} attempts remaining`; if (options.signal?.aborted) { throw new Errors.APIUserAbortError(); } // detect native connection timeout errors // deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)" // undici throws "TypeError: fetch failed" with cause "ConnectTimeoutError: Connect Timeout Error (attempted address: example:443, timeout: 1ms)" // others do not provide enough information to distinguish timeouts from other connection errors const isTimeout = (0, errors_js_1.isAbortError)(response) || /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : '')); if (retriesRemaining) { (0, log_js_1.loggerFor)(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`); (0, log_js_1.loggerFor)(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, (0, log_js_1.formatRequestDetails)({ retryOfRequestLogID, url, durationMs: headersTime - startTime, message: response.message, })); return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID); } (0, log_js_1.loggerFor)(this).info(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`); (0, log_js_1.loggerFor)(this).debug(`[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, (0, log_js_1.formatRequestDetails)({ retryOfRequestLogID, url, durationMs: headersTime - startTime, message: response.message, })); if (isTimeout) { throw new Errors.APIConnectionTimeoutError(); } throw new Errors.APIConnectionError({ cause: response }); } const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${response.ok ? 'succeeded' : 'failed'} with status ${response.status} in ${headersTime - startTime}ms`; if (!response.ok) { const shouldRetry = await this.shouldRetry(response); if (retriesRemaining && shouldRetry) { const retryMessage = `retrying, ${retriesRemaining} attempts remaining`; // We don't need the body of this response. await Shims.CancelReadableStream(response.body); (0, log_js_1.loggerFor)(this).info(`${responseInfo} - ${retryMessage}`); (0, log_js_1.loggerFor)(this).debug(`[${requestLogID}] response error (${retryMessage})`, (0, log_js_1.formatRequestDetails)({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, durationMs: headersTime - startTime, })); return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, response.headers); } const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`; (0, log_js_1.loggerFor)(this).info(`${responseInfo} - ${retryMessage}`); const errText = await response.text().catch((err) => (0, errors_js_1.castToError)(err).message); const errJSON = (0, values_js_1.safeJSON)(errText); const errMessage = errJSON ? undefined : errText; (0, log_js_1.loggerFor)(this).debug(`[${requestLogID}] response error (${retryMessage})`, (0, log_js_1.formatRequestDetails)({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, message: errMessage, durationMs: Date.now() - startTime, })); const err = this.makeStatusError(response.status, errJSON, errMessage, response.headers); throw err; } (0, log_js_1.loggerFor)(this).info(responseInfo); (0, log_js_1.loggerFor)(this).debug(`[${requestLogID}] response start`, (0, log_js_1.formatRequestDetails)({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, durationMs: headersTime - startTime, })); return { response, options, controller, requestLogID, retryOfRequestLogID, startTime }; } getAPIList(path, Page, opts) { return this.requestAPIList(Page, opts && 'then' in opts ? opts.then((opts) => ({ method: 'get', path, ...opts })) : { method: 'get', path, ...opts }); } requestAPIList(Page, options) { const request = this.makeRequest(options, null, undefined); return new Pagination.PagePromise(this, request, Page); } async fetchWithTimeout(url, init, ms, controller) { const { signal, method, ...options } = init || {}; const abort = this._makeAbort(controller); if (signal) signal.addEventListener('abort', abort, { once: true }); const timeout = setTimeout(abort, ms); const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) || (typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body); const fetchOptions = { signal: controller.signal, ...(isReadableBody ? { duplex: 'half' } : {}), method: 'GET', ...options, }; if (method) { // Custom methods like 'patch' need to be uppercased // See https://github.com/nodejs/undici/issues/2294 fetchOptions.method = method.toUpperCase(); } try { // use undefined this binding; fetch errors if bound to something else in browser/cloudflare return await this.fetch.call(undefined, url, fetchOptions); } finally { clearTimeout(timeout); } } async shouldRetry(response) { // Note this is not a standard header. const shouldRetryHeader = response.headers.get('x-should-retry'); // If the server explicitly says whether or not to retry, obey. if (shouldRetryHeader === 'true') return true; if (shouldRetryHeader === 'false') return false; // Retry on request timeouts. if (response.status === 408) return true; // Retry on lock timeouts. if (response.status === 409) return true; // Retry on rate limits. if (response.status === 429) return true; // Retry internal errors. if (response.status >= 500) return true; return false; } async retryRequest(options, retriesRemaining, requestLogID, responseHeaders) { let timeoutMillis; // Note the `retry-after-ms` header may not be standard, but is a good idea and we'd like proactive support for it. const retryAfterMillisHeader = responseHeaders?.get('retry-after-ms'); if (retryAfterMillisHeader) { const timeoutMs = parseFloat(retryAfterMillisHeader); if (!Number.isNaN(timeoutMs)) { timeoutMillis = timeoutMs; } } // About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After const retryAfterHeader = responseHeaders?.get('retry-after'); if (retryAfterHeader && !timeoutMillis) { const timeoutSeconds = parseFloat(retryAfterHeader); if (!Number.isNaN(timeoutSeconds)) { timeoutMillis = timeoutSeconds * 1000; } else { timeoutMillis = Date.parse(retryAfterHeader) - Date.now(); } } // If the API asks us to wait a certain amount of time, just do what it // says, but otherwise calculate a default if (timeoutMillis === undefined) { const maxRetries = options.maxRetries ?? this.maxRetries; timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries); } await (0, sleep_js_1.sleep)(timeoutMillis); return this.makeRequest(options, retriesRemaining - 1, requestLogID); } calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries) { const initialRetryDelay = 0.5; const maxRetryDelay = 16.0; const numRetries = maxRetries - retriesRemaining; // Apply exponential backoff, but not more than the max. const sleepSeconds = Math.min(initialRetryDelay * Math.pow(2, numRetries), maxRetryDelay); // Apply some jitter, take up to at most 25 percent of the retry time. const jitter = 1 - Math.random() * 0.25; return sleepSeconds * jitter * 1000; } async buildRequest(inputOptions, { retryCount = 0 } = {}) { const options = { ...inputOptions }; const { method, path, query, defaultBaseURL } = options; const url = this.buildURL(path, query, defaultBaseURL); if ('timeout' in options) (0, values_js_1.validatePositiveInteger)('timeout', options.timeout); options.timeout = options.timeout ?? this.timeout; const { bodyHeaders, body } = this.buildBody({ options }); const reqHeaders = await this.buildHeaders({ options: inputOptions, method, bodyHeaders, retryCount }); const req = { method, headers: reqHeaders, ...(options.signal && { signal: options.signal }), ...(globalThis.ReadableStream && body instanceof globalThis.ReadableStream && { duplex: 'half' }), ...(body && { body }), ...(this.fetchOptions ?? {}), ...(options.fetchOptions ?? {}), }; return { req, url, timeout: options.timeout }; } async buildHeaders({ options, method, bodyHeaders, retryCount, }) { let idempotencyHeaders = {}; if (this.idempotencyHeader && method !== 'get') { if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey(); idempotencyHeaders[this.idempotencyHeader] = options.idempotencyKey; } const headers = (0, headers_js_1.buildHeaders)([ idempotencyHeaders, { Accept: 'application/json', 'User-Agent': this.getUserAgent(), 'X-Stainless-Retry-Count': String(retryCount), ...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}), ...(0, detect_platform_js_1.getPlatformHeaders)(), }, await this.authHeaders(options), this._options.defaultHeaders, bodyHeaders, options.headers, ]); this.validateHeaders(headers); return headers.values; } _makeAbort(controller) { // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure // would capture all request options, and cause a memory leak. return () => controller.abort(); } buildBody({ options: { body, headers: rawHeaders } }) { if (!body) { return { bodyHeaders: undefined, body: undefined }; } const headers = (0, headers_js_1.buildHeaders)([rawHeaders]); if ( // Pass raw type verbatim ArrayBuffer.isView(body) || body instanceof ArrayBuffer || body instanceof DataView || (typeof body === 'string' && // Preserve legacy string encoding behavior for now headers.values.has('content-type')) || // `Blob` is superset of `File` (globalThis.Blob && body instanceof globalThis.Blob) || // `FormData` -> `multipart/form-data` body instanceof FormData || // `URLSearchParams` -> `application/x-www-form-urlencoded` body instanceof URLSearchParams || // Send chunked stream (each chunk has own `length`) (globalThis.ReadableStream && body instanceof globalThis.ReadableStream)) { return { bodyHeaders: undefined, body: body }; } else if (typeof body === 'object' && (Symbol.asyncIterator in body || (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))) { return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body) }; } else if (typeof body === 'object' && headers.values.get('content-type') === 'application/x-www-form-urlencoded') { return { bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' }, body: this.stringifyQuery(body), }; } else { return __classPrivateFieldGet(this, _Langsmith_encoder, "f").call(this, { body, headers }); } } } exports.Langsmith = Langsmith; _a = Langsmith, _Langsmith_encoder = new WeakMap(), _Langsmith_instances = new WeakSet(), _Langsmith_baseURLOverridden = function _Langsmith_baseURLOverridden() { return this.baseURL !== 'https://api.smith.langchain.com/'; }; Object.defineProperty(Langsmith, "Langsmith", { enumerable: true, configurable: true, writable: true, value: _a }); Object.defineProperty(Langsmith, "DEFAULT_TIMEOUT", { enumerable: true, configurable: true, writable: true, value: 90000 }); // 1.5 minutes Object.defineProperty(Langsmith, "LangsmithError", { enumerable: true, configurable: true, writable: true, value: Errors.LangsmithError }); Object.defineProperty(Langsmith, "APIError", { enumerable: true, configurable: true, writable: true, value: Errors.APIError }); Object.defineProperty(Langsmith, "APIConnectionError", { enumerable: true, configurable: true, writable: true, value: Errors.APIConnectionError }); Object.defineProperty(Langsmith, "APIConnectionTimeoutError", { enumerable: true, configurable: true, writable: true, value: Errors.APIConnectionTimeoutError }); Object.defineProperty(Langsmith, "APIUserAbortError", { enumerable: true, configurable: true, writable: true, value: Errors.APIUserAbortError }); Object.defineProperty(Langsmith, "NotFoundError", { enumerable: true, configurable: true, writable: true, value: Errors.NotFoundError }); Object.defineProperty(Langsmith, "ConflictError", { enumerable: true, configurable: true, writable: true, value: Errors.ConflictError }); Object.defineProperty(Langsmith, "RateLimitError", { enumerable: true, configurable: true, writable: true, value: Errors.RateLimitError }); Object.defineProperty(Langsmith, "BadRequestError", { enumerable: true, configurable: true, writable: true, value: Errors.BadRequestError }); Object.defineProperty(Langsmith, "AuthenticationError", { enumerable: true, configurable: true, writable: true, value: Errors.AuthenticationError }); Object.defineProperty(Langsmith, "InternalServerError", { enumerable: true, configurable: true, writable: true, value: Errors.InternalServerError }); Object.defineProperty(Langsmith, "PermissionDeniedError", { enumerable: true, configurable: true, writable: true, value: Errors.PermissionDeniedError }); Object.defineProperty(Langsmith, "UnprocessableEntityError", { enumerable: true, configurable: true, writable: true, value: Errors.UnprocessableEntityError }); Object.defineProperty(Langsmith, "toFile", { enumerable: true, configurable: true, writable: true, value: Uploads.toFile }); Langsmith.Datasets = datasets_js_1.Datasets; Langsmith.Runs = runs_js_1.Runs; Langsmith.Threads = threads_js_1.Threads; Langsmith.Traces = traces_js_1.Traces; Langsmith.OnlineEvaluators = online_evaluators_js_1.OnlineEvaluators; Langsmith.Info = info_js_1.Info; Langsmith.Issues = issues_js_1.Issues; Langsmith.Sandboxes = sandboxes_js_1.Sandboxes;