// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import type { RequestInit, RequestInfo, BodyInit } from './internal/builtin-types'; import type { HTTPMethod, PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from './internal/types'; import { uuid4 } from './internal/utils/uuid'; import { validatePositiveInteger, isAbsoluteURL, safeJSON } from './internal/utils/values'; import { sleep } from './internal/utils/sleep'; export type { Logger, LogLevel } from './internal/utils/log'; import { castToError, isAbortError } from './internal/errors'; import type { APIResponseProps } from './internal/parse'; import { getPlatformHeaders } from './internal/detect-platform'; import * as Shims from './internal/shims'; import * as Opts from './internal/request-options'; import { stringifyQuery } from './internal/utils/query'; import { VERSION } from './version'; import * as Errors from './core/error'; import * as Uploads from './core/uploads'; import * as API from './resources/index'; import { APIPromise } from './core/api-promise'; import { Autosuggest, AutosuggestSuggestParams, AutosuggestSuggestResponse } from './resources/autosuggest'; import { ChatbotItemV2, ChatbotListParams, ChatbotListResponse, ChatbotRetrieveFiltersParams, ChatbotRetrieveFiltersResponse, Chatbots, ClickBehaviour, DisplayType, } from './resources/chatbots'; import { Company, CompanyListParams, CompanyListResponse, CompanyRetrieveMembersParams, CompanyRetrieveMembersResponse, CompanyRetrieveParams, } from './resources/company'; import { ComponentRunParams, ComponentRunResponse, Components } from './resources/components'; import { ConnectorConnectParams, ConnectorConnectResponse, ConnectorDisconnectParams, ConnectorDisconnectResponse, ConnectorListParams, ConnectorListResponse, ConnectorRetrieveParams, ConnectorRetrieveResponse, ConnectorStatus, Connectors, } from './resources/connectors'; import { DeepResearch, DeepResearchGenerateParams, DeepResearchGenerateResponse, } from './resources/deep-research'; import { DigitalEmployeeRetrieveDigitalEmployeesParams, DigitalEmployeeRetrieveDigitalEmployeesResponse, DigitalEmployeeRetrieveParams, DigitalEmployeeRetrieveResponse, DigitalEmployeeUpdatePinParams, DigitalEmployees, GLChatBeAPIModelDigitalEmployeeDigitalEmployeeProjectRef, } from './resources/digital-employees'; import { Encryption, EncryptionDecryptParams, EncryptionEncryptParams, EncryptionTextRequest, EncryptionTextResponse, } from './resources/encryption'; import { EnhancePrompt, EnhancePromptEnhancePromptParams, EnhancePromptEnhancePromptResponse, } from './resources/enhance-prompt'; import { EnvRetrieveConfigParams, EnvRetrieveConfigResponse, Envs } from './resources/envs'; import { ExternalPipeline, ExternalPipelineDeleteParams, ExternalPipelineSynchronizeParams, } from './resources/external-pipeline'; import { FileDeleteAllParams, FileDeleteAllResponse, FileDeleteParams, FileDeleteResponse, FileUploadParams, FileUploadResponse, Files, } from './resources/files'; import { HealthCheck, HealthCheckStatusParams, HealthCheckTestAuthParams, Healthcheck, } from './resources/health-check'; import { I18n, I18nRetrieveParams, I18nRetrieveResponse } from './resources/i18n'; import { Internal, InternalRetrieveParams } from './resources/internal'; import { KnowledgeBaseInfo, KnowledgeBaseListParams, KnowledgeBaseListResponse, KnowledgeBases, } from './resources/knowledge-bases'; import { DeleteMemoryRequest, GetMemoryResponse, Memories, MemoryDeleteAllParams, MemoryDeleteParams, MemoryListParams, MemoryMarkParams, MemoryMarkResponse, MemoryUpdateParams, MemoryUpdateResponse, UpdateMemoryRequest, } from './resources/memories'; import { MessageStatRetrieveParams, MessageStatRetrieveResponse, MessageStats, } from './resources/message-stats'; import { PipelinePlugin, PipelinePluginCreateParams, PipelinePluginCreateResponse, PipelinePluginDeleteParams, PipelinePluginDeleteResponse, } from './resources/pipeline-plugin'; import { RegisterExternalPipeline, RegisterExternalPipelineRegisterExternalPipelineParams, RegisterExternalPipelineResponse, } from './resources/register-external-pipeline'; import { Retrieve, RetrieveCreateParams, RetrieveCreateResponse } from './resources/retrieve'; import { RootBranding, RootBrandingRetrieveRootBrandingParams, RootBrandingRetrieveRootBrandingResponse, } from './resources/root-branding'; import { SaveMessage, SaveMessageCreateParams, SaveMessageCreateResponse } from './resources/save-message'; import { ShingleListParams, ShingleListResponse, Shingles } from './resources/shingles'; import { SkillRetrieveEnabledParams, SkillRetrieveEnabledResponse, SkillToggleParams, SkillToggleResponse, Skills, } from './resources/skills'; import { StreamResource, StreamResourceStopParams, StreamResourceStopResponse } from './resources/stream'; import { VectorStore, VectorStoreCreateParams, VectorStoreCreateResponse } from './resources/vector-store'; import { Agents } from './resources/agents/agents'; import { API as ApiapiAPI, APIPreviewTokenParams, APIPreviewTokenResponse } from './resources/api/api'; import { Auth, AuthDirectAPILoginParams, AuthDirectAPILoginResponse, AuthLastVisitedOrganizationParams, AuthLastVisitedOrganizationResponse, AuthLogoutAllParams, AuthLogoutAllResponse, AuthLogoutParams, AuthLogoutResponse, AuthLookupEmailParams, AuthLookupEmailResponse, AuthMeParams, AuthMeResponse, AuthPostLoginParams, AuthResolveUsernameParams, AuthResolveUsernameResponse, AuthRetrieveProvidersParams, AuthRetrieveProvidersResponse, CurrentUserOutput, PostLoginRouting, RoutingOrganization, Tenant, } from './resources/auth/auth'; import { ConversationLegacy, ConversationLegacyCreateParams, ConversationLegacyDeleteParams, ConversationLegacyDeleteResponse, ConversationLegacyGenerateTitleParams, ConversationLegacyGenerateTitleResponse, ConversationLegacyRenameParams, ConversationLegacyRetrieveParams, ConversationLegacyRetrieveResponse, ConversationLegacyShareParams, ConversationLegacyUpdateParams, ConversationLegacyUpdateResponse, } from './resources/conversation-legacy/conversation-legacy'; import { ConversationBranchHistoryParams, ConversationBranchHistoryResponse, ConversationCreateParams, ConversationDeleteMultipleParams, ConversationDeleteMultipleResponse, ConversationDeleteParams, ConversationDeleteResponse, ConversationListParams, ConversationListResponse, ConversationRemainingContextWindowParams, ConversationRemainingContextWindowResponse, ConversationUpdateParams, Conversations, CreateConversation, } from './resources/conversations/conversations'; import { Library, LibraryRetrieveConfigParams, LibraryRetrieveConfigResponse, LibraryRetrieveShareTargetsParams, LibraryRetrieveShareTargetsResponse, } from './resources/library/library'; import { Media, MediaRetrieveParams, MediaRetrieveResponse } from './resources/media/media'; import { Message, MessageCreateParams, MessageDeanonymizeParams, MessageDeanonymizeResponse, MessageDeleteParams, MessageDeleteResponse, MessageResource, SearchType, } from './resources/message/message'; import { MindMap, MindMapCreateParams, MindMapNodeResponse, MindMaps } from './resources/mind-maps/mind-maps'; import { NotificationListParams, NotificationListResponse, NotificationMarkAllParams, NotificationMarkAllResponse, NotificationRetrieveCatalogParams, NotificationRetrieveCatalogResponse, NotificationUpdateParams, NotificationUpdateResponse, Notifications, } from './resources/notifications/notifications'; import { Scheduler } from './resources/scheduler/scheduler'; import { UserUpdatePrivacyPolicyConsentParams, Users } from './resources/users/users'; import { V2 } from './resources/v2/v2'; import { V3 } from './resources/v3/v3'; import { type Fetch } from './internal/builtin-types'; import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers'; import { FinalRequestOptions, RequestOptions } from './internal/request-options'; import { readEnv } from './internal/utils/env'; import { type LogLevel, type Logger, formatRequestDetails, loggerFor, parseLogLevel, } from './internal/utils/log'; import { isEmptyObj } from './internal/utils/values'; import { MemoryCacheStore } from './custom/cache'; export interface ClientOptions { /** * Defaults to process.env['GLCHAT_API_KEY']. */ apiKey?: string | null | undefined; /** * Defaults to process.env['GLCHAT_TENANT_ID']. */ tenantID?: string | null | undefined; /** * Override the default base URL for the API, e.g., "https://api.example.com/v2/" * * Defaults to process.env['GL_CHAT_BASE_URL']. */ baseURL?: string | null | undefined; /** * The maximum amount of time (in milliseconds) that the client should wait for a response * from the server before timing out a single request. * * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. * * @unit milliseconds */ timeout?: number | undefined; /** * Additional `RequestInit` options to be passed to `fetch` calls. * Properties will be overridden by per-request `fetchOptions`. */ fetchOptions?: MergedRequestInit | undefined; /** * Specify a custom `fetch` function implementation. * * If not provided, we expect that `fetch` is defined globally. */ fetch?: Fetch | undefined; /** * The maximum number of times that the client will retry a request in case of a * temporary failure, like a network error or a 5XX error from the server. * * @default 5 */ maxRetries?: number | undefined; /** * Default headers to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * header to `null` in request options. */ defaultHeaders?: HeadersLike | undefined; /** * Default query parameters to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * param to `undefined` in request options. */ defaultQuery?: Record | undefined; /** * Set the log level. * * Defaults to process.env['GL_CHAT_LOG'] or 'warn' if it isn't set. */ logLevel?: LogLevel | undefined; /** * Set the logger. * * Defaults to globalThis.console. */ logger?: Logger | undefined; /** * Enable experimental caching mechanism using the `ETag` header. * * Refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/ETag * for more information on how it works. * * Defaults to `false` for backward compatibility. */ cache?: CacheOptions | boolean; } interface CacheOptions { store?: CacheStore; maxBodyBytes?: number; } export interface CacheEntry { tag: string; body: string; contentType: string | null; savedAt: number; } export interface CacheStore { get(key: string): CacheEntry | null | Promise; set(key: string, entry: CacheEntry): void | Promise; delete(key: string): void | Promise; clear(): void | Promise; } /** * API Client for interfacing with the GLChat API. */ export class GLChat { apiKey: string | null; tenantID: string | null; baseURL: string; maxRetries: number; timeout: number; logger: Logger; logLevel: LogLevel | undefined; fetchOptions: MergedRequestInit | undefined; private fetch: Fetch; #encoder: Opts.RequestEncoder; protected idempotencyHeader?: string; private _options: ClientOptions; private _cache: CacheStore | null; private _maxCacheableSize: number | null; /** * API Client for interfacing with the GLChat API. * * @param {string | null | undefined} [opts.apiKey=process.env['GLCHAT_API_KEY'] ?? null] * @param {string | null | undefined} [opts.tenantID=process.env['GLCHAT_TENANT_ID'] ?? null] * @param {string} [opts.baseURL=process.env['GL_CHAT_BASE_URL'] ?? https://glchat-api.glair.ai/] - Override the default base URL for the API. * @param {number} [opts.timeout=1 minute] - 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=5] - 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} opts.defaultQuery - Default query parameters to include with every request to the API. */ constructor({ baseURL = readEnv('GL_CHAT_BASE_URL'), apiKey = readEnv('GLCHAT_API_KEY') ?? null, tenantID = readEnv('GLCHAT_TENANT_ID') ?? null, ...opts }: ClientOptions = {}) { const options: ClientOptions = { apiKey, tenantID, ...opts, baseURL: baseURL || `https://glchat-api.glair.ai/`, }; this.baseURL = options.baseURL!; this.timeout = options.timeout ?? GLChat.DEFAULT_TIMEOUT; /* 1 minute */ 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 = parseLogLevel(options.logLevel, 'ClientOptions.logLevel', this) ?? parseLogLevel(readEnv('GL_CHAT_LOG'), "process.env['GL_CHAT_LOG']", this) ?? defaultLogLevel; this.fetchOptions = options.fetchOptions; this.maxRetries = options.maxRetries ?? 5; this.fetch = options.fetch ?? Shims.getDefaultFetch(); this.#encoder = Opts.FallbackEncoder; const customHeadersEnv = readEnv('GL_CHAT_CUSTOM_HEADERS'); if (customHeadersEnv) { const parsed: Record = {}; 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; this._cache = null; this._maxCacheableSize = 512 * 1024; if (typeof options.cache === 'object' && options.cache.store !== undefined) { this._cache = options.cache.store; if (options.cache.maxBodyBytes !== undefined) { this._maxCacheableSize = options.cache.maxBodyBytes; } } else if (options.cache === true) { this._cache = new MemoryCacheStore(); } else { this._maxCacheableSize = 0; } } /** * Create a new client instance re-using the same options given to the current client with optional overriding. */ withOptions(options: Partial): this { const client = new (this.constructor as any as new (props: ClientOptions) => typeof this)({ ...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; } /** * Check whether the base URL is set to its default. */ #baseURLOverridden(): boolean { return this.baseURL !== 'https://glchat-api.glair.ai/'; } protected defaultQuery(): Record | undefined { return this._options.defaultQuery; } protected validateHeaders({ values, nulls }: NullableHeaders) { if (this.apiKey && values.get('authorization')) { return; } if (nulls.has('authorization')) { return; } throw new Error( 'Could not resolve authentication method. Expected the apiKey to be set. Or for the "Authorization" headers to be explicitly omitted', ); } protected async authHeaders(opts: FinalRequestOptions): Promise { if (this.apiKey == null) { return undefined; } return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]); } protected stringifyQuery(query: object | Record): string { return stringifyQuery(query); } private getUserAgent(): string { return `${this.constructor.name}/JS ${VERSION}`; } protected defaultIdempotencyKey(): string { return `stainless-node-retry-${uuid4()}`; } protected makeStatusError( status: number, error: Object, message: string | undefined, headers: Headers, ): Errors.APIError { return Errors.APIError.generate(status, error, message, headers); } buildURL( path: string, query: Record | null | undefined, defaultBaseURL?: string | undefined, ): string { const baseURL = (!this.#baseURLOverridden() && defaultBaseURL) || this.baseURL; const url = 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 (!isEmptyObj(defaultQuery) || !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. */ protected async prepareOptions(options: FinalRequestOptions): Promise {} /** * 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`. */ protected async prepareRequest( request: RequestInit, { url, options }: { url: string; options: FinalRequestOptions }, ): Promise {} get(path: string, opts?: PromiseOrValue): APIPromise { return this.methodRequest('get', path, opts); } post(path: string, opts?: PromiseOrValue): APIPromise { return this.methodRequest('post', path, opts); } patch(path: string, opts?: PromiseOrValue): APIPromise { return this.methodRequest('patch', path, opts); } put(path: string, opts?: PromiseOrValue): APIPromise { return this.methodRequest('put', path, opts); } delete(path: string, opts?: PromiseOrValue): APIPromise { return this.methodRequest('delete', path, opts); } private methodRequest( method: HTTPMethod, path: string, opts?: PromiseOrValue, ): APIPromise { return this.request( Promise.resolve(opts).then((opts) => { return { method, path, ...opts }; }), ); } request( options: PromiseOrValue, remainingRetries: number | null = null, ): APIPromise { return new APIPromise(this, this.makeRequest(options, remainingRetries, undefined)); } private async makeRequest( optionsInput: PromiseOrValue, retriesRemaining: number | null, retryOfRequestLogID: string | undefined, ): Promise { 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(); loggerFor(this).debug( `[${requestLogID}] sending request`, 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(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 = isAbortError(response) || /timed? ?out/i.test(String(response) + ('cause' in response ? String(response.cause) : '')); if (retriesRemaining) { loggerFor(this).info( `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - ${retryMessage}`, ); loggerFor(this).debug( `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (${retryMessage})`, formatRequestDetails({ retryOfRequestLogID, url, durationMs: headersTime - startTime, message: response.message, }), ); return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID); } loggerFor(this).info( `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} - error; no more retries left`, ); loggerFor(this).debug( `[${requestLogID}] connection ${isTimeout ? 'timed out' : 'failed'} (error; no more retries left)`, 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); loggerFor(this).info(`${responseInfo} - ${retryMessage}`); loggerFor(this).debug( `[${requestLogID}] response error (${retryMessage})`, 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`; loggerFor(this).info(`${responseInfo} - ${retryMessage}`); const errText = await response.text().catch((err: any) => castToError(err).message); const errJSON = safeJSON(errText) as any; const errMessage = errJSON ? undefined : errText; loggerFor(this).debug( `[${requestLogID}] response error (${retryMessage})`, 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; } loggerFor(this).info(responseInfo); loggerFor(this).debug( `[${requestLogID}] response start`, formatRequestDetails({ retryOfRequestLogID, url: response.url, status: response.status, headers: response.headers, durationMs: headersTime - startTime, }), ); return { response, options, controller, requestLogID, retryOfRequestLogID, startTime }; } async rebuildResponse(response: Response, headers: Headers): Promise { const init = { status: response.status, statusText: response.statusText, headers }; if (response.status === 204 || response.status === 205 || response.status === 304) { return new Response(null, init); } if (typeof (response as any).body?.getReader === 'function') { return new Response(response.body, init); } if (typeof response.arrayBuffer === 'function') { return new Response(await response.arrayBuffer(), init); } return new Response(await response.text(), init); } /** * Attach headers to a response without touching its body. * * Response headers carry an "immutable" guard, so `response.headers.set()` * throws; replacing the property is the only way to annotate a response * in-place. This matters on runtimes that expose `.text()`/`.arrayBuffer()` * but no `.body` stream (React Native, jsdom, fetch polyfills and mocks), * where `new Response(response.body, …)` would produce an empty body. */ async attachHeaders(response: Response, extra: Record): Promise { const headers = new Headers(response.headers); for (const [key, value] of Object.entries(extra)) headers.set(key, value); try { Object.defineProperty(response, 'headers', { value: headers, configurable: true, enumerable: true, }); return response; } catch { return this.rebuildResponse(response, headers); } } byteLength(body: string): number { if (typeof TextEncoder !== 'undefined') { return new TextEncoder().encode(body).length; } return new Blob([body]).size; } async fetchWithTimeout( url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController, ): Promise { 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 as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) || (typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body); const fetchOptions: RequestInit = { signal: controller.signal as any, ...(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 { const urlStr = url.toString(); const method = fetchOptions.method || 'GET'; let isCacheEnabled = false; if ('etagCache' in options && options.etagCache === true) { isCacheEnabled = false; } let entry: CacheEntry | null = null; if (this._cache && method === 'GET' && isCacheEnabled) { entry = await this._cache.get(urlStr); if (entry) { const headers = new Headers(fetchOptions.headers); headers.set('If-None-Match', entry.tag); fetchOptions.headers = headers; } } const response = await this.fetch.call(undefined, url, fetchOptions); if (response.status === 304 && entry) { const headers = new Headers(response.headers); if (entry.contentType) { headers.set('Content-Type', entry.contentType); } headers.set('X-GLChat-Cache', 'hit'); return new Response(entry.body, { status: 200, statusText: 'OK', headers, }); } const isGet = method === 'GET'; if (!isGet) { if (response.ok && this._cache) { await this._cache.delete(urlStr); } return response; } const etag = response.headers.get('ETag'); if (response.ok && etag) { const body = await response.text(); const contentType = response.headers.get('Content-Type'); const isSizeBypassed = !this._maxCacheableSize || this.byteLength(body) > this._maxCacheableSize; if (!isSizeBypassed && this._cache) { await this._cache.set(urlStr, { tag: etag, body, contentType, savedAt: Date.now(), }); } const headers = new Headers(response.headers); headers.set('X-GLChat-Cache', isSizeBypassed ? 'bypassed' : 'miss'); return new Response(body, { status: response.status, statusText: response.statusText, headers, }); } return this.attachHeaders(response, { 'X-GLChat-Cache': 'miss' }); } finally { clearTimeout(timeout); } } private async shouldRetry(response: Response): Promise { // 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; } private async retryRequest( options: FinalRequestOptions, retriesRemaining: number, requestLogID: string, responseHeaders?: Headers | undefined, ): Promise { let timeoutMillis: number | undefined; // 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 sleep(timeoutMillis); return this.makeRequest(options, retriesRemaining - 1, requestLogID); } private calculateDefaultRetryTimeoutMillis(retriesRemaining: number, maxRetries: number): number { const initialRetryDelay = 1.0; const maxRetryDelay = 10.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: FinalRequestOptions, { retryCount = 0 }: { retryCount?: number } = {}, ): Promise<{ req: FinalizedRequestInit; url: string; timeout: number }> { const options = { ...inputOptions }; const { method, path, query, defaultBaseURL } = options; const url = this.buildURL(path!, query as Record, defaultBaseURL); if ('timeout' in options) 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: FinalizedRequestInit = { method, headers: reqHeaders, ...(options.signal && { signal: options.signal }), ...((globalThis as any).ReadableStream && body instanceof (globalThis as any).ReadableStream && { duplex: 'half' }), ...(body && { body }), ...((this.fetchOptions as any) ?? {}), ...((options.fetchOptions as any) ?? {}), }; return { req, url, timeout: options.timeout }; } private async buildHeaders({ options, method, bodyHeaders, retryCount, }: { options: FinalRequestOptions; method: HTTPMethod; bodyHeaders: HeadersLike; retryCount: number; }): Promise { let idempotencyHeaders: HeadersLike = {}; if (this.idempotencyHeader && method !== 'get') { if (!options.idempotencyKey) options.idempotencyKey = this.defaultIdempotencyKey(); idempotencyHeaders[this.idempotencyHeader] = options.idempotencyKey; } const headers = 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)) } : {}), ...getPlatformHeaders(), 'X-Tenant-ID': this.tenantID, }, await this.authHeaders(options), this._options.defaultHeaders, bodyHeaders, options.headers, ]); this.validateHeaders(headers); return headers.values; } private _makeAbort(controller: AbortController) { // 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(); } private buildBody({ options }: { options: FinalRequestOptions }): { bodyHeaders: HeadersLike; body: BodyInit | undefined; } { const { body, headers: rawHeaders } = options; if (!body) { // A resource method always passes a `body` key when its operation defines a // request body, even if the caller omitted an optional body param. Keep the // content-type for those, and only elide it for operations with no body at // all (e.g. GET/DELETE). if (body == null && 'body' in options) { return this.#encoder({ body, headers: buildHeaders([rawHeaders]) }); } return { bodyHeaders: undefined, body: undefined }; } const headers = 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 as any).Blob && body instanceof (globalThis as any).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 as any).ReadableStream && body instanceof (globalThis as any).ReadableStream) ) { return { bodyHeaders: undefined, body: body as BodyInit }; } 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 as AsyncIterable) }; } 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 this.#encoder({ body, headers }); } } static GLChat = this; static DEFAULT_TIMEOUT = 60000; // 1 minute static GLChatError = Errors.GLChatError; static APIError = Errors.APIError; static APIConnectionError = Errors.APIConnectionError; static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError; static APIUserAbortError = Errors.APIUserAbortError; static NotFoundError = Errors.NotFoundError; static ConflictError = Errors.ConflictError; static RateLimitError = Errors.RateLimitError; static BadRequestError = Errors.BadRequestError; static AuthenticationError = Errors.AuthenticationError; static InternalServerError = Errors.InternalServerError; static PermissionDeniedError = Errors.PermissionDeniedError; static UnprocessableEntityError = Errors.UnprocessableEntityError; static toFile = Uploads.toFile; auth: API.Auth = new API.Auth(this); autosuggest: API.Autosuggest = new API.Autosuggest(this); shingles: API.Shingles = new API.Shingles(this); deepResearch: API.DeepResearch = new API.DeepResearch(this); healthCheck: API.HealthCheck = new API.HealthCheck(this); media: API.Media = new API.Media(this); message: API.MessageResource = new API.MessageResource(this); saveMessage: API.SaveMessage = new API.SaveMessage(this); stream: API.StreamResource = new API.StreamResource(this); files: API.Files = new API.Files(this); messageStats: API.MessageStats = new API.MessageStats(this); mindMaps: API.MindMaps = new API.MindMaps(this); pipelinePlugin: API.PipelinePlugin = new API.PipelinePlugin(this); chatbots: API.Chatbots = new API.Chatbots(this); knowledgeBases: API.KnowledgeBases = new API.KnowledgeBases(this); vectorStore: API.VectorStore = new API.VectorStore(this); connectors: API.Connectors = new API.Connectors(this); users: API.Users = new API.Users(this); conversationLegacy: API.ConversationLegacy = new API.ConversationLegacy(this); conversations: API.Conversations = new API.Conversations(this); memories: API.Memories = new API.Memories(this); agents: API.Agents = new API.Agents(this); notifications: API.Notifications = new API.Notifications(this); scheduler: API.Scheduler = new API.Scheduler(this); i18n: API.I18n = new API.I18n(this); v2: API.V2 = new API.V2(this); v3: API.V3 = new API.V3(this); company: API.Company = new API.Company(this); api: API.API = new API.API(this); enhancePrompt: API.EnhancePrompt = new API.EnhancePrompt(this); registerExternalPipeline: API.RegisterExternalPipeline = new API.RegisterExternalPipeline(this); externalPipeline: API.ExternalPipeline = new API.ExternalPipeline(this); encryption: API.Encryption = new API.Encryption(this); internal: API.Internal = new API.Internal(this); components: API.Components = new API.Components(this); retrieve: API.Retrieve = new API.Retrieve(this); digitalEmployees: API.DigitalEmployees = new API.DigitalEmployees(this); skills: API.Skills = new API.Skills(this); rootBranding: API.RootBranding = new API.RootBranding(this); library: API.Library = new API.Library(this); envs: API.Envs = new API.Envs(this); } GLChat.Auth = Auth; GLChat.Autosuggest = Autosuggest; GLChat.Shingles = Shingles; GLChat.DeepResearch = DeepResearch; GLChat.HealthCheck = HealthCheck; GLChat.Media = Media; GLChat.MessageResource = MessageResource; GLChat.SaveMessage = SaveMessage; GLChat.StreamResource = StreamResource; GLChat.Files = Files; GLChat.MessageStats = MessageStats; GLChat.MindMaps = MindMaps; GLChat.PipelinePlugin = PipelinePlugin; GLChat.Chatbots = Chatbots; GLChat.KnowledgeBases = KnowledgeBases; GLChat.VectorStore = VectorStore; GLChat.Connectors = Connectors; GLChat.Users = Users; GLChat.ConversationLegacy = ConversationLegacy; GLChat.Conversations = Conversations; GLChat.Memories = Memories; GLChat.Agents = Agents; GLChat.Notifications = Notifications; GLChat.Scheduler = Scheduler; GLChat.I18n = I18n; GLChat.V2 = V2; GLChat.V3 = V3; GLChat.Company = Company; GLChat.API = ApiapiAPI; GLChat.EnhancePrompt = EnhancePrompt; GLChat.RegisterExternalPipeline = RegisterExternalPipeline; GLChat.ExternalPipeline = ExternalPipeline; GLChat.Encryption = Encryption; GLChat.Internal = Internal; GLChat.Components = Components; GLChat.Retrieve = Retrieve; GLChat.DigitalEmployees = DigitalEmployees; GLChat.Skills = Skills; GLChat.RootBranding = RootBranding; GLChat.Library = Library; GLChat.Envs = Envs; export declare namespace GLChat { export type RequestOptions = Opts.RequestOptions; export { Auth as Auth, type CurrentUserOutput as CurrentUserOutput, type PostLoginRouting as PostLoginRouting, type RoutingOrganization as RoutingOrganization, type Tenant as Tenant, type AuthDirectAPILoginResponse as AuthDirectAPILoginResponse, type AuthLastVisitedOrganizationResponse as AuthLastVisitedOrganizationResponse, type AuthLogoutResponse as AuthLogoutResponse, type AuthLogoutAllResponse as AuthLogoutAllResponse, type AuthLookupEmailResponse as AuthLookupEmailResponse, type AuthMeResponse as AuthMeResponse, type AuthResolveUsernameResponse as AuthResolveUsernameResponse, type AuthRetrieveProvidersResponse as AuthRetrieveProvidersResponse, type AuthDirectAPILoginParams as AuthDirectAPILoginParams, type AuthLastVisitedOrganizationParams as AuthLastVisitedOrganizationParams, type AuthLogoutParams as AuthLogoutParams, type AuthLogoutAllParams as AuthLogoutAllParams, type AuthLookupEmailParams as AuthLookupEmailParams, type AuthMeParams as AuthMeParams, type AuthPostLoginParams as AuthPostLoginParams, type AuthResolveUsernameParams as AuthResolveUsernameParams, type AuthRetrieveProvidersParams as AuthRetrieveProvidersParams, }; export { Autosuggest as Autosuggest, type AutosuggestSuggestResponse as AutosuggestSuggestResponse, type AutosuggestSuggestParams as AutosuggestSuggestParams, }; export { Shingles as Shingles, type ShingleListResponse as ShingleListResponse, type ShingleListParams as ShingleListParams, }; export { DeepResearch as DeepResearch, type DeepResearchGenerateResponse as DeepResearchGenerateResponse, type DeepResearchGenerateParams as DeepResearchGenerateParams, }; export { HealthCheck as HealthCheck, type Healthcheck as Healthcheck, type HealthCheckStatusParams as HealthCheckStatusParams, type HealthCheckTestAuthParams as HealthCheckTestAuthParams, }; export { Media as Media, type MediaRetrieveResponse as MediaRetrieveResponse, type MediaRetrieveParams as MediaRetrieveParams, }; export { MessageResource as MessageResource, type Message as Message, type SearchType as SearchType, type MessageDeleteResponse as MessageDeleteResponse, type MessageDeanonymizeResponse as MessageDeanonymizeResponse, type MessageCreateParams as MessageCreateParams, type MessageDeleteParams as MessageDeleteParams, type MessageDeanonymizeParams as MessageDeanonymizeParams, }; export { SaveMessage as SaveMessage, type SaveMessageCreateResponse as SaveMessageCreateResponse, type SaveMessageCreateParams as SaveMessageCreateParams, }; export { StreamResource as StreamResource, type StreamResourceStopResponse as StreamResourceStopResponse, type StreamResourceStopParams as StreamResourceStopParams, }; export { Files as Files, type FileUploadResponse as FileUploadResponse, type FileDeleteResponse as FileDeleteResponse, type FileDeleteAllResponse as FileDeleteAllResponse, type FileDeleteParams as FileDeleteParams, type FileDeleteAllParams as FileDeleteAllParams, type FileUploadParams as FileUploadParams, }; export { MessageStats as MessageStats, type MessageStatRetrieveResponse as MessageStatRetrieveResponse, type MessageStatRetrieveParams as MessageStatRetrieveParams, }; export { MindMaps as MindMaps, type MindMap as MindMap, type MindMapNodeResponse as MindMapNodeResponse, type MindMapCreateParams as MindMapCreateParams, }; export { PipelinePlugin as PipelinePlugin, type PipelinePluginCreateResponse as PipelinePluginCreateResponse, type PipelinePluginDeleteResponse as PipelinePluginDeleteResponse, type PipelinePluginCreateParams as PipelinePluginCreateParams, type PipelinePluginDeleteParams as PipelinePluginDeleteParams, }; export { Chatbots as Chatbots, type ChatbotItemV2 as ChatbotItemV2, type ClickBehaviour as ClickBehaviour, type DisplayType as DisplayType, type ChatbotListResponse as ChatbotListResponse, type ChatbotRetrieveFiltersResponse as ChatbotRetrieveFiltersResponse, type ChatbotListParams as ChatbotListParams, type ChatbotRetrieveFiltersParams as ChatbotRetrieveFiltersParams, }; export { KnowledgeBases as KnowledgeBases, type KnowledgeBaseInfo as KnowledgeBaseInfo, type KnowledgeBaseListResponse as KnowledgeBaseListResponse, type KnowledgeBaseListParams as KnowledgeBaseListParams, }; export { VectorStore as VectorStore, type VectorStoreCreateResponse as VectorStoreCreateResponse, type VectorStoreCreateParams as VectorStoreCreateParams, }; export { Connectors as Connectors, type ConnectorStatus as ConnectorStatus, type ConnectorRetrieveResponse as ConnectorRetrieveResponse, type ConnectorListResponse as ConnectorListResponse, type ConnectorConnectResponse as ConnectorConnectResponse, type ConnectorDisconnectResponse as ConnectorDisconnectResponse, type ConnectorRetrieveParams as ConnectorRetrieveParams, type ConnectorListParams as ConnectorListParams, type ConnectorConnectParams as ConnectorConnectParams, type ConnectorDisconnectParams as ConnectorDisconnectParams, }; export { Users as Users, type UserUpdatePrivacyPolicyConsentParams as UserUpdatePrivacyPolicyConsentParams, }; export { ConversationLegacy as ConversationLegacy, type ConversationLegacyRetrieveResponse as ConversationLegacyRetrieveResponse, type ConversationLegacyUpdateResponse as ConversationLegacyUpdateResponse, type ConversationLegacyDeleteResponse as ConversationLegacyDeleteResponse, type ConversationLegacyGenerateTitleResponse as ConversationLegacyGenerateTitleResponse, type ConversationLegacyCreateParams as ConversationLegacyCreateParams, type ConversationLegacyRetrieveParams as ConversationLegacyRetrieveParams, type ConversationLegacyUpdateParams as ConversationLegacyUpdateParams, type ConversationLegacyDeleteParams as ConversationLegacyDeleteParams, type ConversationLegacyGenerateTitleParams as ConversationLegacyGenerateTitleParams, type ConversationLegacyRenameParams as ConversationLegacyRenameParams, type ConversationLegacyShareParams as ConversationLegacyShareParams, }; export { Conversations as Conversations, type CreateConversation as CreateConversation, type ConversationListResponse as ConversationListResponse, type ConversationDeleteResponse as ConversationDeleteResponse, type ConversationBranchHistoryResponse as ConversationBranchHistoryResponse, type ConversationDeleteMultipleResponse as ConversationDeleteMultipleResponse, type ConversationRemainingContextWindowResponse as ConversationRemainingContextWindowResponse, type ConversationCreateParams as ConversationCreateParams, type ConversationUpdateParams as ConversationUpdateParams, type ConversationListParams as ConversationListParams, type ConversationDeleteParams as ConversationDeleteParams, type ConversationBranchHistoryParams as ConversationBranchHistoryParams, type ConversationDeleteMultipleParams as ConversationDeleteMultipleParams, type ConversationRemainingContextWindowParams as ConversationRemainingContextWindowParams, }; export { Memories as Memories, type DeleteMemoryRequest as DeleteMemoryRequest, type GetMemoryResponse as GetMemoryResponse, type UpdateMemoryRequest as UpdateMemoryRequest, type MemoryUpdateResponse as MemoryUpdateResponse, type MemoryMarkResponse as MemoryMarkResponse, type MemoryUpdateParams as MemoryUpdateParams, type MemoryListParams as MemoryListParams, type MemoryDeleteParams as MemoryDeleteParams, type MemoryDeleteAllParams as MemoryDeleteAllParams, type MemoryMarkParams as MemoryMarkParams, }; export { Agents as Agents }; export { Notifications as Notifications, type NotificationUpdateResponse as NotificationUpdateResponse, type NotificationListResponse as NotificationListResponse, type NotificationMarkAllResponse as NotificationMarkAllResponse, type NotificationRetrieveCatalogResponse as NotificationRetrieveCatalogResponse, type NotificationUpdateParams as NotificationUpdateParams, type NotificationListParams as NotificationListParams, type NotificationMarkAllParams as NotificationMarkAllParams, type NotificationRetrieveCatalogParams as NotificationRetrieveCatalogParams, }; export { Scheduler as Scheduler }; export { I18n as I18n, type I18nRetrieveResponse as I18nRetrieveResponse, type I18nRetrieveParams as I18nRetrieveParams, }; export { V2 as V2 }; export { V3 as V3 }; export { Company as Company, type CompanyListResponse as CompanyListResponse, type CompanyRetrieveMembersResponse as CompanyRetrieveMembersResponse, type CompanyRetrieveParams as CompanyRetrieveParams, type CompanyListParams as CompanyListParams, type CompanyRetrieveMembersParams as CompanyRetrieveMembersParams, }; export { ApiapiAPI as API, type APIPreviewTokenResponse as APIPreviewTokenResponse, type APIPreviewTokenParams as APIPreviewTokenParams, }; export { EnhancePrompt as EnhancePrompt, type EnhancePromptEnhancePromptResponse as EnhancePromptEnhancePromptResponse, type EnhancePromptEnhancePromptParams as EnhancePromptEnhancePromptParams, }; export { RegisterExternalPipeline as RegisterExternalPipeline, type RegisterExternalPipelineResponse as RegisterExternalPipelineResponse, type RegisterExternalPipelineRegisterExternalPipelineParams as RegisterExternalPipelineRegisterExternalPipelineParams, }; export { ExternalPipeline as ExternalPipeline, type ExternalPipelineDeleteParams as ExternalPipelineDeleteParams, type ExternalPipelineSynchronizeParams as ExternalPipelineSynchronizeParams, }; export { Encryption as Encryption, type EncryptionTextRequest as EncryptionTextRequest, type EncryptionTextResponse as EncryptionTextResponse, type EncryptionDecryptParams as EncryptionDecryptParams, type EncryptionEncryptParams as EncryptionEncryptParams, }; export { Internal as Internal, type InternalRetrieveParams as InternalRetrieveParams }; export { Components as Components, type ComponentRunResponse as ComponentRunResponse, type ComponentRunParams as ComponentRunParams, }; export { Retrieve as Retrieve, type RetrieveCreateResponse as RetrieveCreateResponse, type RetrieveCreateParams as RetrieveCreateParams, }; export { DigitalEmployees as DigitalEmployees, type GLChatBeAPIModelDigitalEmployeeDigitalEmployeeProjectRef as GLChatBeAPIModelDigitalEmployeeDigitalEmployeeProjectRef, type DigitalEmployeeRetrieveResponse as DigitalEmployeeRetrieveResponse, type DigitalEmployeeRetrieveDigitalEmployeesResponse as DigitalEmployeeRetrieveDigitalEmployeesResponse, type DigitalEmployeeRetrieveParams as DigitalEmployeeRetrieveParams, type DigitalEmployeeRetrieveDigitalEmployeesParams as DigitalEmployeeRetrieveDigitalEmployeesParams, type DigitalEmployeeUpdatePinParams as DigitalEmployeeUpdatePinParams, }; export { Skills as Skills, type SkillRetrieveEnabledResponse as SkillRetrieveEnabledResponse, type SkillToggleResponse as SkillToggleResponse, type SkillRetrieveEnabledParams as SkillRetrieveEnabledParams, type SkillToggleParams as SkillToggleParams, }; export { RootBranding as RootBranding, type RootBrandingRetrieveRootBrandingResponse as RootBrandingRetrieveRootBrandingResponse, type RootBrandingRetrieveRootBrandingParams as RootBrandingRetrieveRootBrandingParams, }; export { Library as Library, type LibraryRetrieveConfigResponse as LibraryRetrieveConfigResponse, type LibraryRetrieveShareTargetsResponse as LibraryRetrieveShareTargetsResponse, type LibraryRetrieveConfigParams as LibraryRetrieveConfigParams, type LibraryRetrieveShareTargetsParams as LibraryRetrieveShareTargetsParams, }; export { Envs as Envs, type EnvRetrieveConfigResponse as EnvRetrieveConfigResponse, type EnvRetrieveConfigParams as EnvRetrieveConfigParams, }; export type AdminChatbotModel = API.AdminChatbotModel; export type AdminKnowledgeBaseModel = API.AdminKnowledgeBaseModel; export type AdminKnowledgeStoreModel = API.AdminKnowledgeStoreModel; export type AdminLmrpCatalogEntryModel = API.AdminLmrpCatalogEntryModel; export type AdminLmrpCatalogModel = API.AdminLmrpCatalogModel; export type AdminPipelineModel = API.AdminPipelineModel; export type AdminPresetModel = API.AdminPresetModel; export type AdminPromptBuilderCatalogEntryModel = API.AdminPromptBuilderCatalogEntryModel; export type AdminPromptBuilderCatalogModel = API.AdminPromptBuilderCatalogModel; export type AdminUserDomainModel = API.AdminUserDomainModel; export type ChatbotModel = API.ChatbotModel; export type GLChatBeAdminChatbotConnectorModelModelAdminChatbotConnectorModel = API.GLChatBeAdminChatbotConnectorModelModelAdminChatbotConnectorModel; export type OrganizationResponse = API.OrganizationResponse; export type RecommendedQuestion = API.RecommendedQuestion; export type UserInfo = API.UserInfo; export type WhatsAppPhoneNumberModel = API.WhatsAppPhoneNumberModel; export type WhatsAppProviderModel = API.WhatsAppProviderModel; }