// 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'; import { path } from '../../internal/utils/path'; export class Chat extends APIResource { /** * Retrieves feedback data for the organization with optional filtering * * @example * ```ts * await client.v1.chat.retrieveFeedback(); * ``` */ retrieveFeedback( query: ChatRetrieveFeedbackParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get('/api/v1/chat/feedback', { query, ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } /** * Retrieves the specific message and full conversation for a feedback item * * @example * ```ts * await client.v1.chat.retrieveFeedbackContext('feedbackId'); * ``` */ retrieveFeedbackContext(feedbackID: string, options?: RequestOptions): APIPromise { return this._client.get(path`/api/v1/chat/feedback/${feedbackID}/context`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } /** * Streams a chat response in real-time using server-sent events (SSE). Supports * both AI SDK format (with messages array) and custom format (with message * object). * * @example * ```ts * await client.v1.chat.stream(); * ``` */ stream(params: ChatStreamParams, options?: RequestOptions): APIPromise { const { 'x-component-id': xComponentID, ...body } = params; return this._client.post('/api/v1/chat/stream', { body, ...options, headers: buildHeaders([ { Accept: '*/*', ...(xComponentID != null ? { 'x-component-id': xComponentID } : undefined) }, options?.headers, ]), }); } } export interface ChatRetrieveFeedbackParams { /** * Filter by component ID */ componentId?: string; /** * Filter by end date (ISO string) */ endDate?: string; /** * Filter by feedback type */ feedbackType?: 'thumbsUp' | 'thumbsDown'; /** * Filter by group ID */ groupId?: string; /** * Number of records to return (default: 100) */ limit?: string; /** * Number of records to skip (default: 0) */ skip?: string; /** * Filter by start date (ISO string) */ startDate?: string; /** * Filter by user ID */ userId?: string; } export interface ChatStreamParams { /** * Body param: Session ID (AI SDK uses "id") */ id?: string; /** * Body param: Component ID */ componentId?: string; /** * Body param: Additional context */ context?: unknown; /** * Body param: Group IDs for access control */ groupIds?: Array; /** * Body param: Single message for custom format - contains text and optional images */ message?: ChatStreamParams.Message; /** * Body param: Messages array for AI SDK format - list of conversation messages * with roles */ messages?: Array; /** * Body param: Session ID */ sessionId?: string; /** * Body param: Trigger for AI SDK (what triggered the message) */ trigger?: string; /** * Body param: User ID */ userId?: string; /** * Header param: Optional component ID for component-specific chat context */ 'x-component-id'?: string; } export namespace ChatStreamParams { /** * Single message for custom format - contains text and optional images */ export interface Message { /** * Images attached to the message */ images?: Array; /** * Text content of the message */ text?: string; } export namespace Message { export interface Image { /** * Base64 encoded image data */ base64?: string; /** * Caption for the image */ caption?: string; /** * MIME type of the image */ mimeType?: string; /** * URL of the image */ url?: string; } } } export declare namespace Chat { export { type ChatRetrieveFeedbackParams as ChatRetrieveFeedbackParams, type ChatStreamParams as ChatStreamParams, }; }