// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as SharedAPI from './shared'; import { Shared, SharedCloneParams, SharedCloneResponse, SharedDeleteParams, SharedDeleteResponse, SharedListParams, SharedRetrieveParams, } from './shared'; import * as ConversationsAPI from '../conversations/conversations'; import * as ShareAPI from '../conversations/share'; 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 ConversationLegacy extends APIResource { shared: SharedAPI.Shared = new SharedAPI.Shared(this._client); /** * Create a new conversation with optional title. NOTE: This endpoint is DEPRECATED * and will be removed soon. Please use `POST /conversations` instead. * * @deprecated Use `conversations.create` instead. */ create( params: ConversationLegacyCreateParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post('/conversation', { body, ...options, headers: buildHeaders([ { 'Content-Type': 'application/x-www-form-urlencoded', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Get messages from a specific conversation with optional limit and date * filtering. NOTE: This endpoint is DEPRECATED and will be removed soon. Please * use `GET /conversations/{conversation_id}` instead. * * @deprecated Use `conversations.messages.list` instead. */ retrieve( conversationID: string, params: ConversationLegacyRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...query } = params ?? {}; return this._client.get(path`/conversation/${conversationID}`, { query, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Update a conversation document's status, number of chunks, and optional message * information. NOTE: This endpoint is DEPRECATED and will be removed soon. Please * use `PATCH /conversations/documents/{document_id}` instead. * * @deprecated Use `conversations.documents.update` instead. */ update( documentID: string, params: ConversationLegacyUpdateParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.patch(path`/conversation/document/${documentID}`, { body, ...options, headers: buildHeaders([ { 'Content-Type': 'application/x-www-form-urlencoded', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Delete a specific conversation by ID and remove any associated attachments and * vector DB documents. NOTE: This endpoint is DEPRECATED and will be removed soon. * Please use `DELETE /conversations/{conversation_id}` instead. * * @deprecated Use `conversations.delete` instead. */ delete( conversationID: string, params: ConversationLegacyDeleteParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.delete(path`/conversation/${conversationID}`, { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Generate a title for an existing conversation based on its content. NOTE: This * endpoint is DEPRECATED and will be removed soon. Please use * `POST /conversations/{conversation_id}/generate-title` instead. * * @deprecated Use `conversations.title.generate` instead. */ generateTitle( conversationID: string, params: ConversationLegacyGenerateTitleParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post(path`/conversation/${conversationID}/generate-title`, { body, ...options, headers: buildHeaders([ { 'Content-Type': 'application/x-www-form-urlencoded', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Rename an existing conversation with a new title. NOTE: This endpoint is * DEPRECATED and will be removed soon. Please use * `PATCH /conversations/{conversation_id}` instead. * * @deprecated Use `conversations.update` instead. */ rename( conversationID: string, params: ConversationLegacyRenameParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.patch(path`/conversation/${conversationID}`, { body, ...options, headers: buildHeaders([ { 'Content-Type': 'application/x-www-form-urlencoded', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Create a shareable link for a conversation with optional expiry days. NOTE: This * endpoint is DEPRECATED and will be removed soon. Please use * `POST /conversations/{conversation_id}/share` instead. * * @deprecated Use `conversations.share.createOrUpdate` instead. */ share( conversationID: string, params: ConversationLegacyShareParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params ?? {}; return this._client.post(path`/conversation/${conversationID}/share`, { body, ...options, headers: buildHeaders([ { 'Content-Type': 'application/x-www-form-urlencoded', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } export type ConversationLegacyRetrieveResponse = { [key: string]: unknown }; export type ConversationLegacyUpdateResponse = { [key: string]: unknown }; export type ConversationLegacyDeleteResponse = { [key: string]: unknown }; export type ConversationLegacyGenerateTitleResponse = { [key: string]: unknown }; export interface ConversationLegacyCreateParams { /** * Body param */ chatbot_id: string; /** * Body param */ user_id: string; /** * Body param */ metadata_?: string | null; /** * Body param */ model_name?: string; /** * Body param */ title?: string | null; /** * 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 interface ConversationLegacyRetrieveParams { /** * Query param */ limit?: number | null; /** * Query param */ max_date?: string | null; /** * 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 interface ConversationLegacyUpdateParams { /** * Body param */ number_of_chunks: number; /** * Body param */ status: string; /** * Body param */ message?: string | null; /** * 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 interface ConversationLegacyDeleteParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } export interface ConversationLegacyGenerateTitleParams { /** * Body param */ message: string; /** * Body param */ anonymize_lm?: boolean; /** * 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 interface ConversationLegacyRenameParams { /** * Body param */ title: string; /** * 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 interface ConversationLegacyShareParams { /** * Body param */ expiry_days?: number | null; /** * 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; } ConversationLegacy.Shared = Shared; export declare namespace ConversationLegacy { export { 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 { Shared as Shared, type SharedDeleteResponse as SharedDeleteResponse, type SharedCloneResponse as SharedCloneResponse, type SharedRetrieveParams as SharedRetrieveParams, type SharedListParams as SharedListParams, type SharedDeleteParams as SharedDeleteParams, type SharedCloneParams as SharedCloneParams, }; }