// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import * as MessageAPI from './message/message'; import { APIPromise } from '../core/api-promise'; import { type Uploadable } from '../core/uploads'; import { buildHeaders } from '../internal/headers'; import { RequestOptions } from '../internal/request-options'; import { multipartFormRequestOptions } from '../internal/uploads'; export class Retrieve extends APIResource { /** * Retrieve relevant knowledge base chunks for a query, without generating a chat * response. */ create(params: RetrieveCreateParams, options?: RequestOptions): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-API-Key': xAPIKey, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post( '/retrieve', multipartFormRequestOptions( { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xAPIKey != null ? { 'X-API-Key': xAPIKey } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }, this._client, ), ); } } /** * Response model for retrieving knowledge base chunks without generating a chat * response. * * Attributes: request_id (str): The unique identifier for this retrieval request. * chunks (list[RetrieveChunk]): The retrieved chunks. pii (PiiInfo): PII * anonymization info for this request. */ export interface RetrieveCreateResponse { /** * PII anonymization info for a retrieval response. * * Attributes: enabled (bool): Whether PII anonymization was applied to this * request. mappings (list[PiiMapping]): The anonymization mappings produced, if * any. */ pii: RetrieveCreateResponse.Pii; request_id: string; chunks?: Array; } export namespace RetrieveCreateResponse { /** * PII anonymization info for a retrieval response. * * Attributes: enabled (bool): Whether PII anonymization was applied to this * request. mappings (list[PiiMapping]): The anonymization mappings produced, if * any. */ export interface Pii { enabled: boolean; mappings?: Array; } export namespace Pii { /** * A single PII anonymization mapping. * * Attributes: id (str): The mapping's unique identifier. pii_type (str): The type * of PII detected (e.g. `PERSON`, `EMAIL`). anonymized_value (str): The * placeholder value substituted for the PII (e.g. ``). pii_value (str): * The original PII value. */ export interface Mapping { id: string; anonymized_value: string; pii_type: string; pii_value: string; } } /** * A single retrieved knowledge base chunk. * * Attributes: id (str): The chunk's unique identifier. content (str): The chunk's * text content. score (float | None): The retrieval relevance score, if available. * metadata (dict[str, Any]): Chunk metadata (e.g. `source_url`, `title`). */ export interface Chunk { id: string; content: string; metadata?: { [key: string]: unknown }; score?: number | null; } } export interface RetrieveCreateParams { /** * Body param */ chatbot_id: string; /** * Body param */ agent_ids?: string; /** * Body param */ anonymize_em?: boolean | null; /** * Body param */ anonymize_lm?: boolean | null; /** * Body param */ assistant_message_id?: string | null; /** * Body param */ chat_history?: string | null; /** * Body param */ connectors?: string; /** * Body param */ conversation_id?: string | null; /** * Body param */ digital_employee_id?: string | null; /** * Body param */ exclude_events?: Array; /** * Body param */ exclude_prefix?: boolean; /** * Body param */ files?: Array; /** * Body param */ filters?: string | null; /** * Body param */ include_pipeline_trace?: boolean; /** * Body param */ include_states?: boolean; /** * Body param */ is_edited?: boolean; /** * Body param */ is_regenerated?: boolean; /** * Body param */ is_retried?: boolean; /** * Body param */ message?: string | null; /** * Body param */ metadata?: string | null; /** * Body param */ model_name?: string | null; /** * Body param */ parent_id?: string | null; /** * Body param */ quote?: string | null; /** * Body param */ regenerated_message_id?: string | null; /** * Body param: The type of search to perform. * * Attributes: NORMAL: Get answer from chatbot knowledge. SEARCH: Get answer from * various connectors. SQL_SEARCH: Get answer from SQL-based database. * AGENT_CONNECTOR: Execute a scoped glaip coordinator with per-request connector * selection. No request_connector or connector_management tooling — missing * connectors yield a plain-text response from the coordinator. WEB: Get more * relevant information from the web. (DEPRECATED) Web Search uses real-time data. * Agent selection isn't available in this mode. DEEP_RESEARCH: Get answer from * Deep Research Agent. ESSENTIALS_DEEP_RESEARCH: Get answer from Deep Research * with Essentials mode. Provides key points and core insights without noise, * optimized for speed and clarity. Ideal for quick decision-making support and * fast orientation. COMPREHENSIVE_DEEP_RESEARCH: Get answer from Deep Research * with Comprehensive mode. Delivers the full picture with depth and thoroughness, * covering all relevant angles, details, and supporting data. Suitable for * professional research tasks where precision matters more than speed. * PRIVATE_DEEP_RESEARCH: Get answer from Deep Research with private deep research * providers. INTERNAL_DEEP_RESEARCH: Retrieves answers using Deep Research with * internal data sources. (DEPRECATED) Accesses internal repositories such as * Google Drive and utilizes the same processing engine as Essentials Deep Research * mode. */ search_type?: MessageAPI.SearchType | null; /** * Body param */ skill_ids?: string; /** * Body param */ smart_mode?: boolean; /** * Body param */ source?: string | null; /** * Body param */ stream?: boolean; /** * Body param */ stream_id?: string | null; /** * Body param */ stream_message_only?: boolean; /** * Body param */ temporary_file_ids?: string | null; /** * Body param */ use_cache?: boolean | null; /** * Body param */ user_id?: string | null; /** * Body param */ user_message_id?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param */ 'X-API-Key'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export declare namespace Retrieve { export { type RetrieveCreateResponse as RetrieveCreateResponse, type RetrieveCreateParams as RetrieveCreateParams, }; }