// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import { APIPromise } from '../core/api-promise'; import { buildHeaders } from '../internal/headers'; import { RequestOptions } from '../internal/request-options'; export class Autosuggest extends APIResource { /** * Suggest original Auto FAQ questions using per-token fuzzy matching and prefix * matching when the final token is ordinary. Identifier-like tokens are not fuzzy * or prefix matched. Results below 30% of the best relevance score are omitted * when that score is positive. */ suggest( params: AutosuggestSuggestParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...query } = params; return this._client.get('/autosuggest', { query, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } export type AutosuggestSuggestResponse = Array | Array; export namespace AutosuggestSuggestResponse { /** * Verbatim FAQ question with the matched regions to highlight. * * Offsets count Unicode code points, not UTF-16 code units. JavaScript/TypeScript * clients can select a span with * `Array.from(suggestion).slice(start, end).join('')`. For example, offsets [2, 8) * in "𠀀 Docker" select "Docker". */ export interface UnionMember1 { /** * Matched regions in the suggestion. */ highlight_spans: Array; /** * Original FAQ question text, preserved verbatim for cache lookup. */ suggestion: string; } export namespace UnionMember1 { /** * Matched region in a verbatim FAQ question, measured in Unicode code points. */ export interface HighlightSpan { /** * Zero-based, exclusive end offset in Unicode code points in the original FAQ * question. */ end: number; /** * Zero-based, inclusive start offset in Unicode code points in the original FAQ * question. */ start: number; } } } export interface AutosuggestSuggestParams { /** * Query param */ chatbot_id: string; /** * Query param: Query must be between 3 and 30 characters */ query: string; /** * Query param: Return suggestion objects with highlight spans when true. */ highlight?: boolean; /** * Query param */ size?: number; /** * Header param */ 'Accept-Language'?: 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 Autosuggest { export { type AutosuggestSuggestResponse as AutosuggestSuggestResponse, type AutosuggestSuggestParams as AutosuggestSuggestParams, }; }