From 299f8b10c28251729cd59e50233fd7fa2e12542f Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Sun, 25 Jan 2026 15:11:25 +0800 Subject: [PATCH] generate with a better input --- web/gen/orpc.gen.ts | 306 ++--- web/gen/types.gen.ts | 2745 +++++++++++++++----------------------- web/gen/zod.gen.ts | 1277 +++++++++++------- web/openapi-ts.config.ts | 2 +- web/openapi_chat.json | 1935 +++++++++++++++++++++++++++ 5 files changed, 3917 insertions(+), 2348 deletions(-) create mode 100644 web/openapi_chat.json diff --git a/web/gen/orpc.gen.ts b/web/gen/orpc.gen.ts index 15ccaba799..7169e289d0 100644 --- a/web/gen/orpc.gen.ts +++ b/web/gen/orpc.gen.ts @@ -1,306 +1,160 @@ // This file is auto-generated by @hey-api/openapi-ts import { oc } from '@orpc/contract' -import { zCheckAppPermissionData, zCheckForgotPasswordTokenData, zCreateChatMessageData, zCreateCompletionMessageData, zCreateMessageFeedbackData, zDeleteConversationData, zDeleteSavedMessageData, zGenerateMoreLikeThisData, zGetAppAccessModeData, zGetConversationListData, zGetMessageListData, zGetRemoteFileInfoData, zGetRemoteFileInfoResponse, zGetSavedMessagesData, zGetSuggestedQuestionsData, zPinConversationData, zRenameConversationData, zResetPasswordData, zRunWorkflowData, zSaveMessageData, zSendEmailCodeLoginData, zSendForgotPasswordEmailData, zStopChatMessageData, zStopCompletionMessageData, zStopWorkflowTaskData, zTextToAudioData, zUnpinConversationData, zUploadFileResponse, zUploadRemoteFileResponse, zVerifyEmailCodeLoginData, zWebAppLoginData } from './zod.gen' +import { zAudioToTextData, zAudioToTextResponse, zCreateAnnotationData, zCreateAnnotationResponse, zDeleteAnnotationData, zDeleteConversationData, zGetAnnotationListData, zGetAnnotationListResponse, zGetChatAppFeedbacksData, zGetChatAppFeedbacksResponse, zGetChatAppInfoResponse, zGetChatAppMetaResponse, zGetChatAppParametersData, zGetChatAppParametersResponse, zGetChatWebAppSettingsResponse, zGetConversationHistoryData, zGetConversationHistoryResponse, zGetConversationsListData, zGetConversationsListResponse, zGetConversationVariablesData, zGetConversationVariablesResponse, zGetInitialAnnotationReplySettingsStatusData, zGetInitialAnnotationReplySettingsStatusResponse, zGetSuggestedQuestionsData, zGetSuggestedQuestionsResponse, zInitialAnnotationReplySettingsData, zInitialAnnotationReplySettingsResponse, zPostChatMessageFeedbackData, zPostChatMessageFeedbackResponse, zPreviewChatFileData, zPreviewChatFileResponse, zRenameConversationData, zRenameConversationResponse, zSendChatMessageData, zSendChatMessageResponse, zStopChatMessageGenerationData, zStopChatMessageGenerationResponse, zTextToAudioChatData, zTextToAudioChatResponse, zUpdateAnnotationData, zUpdateAnnotationResponse, zUploadChatFileData, zUploadChatFileResponse } from './zod.gen' export const base = oc.$route({ inputStructure: 'detailed' }) /** - * Convert audio file to text using speech-to-text service. + * Send a request to the chat application. */ -export const audioToTextContract = base.route({ path: '/audio-to-text', method: 'POST' }) +export const sendChatMessageContract = base.route({ path: '/chat-messages', method: 'POST' }).input(zSendChatMessageData).output(zSendChatMessageResponse) /** - * Create a chat message for conversational applications. + * Upload a file (currently only images are supported) for use when sending messages, enabling multimodal understanding of images and text. Supports png, jpg, jpeg, webp, gif formats. Uploaded files are for use by the current end-user only. */ -export const createChatMessageContract = base.route({ path: '/chat-messages', method: 'POST' }).input(zCreateChatMessageData) +export const uploadChatFileContract = base.route({ path: '/files/upload', method: 'POST' }).input(zUploadChatFileData).output(zUploadChatFileResponse) /** - * Stop a running chat message task. + * Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API. Files can only be accessed if they belong to messages within the requesting application. */ -export const stopChatMessageContract = base.route({ path: '/chat-messages/{task_id}/stop', method: 'POST' }).input(zStopChatMessageData) +export const previewChatFileContract = base.route({ path: '/files/{file_id}/preview', method: 'GET' }).input(zPreviewChatFileData).output(zPreviewChatFileResponse) /** - * Create a completion message for text generation applications. + * Stops a chat message generation task. Only supported in streaming mode. */ -export const createCompletionMessageContract = base.route({ path: '/completion-messages', method: 'POST' }).input(zCreateCompletionMessageData) +export const stopChatMessageGenerationContract = base.route({ path: '/chat-messages/{task_id}/stop', method: 'POST' }).input(zStopChatMessageGenerationData).output(zStopChatMessageGenerationResponse) /** - * Stop a running completion message task. + * End-users can provide feedback messages, facilitating application developers to optimize expected outputs. */ -export const stopCompletionMessageContract = base.route({ path: '/completion-messages/{task_id}/stop', method: 'POST' }).input(zStopCompletionMessageData) +export const postChatMessageFeedbackContract = base.route({ path: '/messages/{message_id}/feedbacks', method: 'POST' }).input(zPostChatMessageFeedbackData).output(zPostChatMessageFeedbackResponse) /** - * Retrieve paginated list of conversations for a chat application. + * Get application's feedbacks. */ -export const getConversationListContract = base.route({ path: '/conversations', method: 'GET' }).input(zGetConversationListData) +export const getChatAppFeedbacksContract = base.route({ path: '/app/feedbacks', method: 'GET' }).input(zGetChatAppFeedbacksData).output(zGetChatAppFeedbacksResponse) /** - * Delete a specific conversation. + * Get next questions suggestions for the current message. */ -export const deleteConversationContract = base.route({ path: '/conversations/{c_id}', method: 'DELETE' }).input(zDeleteConversationData) +export const getSuggestedQuestionsContract = base.route({ path: '/messages/{message_id}/suggested', method: 'GET' }).input(zGetSuggestedQuestionsData).output(zGetSuggestedQuestionsResponse) /** - * Rename a specific conversation with a custom name or auto-generate one. + * Returns historical chat records in a scrolling load format, with the first page returning the latest `{limit}` messages, i.e., in reverse order. */ -export const renameConversationContract = base.route({ path: '/conversations/{c_id}/name', method: 'POST' }).input(zRenameConversationData) +export const getConversationHistoryContract = base.route({ path: '/messages', method: 'GET' }).input(zGetConversationHistoryData).output(zGetConversationHistoryResponse) /** - * Pin a specific conversation to keep it at the top of the list. + * Retrieve the conversation list for the current user, defaulting to the most recent 20 entries. */ -export const pinConversationContract = base.route({ path: '/conversations/{c_id}/pin', method: 'PATCH' }).input(zPinConversationData) +export const getConversationsListContract = base.route({ path: '/conversations', method: 'GET' }).input(zGetConversationsListData).output(zGetConversationsListResponse) /** - * Unpin a specific conversation to remove it from the top of the list. + * Delete a conversation. */ -export const unpinConversationContract = base.route({ path: '/conversations/{c_id}/unpin', method: 'PATCH' }).input(zUnpinConversationData) +export const deleteConversationContract = base.route({ path: '/conversations/{conversation_id}', method: 'DELETE' }).input(zDeleteConversationData) /** - * Send email verification code for login + * Rename the session. The session name is used for display on clients that support multiple sessions. */ -export const sendEmailCodeLoginContract = base.route({ path: '/email-code-login', method: 'POST' }).input(zSendEmailCodeLoginData) +export const renameConversationContract = base.route({ path: '/conversations/{conversation_id}/name', method: 'POST' }).input(zRenameConversationData).output(zRenameConversationResponse) /** - * Verify email code and complete login + * Retrieve variables from a specific conversation. */ -export const verifyEmailCodeLoginContract = base.route({ path: '/email-code-login/validity', method: 'POST' }).input(zVerifyEmailCodeLoginData) +export const getConversationVariablesContract = base.route({ path: '/conversations/{conversation_id}/variables', method: 'GET' }).input(zGetConversationVariablesData).output(zGetConversationVariablesResponse) /** - * Upload a file for use in web applications - * Accepts file uploads for use within web applications, supporting - * multiple file types with automatic validation and storage. - * - * Args: - * app_model: The associated application model - * end_user: The end user uploading the file - * - * Form Parameters: - * file: The file to upload (required) - * source: Optional source type (datasets or None) - * - * Returns: - * dict: File information including ID, URL, and metadata - * int: HTTP status code 201 for success - * - * Raises: - * NoFileUploadedError: No file provided in request - * TooManyFilesError: Multiple files provided (only one allowed) - * FilenameNotExistsError: File has no filename - * FileTooLargeError: File exceeds size limit - * UnsupportedFileTypeError: File type not supported + * Convert audio file to text. Supported formats: mp3, mp4, mpeg, mpga, m4a, wav, webm. File size limit: 15MB. */ -export const uploadFileContract = base.route({ path: '/files/upload', method: 'POST' }).output(zUploadFileResponse) +export const audioToTextContract = base.route({ path: '/audio-to-text', method: 'POST' }).input(zAudioToTextData).output(zAudioToTextResponse) /** - * Send password reset email + * Convert text to speech. */ -export const sendForgotPasswordEmailContract = base.route({ path: '/forgot-password', method: 'POST' }).input(zSendForgotPasswordEmailData) +export const textToAudioChatContract = base.route({ path: '/text-to-audio', method: 'POST' }).input(zTextToAudioChatData).output(zTextToAudioChatResponse) /** - * Reset user password with verification token + * Used to get basic information about this application. */ -export const resetPasswordContract = base.route({ path: '/forgot-password/resets', method: 'POST' }).input(zResetPasswordData) +export const getChatAppInfoContract = base.route({ path: '/info', method: 'GET' }).output(zGetChatAppInfoResponse) /** - * Verify password reset token validity + * Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values. */ -export const checkForgotPasswordTokenContract = base.route({ path: '/forgot-password/validity', method: 'POST' }).input(zCheckForgotPasswordTokenData) +export const getChatAppParametersContract = base.route({ path: '/parameters', method: 'GET' }).input(zGetChatAppParametersData).output(zGetChatAppParametersResponse) /** - * Authenticate user for web application access + * Used to get icons of tools in this application. */ -export const webAppLoginContract = base.route({ path: '/login', method: 'POST' }).input(zWebAppLoginData) +export const getChatAppMetaContract = base.route({ path: '/meta', method: 'GET' }).output(zGetChatAppMetaResponse) /** - * Check login status + * Used to get the WebApp settings of the application. */ -export const webAppLoginStatusContract = base.route({ path: '/login/status', method: 'GET' }) +export const getChatWebAppSettingsContract = base.route({ path: '/site', method: 'GET' }).output(zGetChatWebAppSettingsResponse) /** - * Logout user from web application + * Retrieves a list of annotations for the application. */ -export const webAppLogoutContract = base.route({ path: '/logout', method: 'POST' }) +export const getAnnotationListContract = base.route({ path: '/apps/annotations', method: 'GET' }).input(zGetAnnotationListData).output(zGetAnnotationListResponse) /** - * Retrieve paginated list of messages from a conversation in a chat application. + * Creates a new annotation. */ -export const getMessageListContract = base.route({ path: '/messages', method: 'GET' }).input(zGetMessageListData) +export const createAnnotationContract = base.route({ path: '/apps/annotations', method: 'POST' }).input(zCreateAnnotationData).output(zCreateAnnotationResponse) /** - * Submit feedback (like/dislike) for a specific message. + * Deletes an annotation. */ -export const createMessageFeedbackContract = base.route({ path: '/messages/{message_id}/feedbacks', method: 'POST' }).input(zCreateMessageFeedbackData) +export const deleteAnnotationContract = base.route({ path: '/apps/annotations/{annotation_id}', method: 'DELETE' }).input(zDeleteAnnotationData) /** - * Generate a new completion similar to an existing message (completion apps only). + * Updates an existing annotation. */ -export const generateMoreLikeThisContract = base.route({ path: '/messages/{message_id}/more-like-this', method: 'GET' }).input(zGenerateMoreLikeThisData) +export const updateAnnotationContract = base.route({ path: '/apps/annotations/{annotation_id}', method: 'PUT' }).input(zUpdateAnnotationData).output(zUpdateAnnotationResponse) /** - * Get suggested follow-up questions after a message (chat apps only). + * Enable or disable annotation reply settings and configure embedding models. This interface is executed asynchronously. */ -export const getSuggestedQuestionsContract = base.route({ path: '/messages/{message_id}/suggested-questions', method: 'GET' }).input(zGetSuggestedQuestionsData) +export const initialAnnotationReplySettingsContract = base.route({ path: '/apps/annotation-reply/{action}', method: 'POST' }).input(zInitialAnnotationReplySettingsData).output(zInitialAnnotationReplySettingsResponse) /** - * Retrieve the metadata for a specific app. + * Queries the status of an asynchronously executed annotation reply settings task. */ -export const getAppMetaContract = base.route({ path: '/meta', method: 'GET' }) +export const getInitialAnnotationReplySettingsStatusContract = base.route({ path: '/apps/annotation-reply/{action}/status/{job_id}', method: 'GET' }).input(zGetInitialAnnotationReplySettingsStatusData).output(zGetInitialAnnotationReplySettingsStatusResponse) -/** - * Retrieve the parameters for a specific app. - */ -export const getAppParametersContract = base.route({ path: '/parameters', method: 'GET' }) - -/** - * Get authentication passport for web application access - */ -export const getPassportContract = base.route({ path: '/passport', method: 'GET' }) - -/** - * Upload a file from a remote URL - * Downloads a file from the provided remote URL and uploads it - * to the platform storage for use in web applications. - * - * Args: - * app_model: The associated application model - * end_user: The end user making the request - * - * JSON Parameters: - * url: The remote URL to download the file from (required) - * - * Returns: - * dict: File information including ID, signed URL, and metadata - * int: HTTP status code 201 for success - * - * Raises: - * RemoteFileUploadError: Failed to fetch file from remote URL - * FileTooLargeError: File exceeds size limit - * UnsupportedFileTypeError: File type not supported - */ -export const uploadRemoteFileContract = base.route({ path: '/remote-files/upload', method: 'POST' }).output(zUploadRemoteFileResponse) - -/** - * Get information about a remote file - * Retrieves basic information about a file located at a remote URL, - * including content type and content length. - * - * Args: - * app_model: The associated application model - * end_user: The end user making the request - * url: URL-encoded path to the remote file - * - * Returns: - * dict: Remote file information including type and length - * - * Raises: - * HTTPException: If the remote file cannot be accessed - */ -export const getRemoteFileInfoContract = base.route({ path: '/remote-files/{url}', method: 'GET' }).input(zGetRemoteFileInfoData).output(zGetRemoteFileInfoResponse) - -/** - * Retrieve paginated list of saved messages for a completion application. - */ -export const getSavedMessagesContract = base.route({ path: '/saved-messages', method: 'GET' }).input(zGetSavedMessagesData) - -/** - * Save a specific message for later reference. - */ -export const saveMessageContract = base.route({ path: '/saved-messages', method: 'POST' }).input(zSaveMessageData) - -/** - * Remove a message from saved messages. - */ -export const deleteSavedMessageContract = base.route({ path: '/saved-messages/{message_id}', method: 'DELETE' }).input(zDeleteSavedMessageData) - -/** - * Retrieve app site information and configuration. - */ -export const getAppSiteInfoContract = base.route({ path: '/site', method: 'GET' }) - -/** - * Get system feature flags and configuration - * Returns the current system feature flags and configuration - * that control various functionalities across the platform. - * - * Returns: - * dict: System feature configuration object - * - * This endpoint is akin to the `SystemFeatureApi` endpoint in api/controllers/console/feature.py, - * except it is intended for use by the web app, instead of the console dashboard. - * - * NOTE: This endpoint is unauthenticated by design, as it provides system features - * data required for webapp initialization. - * - * Authentication would create circular dependency (can't authenticate without webapp loading). - * - * Only non-sensitive configuration data should be returned by this endpoint. - */ -export const getSystemFeaturesContract = base.route({ path: '/system-features', method: 'GET' }) - -/** - * Convert text to audio using text-to-speech service. - */ -export const textToAudioContract = base.route({ path: '/text-to-audio', method: 'POST' }).input(zTextToAudioData) - -/** - * Retrieve the access mode for a web application (public or restricted). - */ -export const getAppAccessModeContract = base.route({ path: '/webapp/access-mode', method: 'GET' }).input(zGetAppAccessModeData) - -/** - * Check if user has permission to access a web application. - */ -export const checkAppPermissionContract = base.route({ path: '/webapp/permission', method: 'GET' }).input(zCheckAppPermissionData) - -/** - * Execute a workflow with provided inputs and files. - */ -export const runWorkflowContract = base.route({ path: '/workflows/run', method: 'POST' }).input(zRunWorkflowData) - -/** - * Stop a running workflow task. - */ -export const stopWorkflowTaskContract = base.route({ path: '/workflows/tasks/{task_id}/stop', method: 'POST' }).input(zStopWorkflowTaskData) - -export const contracts = { web: { - audioToTextContract, - createChatMessageContract, - stopChatMessageContract, - createCompletionMessageContract, - stopCompletionMessageContract, - getConversationListContract, - deleteConversationContract, - renameConversationContract, - pinConversationContract, - unpinConversationContract, - sendEmailCodeLoginContract, - verifyEmailCodeLoginContract, - uploadFileContract, - sendForgotPasswordEmailContract, - resetPasswordContract, - checkForgotPasswordTokenContract, - webAppLoginContract, - webAppLoginStatusContract, - webAppLogoutContract, - getMessageListContract, - createMessageFeedbackContract, - generateMoreLikeThisContract, - getSuggestedQuestionsContract, - getAppMetaContract, - getAppParametersContract, - getPassportContract, - uploadRemoteFileContract, - getRemoteFileInfoContract, - getSavedMessagesContract, - saveMessageContract, - deleteSavedMessageContract, - getAppSiteInfoContract, - getSystemFeaturesContract, - textToAudioContract, - getAppAccessModeContract, - checkAppPermissionContract, - runWorkflowContract, - stopWorkflowTaskContract, -} } +export const contracts = { + chat: { + sendChatMessageContract, + stopChatMessageGenerationContract, + getSuggestedQuestionsContract, + }, + files: { uploadChatFileContract, previewChatFileContract }, + feedback: { postChatMessageFeedbackContract, getChatAppFeedbacksContract }, + conversations: { + getConversationHistoryContract, + getConversationsListContract, + deleteConversationContract, + renameConversationContract, + getConversationVariablesContract, + }, + tTS: { audioToTextContract, textToAudioChatContract }, + application: { + getChatAppInfoContract, + getChatAppParametersContract, + getChatAppMetaContract, + getChatWebAppSettingsContract, + }, + annotations: { + getAnnotationListContract, + createAnnotationContract, + deleteAnnotationContract, + updateAnnotationContract, + initialAnnotationReplySettingsContract, + getInitialAnnotationReplySettingsStatusContract, + }, +} export type Contracts = typeof contracts diff --git a/web/gen/types.gen.ts b/web/gen/types.gen.ts index 96cb9841c3..bd15f98fab 100644 --- a/web/gen/types.gen.ts +++ b/web/gen/types.gen.ts @@ -1,652 +1,889 @@ // This file is auto-generated by @hey-api/openapi-ts export type ClientOptions = { - baseUrl: `${string}://${string}/api` | (string & {}) + baseUrl: `${string}://{api_base_url}` | (string & {}) } -/** - * TextToAudioPayload - */ -export type TextToAudioPayload = { +export type ChatRequest = { /** - * Message Id - */ - message_id?: { - [key: string]: unknown - } - /** - * Voice - */ - voice?: { - [key: string]: unknown - } - /** - * Text - */ - text?: { - [key: string]: unknown - } - /** - * Streaming - */ - streaming?: { - [key: string]: unknown - } -} - -/** - * CompletionMessagePayload - */ -export type CompletionMessagePayload = { - /** - * Inputs - * - * Input variables for the completion - */ - inputs: { - [key: string]: unknown - } - /** - * Query - * - * Query text for completion - */ - query?: string - /** - * Files - * - * Files to be processed - */ - files?: { - [key: string]: unknown - } - /** - * Response Mode - * - * Response mode: blocking or streaming - */ - response_mode?: { - [key: string]: unknown - } - /** - * Retriever From - * - * Source of retriever - */ - retriever_from?: string -} - -/** - * ChatMessagePayload - */ -export type ChatMessagePayload = { - /** - * Inputs - * - * Input variables for the chat - */ - inputs: { - [key: string]: unknown - } - /** - * Query - * - * User query/message + * User Input/Question content. */ query: string /** - * Files - * - * Files to be processed + * Allows the entry of various variable values defined by the App. Contains key/value pairs. Default {}. */ - files?: { + inputs?: { [key: string]: unknown } /** - * Response Mode - * - * Response mode: blocking or streaming + * Mode of response return. `streaming` (recommended) uses SSE. `blocking` returns after completion (may be interrupted for long processes; not supported in Agent Assistant mode). Cloudflare timeout is 100s. */ - response_mode?: { - [key: string]: unknown - } + response_mode?: 'streaming' | 'blocking' /** - * Conversation Id - * - * Conversation ID + * User identifier, unique within the application. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface. */ - conversation_id?: { - [key: string]: unknown - } + user: string /** - * Parent Message Id - * - * Parent message ID + * Conversation ID to continue a conversation. Pass the previous message's conversation_id. */ - parent_message_id?: { - [key: string]: unknown - } + conversation_id?: string /** - * Retriever From - * - * Source of retriever + * File list (images) for Vision-capable models. */ - retriever_from?: string + files?: Array + /** + * Auto-generate conversation title. Default `true`. If `false`, use conversation rename API with `auto_generate: true` for async title generation. + */ + auto_generate_name?: boolean +} + +export type InputFileObject = ({ + transfer_method?: 'remote_url' + url: string +} | { + transfer_method?: 'local_file' + upload_file_id: string +}) & { + /** + * Supported type: `image`. + */ + type: 'image' + /** + * Transfer method, `remote_url` for image URL / `local_file` for file upload + */ + transfer_method: 'remote_url' | 'local_file' + /** + * Image URL (when the transfer method is `remote_url`) + */ + url?: string + /** + * Uploaded file ID, which must be obtained by uploading through the File Upload API in advance (when the transfer method is `local_file`) + */ + upload_file_id?: string } /** - * FileResponse + * Response object for blocking mode chat completion. */ -export type FileResponse = { +export type ChatCompletionResponse = { /** - * Id + * Event type, fixed as `message`. + */ + event?: string + /** + * Task ID for request tracking and stop response API. + */ + task_id?: string + /** + * Unique ID of this response/message event. + */ + id?: string + /** + * Unique message ID. + */ + message_id?: string + /** + * Conversation ID. + */ + conversation_id?: string + /** + * App mode, fixed as `chat`. + */ + mode?: string + /** + * Complete response content. + */ + answer?: string + metadata?: { + usage?: Usage + retriever_resources?: Array + } + /** + * Message creation timestamp (Unix epoch seconds). + */ + created_at?: number +} + +/** + * Base schema for Server-Sent Event chunks in streaming mode. + */ +export type ChunkChatEvent = { + /** + * The type of event. + */ + event: 'message' | 'agent_message' | 'tts_message' | 'tts_message_end' | 'agent_thought' | 'message_file' | 'message_end' | 'message_replace' | 'error' | 'ping' +} + +export type StreamEventBase = { + /** + * Task ID. + */ + task_id?: string + /** + * Unique message ID. + */ + message_id?: string + /** + * Conversation ID. + */ + conversation_id?: string + /** + * Creation timestamp. + */ + created_at?: number +} + +export type StreamEventChatMessage = Omit & StreamEventBase & { + /** + * LLM returned text chunk. + */ + answer: string + event: 'message' +} + +export type StreamEventChatAgentMessage = Omit & StreamEventBase & { + /** + * LLM returned text chunk (Agent mode). + */ + answer: string + event: 'agent_message' +} + +export type StreamEventChatTtsMessage = Omit & StreamEventBase & { + /** + * Base64 encoded audio chunk. + */ + audio: string + event: 'tts_message' +} + +export type StreamEventChatTtsMessageEnd = Omit & StreamEventBase & { + /** + * Empty string for end event. + */ + audio: string + event: 'tts_message_end' +} + +export type StreamEventChatAgentThought = Omit & StreamEventBase & { + /** + * Agent thought ID. */ id: string /** - * Name + * Position of this thought in the sequence for the message. */ - name: string + position: number /** - * Size + * What LLM is thinking. */ - size: number + thought?: string /** - * Extension + * Response from tool calls. */ - extension?: { - [key: string]: unknown - } + observation?: string /** - * Mime Type + * List of tools called, split by ';'. */ - mime_type?: { - [key: string]: unknown - } + tool?: string /** - * Created By + * Input of tools in JSON format. Example: {"dalle3": {"prompt": "a cute cat"}}. */ - created_by?: { - [key: string]: unknown - } + tool_input?: string /** - * Created At + * File IDs of files related to this thought (e.g., generated by a tool). */ - created_at?: { - [key: string]: unknown - } - /** - * Preview Url - */ - preview_url?: { - [key: string]: unknown - } - /** - * Source Url - */ - source_url?: { - [key: string]: unknown - } - /** - * Original Url - */ - original_url?: { - [key: string]: unknown - } - /** - * User Id - */ - user_id?: { - [key: string]: unknown - } - /** - * Tenant Id - */ - tenant_id?: { - [key: string]: unknown - } - /** - * Conversation Id - */ - conversation_id?: { - [key: string]: unknown - } - /** - * File Key - */ - file_key?: { - [key: string]: unknown - } + message_files?: Array + event: 'agent_thought' } -/** - * ForgotPasswordSendPayload - */ -export type ForgotPasswordSendPayload = { +export type StreamEventChatMessageFile = Omit & { /** - * Email - */ - email: string - /** - * Language - */ - language?: { - [key: string]: unknown - } -} - -/** - * ForgotPasswordCheckPayload - */ -export type ForgotPasswordCheckPayload = { - /** - * Email - */ - email: string - /** - * Code - */ - code: string - /** - * Token - */ - token: string -} - -/** - * ForgotPasswordResetPayload - */ -export type ForgotPasswordResetPayload = { - /** - * Token - */ - token: string - /** - * New Password - */ - new_password: string - /** - * Password Confirm - */ - password_confirm: string -} - -/** - * LoginPayload - */ -export type LoginPayload = { - /** - * Email - */ - email: string - /** - * Password - */ - password: string -} - -/** - * EmailCodeLoginSendPayload - */ -export type EmailCodeLoginSendPayload = { - /** - * Email - */ - email: string - /** - * Language - */ - language?: { - [key: string]: unknown - } -} - -/** - * EmailCodeLoginVerifyPayload - */ -export type EmailCodeLoginVerifyPayload = { - /** - * Email - */ - email: string - /** - * Code - */ - code: string - /** - * Token - */ - token: string -} - -/** - * MessageMoreLikeThisQuery - */ -export type MessageMoreLikeThisQuery = { - /** - * Response Mode - * - * Response mode - */ - response_mode: 'blocking' | 'streaming' -} - -/** - * RemoteFileInfo - */ -export type RemoteFileInfo = { - /** - * File Type - */ - file_type: string - /** - * File Length - */ - file_length: number -} - -/** - * FileWithSignedUrl - */ -export type FileWithSignedUrl = { - /** - * Id + * File unique ID. */ id: string /** - * Name + * File type, currently only 'image'. */ - name: string + type: 'image' /** - * Size + * Who this file belongs to, always 'assistant' here. */ - size: number + belongs_to: 'assistant' /** - * Extension - */ - extension?: { - [key: string]: unknown - } - /** - * Url - */ - url?: { - [key: string]: unknown - } - /** - * Mime Type - */ - mime_type?: { - [key: string]: unknown - } - /** - * Created By - */ - created_by?: { - [key: string]: unknown - } - /** - * Created At - */ - created_at?: { - [key: string]: unknown - } -} - -/** - * WorkflowRunPayload - */ -export type WorkflowRunPayload = { - /** - * Inputs - * - * Input variables for the workflow - */ - inputs: { - [key: string]: unknown - } - /** - * Files - * - * Files to be processed by the workflow - */ - files?: { - [key: string]: unknown - } -} - -/** - * AppAccessModeQuery - */ -export type AppAccessModeQuery = { - /** - * Appid - * - * Application ID - */ - appId?: { - [key: string]: unknown - } - /** - * Appcode - * - * Application code - */ - appCode?: { - [key: string]: unknown - } -} - -/** - * ConversationListQuery - */ -export type ConversationListQuery = { - /** - * Last Id - */ - last_id?: { - [key: string]: unknown - } - /** - * Limit - */ - limit?: number - /** - * Pinned - */ - pinned?: { - [key: string]: unknown - } - /** - * Sort By - */ - sort_by?: 'created_at' | '-created_at' | 'updated_at' | '-updated_at' -} - -/** - * ConversationRenamePayload - */ -export type ConversationRenamePayload = { - /** - * Name - */ - name?: { - [key: string]: unknown - } - /** - * Auto Generate - */ - auto_generate?: boolean -} - -/** - * MessageListQuery - */ -export type MessageListQuery = { - /** - * Conversation Id - * - * Conversation UUID - */ - conversation_id: string - /** - * First Id - * - * First message ID for pagination - */ - first_id?: { - [key: string]: unknown - } - /** - * Limit - * - * Number of messages to return (1-100) - */ - limit?: number -} - -/** - * MessageFeedbackPayload - */ -export type MessageFeedbackPayload = { - /** - * Rating - * - * Feedback rating - */ - rating?: { - [key: string]: unknown - } - /** - * Content - * - * Feedback content - */ - content?: { - [key: string]: unknown - } -} - -/** - * RemoteFileUploadPayload - */ -export type RemoteFileUploadPayload = { - /** - * Url - * - * Remote file URL + * Remote URL of the file. */ url: string + /** + * Conversation ID. + */ + conversation_id: string + event: 'message_file' +} + +export type StreamEventChatMessageEnd = Omit & StreamEventBase & { + metadata: { + usage?: Usage + retriever_resources?: Array + } + event: 'message_end' +} + +export type StreamEventChatMessageReplace = Omit & StreamEventBase & { + /** + * Replacement content. + */ + answer: string + event: 'message_replace' +} + +export type StreamEventChatError = Omit & StreamEventBase & { + /** + * HTTP status code. + */ + status: number + /** + * Error code. + */ + code: string + /** + * Error message. + */ + message: string + event: 'error' +} + +export type StreamEventChatPing = Omit & { + event: 'ping' + [key: string]: unknown | 'ping' } /** - * SavedMessageListQuery + * Model usage information. */ -export type SavedMessageListQuery = { +export type Usage = { + prompt_tokens?: number + prompt_unit_price?: string + prompt_price_unit?: string + prompt_price?: string + completion_tokens?: number + completion_unit_price?: string + completion_price_unit?: string + completion_price?: string + total_tokens?: number + total_price?: string + currency?: string + latency?: number +} + +/** + * Citation and Attribution information for a resource. + */ +export type RetrieverResource = { /** - * Last Id + * Position of the resource in the list. */ - last_id?: { + position?: number + /** + * ID of the dataset. + */ + dataset_id?: string + /** + * Name of the dataset. + */ + dataset_name?: string + /** + * ID of the document. + */ + document_id?: string + /** + * Name of the document. + */ + document_name?: string + /** + * ID of the specific segment within the document. + */ + segment_id?: string + /** + * Relevance score of the resource. + */ + score?: number + /** + * Content snippet from the resource. + */ + content?: string +} + +export type FileUploadResponse = { + id?: string + name?: string + size?: number + extension?: string + mime_type?: string + created_by?: string + created_at?: number +} + +export type MessageFeedbackRequest = { + rating?: 'like' | 'dislike' | null + user: string + content?: string +} + +export type AppFeedbacksResponse = { + data?: Array +} + +export type FeedbackItem = { + id?: string + app_id?: string + conversation_id?: string + message_id?: string + rating?: 'like' | 'dislike' | null + content?: string + from_source?: string + from_end_user_id?: string + from_account_id?: string | null + created_at?: string + updated_at?: string +} + +export type SuggestedQuestionsResponse = { + result?: string + data?: Array +} + +export type ConversationHistoryResponse = { + limit?: number + has_more?: boolean + data?: Array +} + +export type ConversationMessageItem = { + id?: string + conversation_id?: string + inputs?: { [key: string]: unknown } + query?: string + answer?: string + message_files?: Array + feedback?: { + rating?: 'like' | 'dislike' + } | null + retriever_resources?: Array + agent_thoughts?: Array + created_at?: number +} + +export type MessageFileItem = { + id?: string /** - * Limit + * File type, e.g., 'image'. + */ + type?: string + /** + * Preview image URL. + */ + url?: string + /** + * Who this file belongs to. + */ + belongs_to?: 'user' | 'assistant' +} + +export type AgentThoughtItem = { + /** + * Agent thought ID. + */ + id?: string + /** + * Unique message ID this thought belongs to. + */ + message_id?: string + /** + * Position of this thought. + */ + position?: number + /** + * What LLM is thinking. + */ + thought?: string + /** + * Tools called, split by ';'. + */ + tool?: string + /** + * Input of tools in JSON format. + */ + tool_input?: string + /** + * Response from tool calls. + */ + observation?: string + /** + * File IDs related to this thought (from example, Markdown text says 'message_files'). + */ + files?: Array + /** + * Creation timestamp. + */ + created_at?: number +} + +export type ConversationsListResponse = { + limit?: number + has_more?: boolean + data?: Array +} + +export type ConversationListItem = { + id?: string + name?: string + inputs?: { + [key: string]: unknown + } + status?: string + introduction?: string + created_at?: number + updated_at?: number +} + +export type ConversationRenameRequest = { + /** + * (Optional) The name of the conversation. Omit if auto_generate is true. + */ + name?: string + /** + * (Optional) Automatically generate the title. Default false. + */ + auto_generate?: boolean + /** + * The user identifier. + */ + user: string +} + +export type ConversationRenameResponse = ConversationListItem + +export type ConversationVariablesResponse = { + /** + * Number of items per page. */ limit?: number + /** + * Whether there is a next page. + */ + has_more?: boolean + data?: Array +} + +export type ConversationVariableItem = { + /** + * Variable ID. + */ + id?: string + /** + * Variable name. + */ + name?: string + /** + * Variable type (string, number, object, json, etc.). + */ + value_type?: string + /** + * Variable value (can be a JSON string for complex types). + */ + value?: string + /** + * Variable description. + */ + description?: string + /** + * Creation timestamp. + */ + created_at?: number + /** + * Last update timestamp. + */ + updated_at?: number +} + +export type AudioToTextRequest = { + /** + * Audio file. Supported: mp3, mp4, mpeg, mpga, m4a, wav, webm. Limit: 15MB. + */ + file: Blob | File + /** + * User identifier. + */ + user: string +} + +export type AudioToTextResponse = { + /** + * Output text from speech recognition. + */ + text?: string } /** - * SavedMessageCreatePayload + * Requires `user`. Provide either `message_id` or `text`. */ -export type SavedMessageCreatePayload = { +export type TextToAudioFormRequest = { /** - * Message Id + * Message ID (priority if both text and message_id provided). */ - message_id: string + message_id?: string + /** + * Speech content. + */ + text?: string + /** + * User identifier. + */ + user: string } -export type AudioToTextData = { - body?: never - path?: never - query?: never - url: '/audio-to-text' +export type AppInfoResponse = { + name?: string + description?: string + tags?: Array } -export type AudioToTextErrors = { - /** - * Bad Request - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Audio file too large - */ - 413: unknown - /** - * Unsupported audio type - */ - 415: unknown - /** - * Internal Server Error - */ - 500: unknown +export type ChatAppParametersResponse = { + opening_statement?: string + suggested_questions?: Array + suggested_questions_after_answer?: { + enabled?: boolean + } + speech_to_text?: { + enabled?: boolean + } + text_to_speech?: { + enabled?: boolean + voice?: string + language?: string + autoPlay?: 'enabled' | 'disabled' + } + retriever_resource?: { + enabled?: boolean + } + annotation_reply?: { + enabled?: boolean + } + user_input_form?: Array + file_upload?: { + image?: { + enabled?: boolean + number_limits?: number + detail?: string + transfer_methods?: Array<'remote_url' | 'local_file'> + } + } + system_parameters?: { + file_size_limit?: number + image_file_size_limit?: number + audio_file_size_limit?: number + video_file_size_limit?: number + } } -export type AudioToTextResponses = { - /** - * Success - */ - 200: unknown +export type UserInputFormItem = TextInputControlWrapper | ParagraphControlWrapper | SelectControlWrapper + +export type TextInputControlWrapper = { + 'text-input': TextInputControl } -export type CreateChatMessageData = { - body: ChatMessagePayload +export type ParagraphControlWrapper = { + paragraph: ParagraphControl +} + +export type SelectControlWrapper = { + select: SelectControl +} + +export type TextInputControl = { + label: string + variable: string + required: boolean + default?: string +} + +export type ParagraphControl = { + label: string + variable: string + required: boolean + default?: string +} + +export type SelectControl = { + label: string + variable: string + required: boolean + default?: string + options: Array +} + +export type AppMetaResponse = { + /** + * Tool icons. Keys are tool names. + */ + tool_icons?: { + [key: string]: string | ToolIconDetail + } +} + +export type ToolIconDetail = { + /** + * Background color in hex format. + */ + background?: string + /** + * Emoji content. + */ + content?: string +} + +export type WebAppSettingsResponse = { + title?: string + chat_color_theme?: string + chat_color_theme_inverted?: boolean + icon_type?: 'emoji' | 'image' + icon?: string + icon_background?: string + icon_url?: string | null + description?: string + copyright?: string + privacy_policy?: string + custom_disclaimer?: string + default_language?: string + show_workflow_steps?: boolean + use_icon_as_answer_icon?: boolean +} + +export type AnnotationListResponse = { + data?: Array + has_more?: boolean + limit?: number + total?: number + page?: number +} + +export type AnnotationItem = { + id?: string + question?: string + answer?: string + hit_count?: number + created_at?: number +} + +export type CreateAnnotationRequest = { + question: string + answer: string +} + +export type UpdateAnnotationRequest = { + question: string + answer: string +} + +export type InitialAnnotationReplySettingsRequest = { + /** + * Specified embedding model provider name (Optional). + */ + embedding_provider_name?: string + /** + * Specified embedding model name (Optional). + */ + embedding_model_name?: string + /** + * Similarity threshold for matching annotated replies. + */ + score_threshold: number +} + +export type InitialAnnotationReplySettingsResponse = { + job_id?: string + job_status?: string +} + +export type InitialAnnotationReplySettingsStatusResponse = { + job_id?: string + job_status?: string + error_msg?: string | null +} + +export type ErrorResponse = { + status?: number + code?: string + message?: string +} + +export type SendChatMessageData = { + /** + * Request body to send a chat message. + */ + body: ChatRequest path?: never query?: never url: '/chat-messages' } -export type CreateChatMessageErrors = { +export type SendChatMessageErrors = { /** - * Bad Request + * Bad Request. Possible error codes: + * - `invalid_param`: Abnormal parameter input. + * - `app_unavailable`: App configuration unavailable. + * - `provider_not_initialize`: No available model credential configuration. + * - `provider_quota_exceeded`: Model invocation quota insufficient. + * - `model_currently_not_support`: Current model unavailable. + * - `completion_request_error`: Text generation failed. */ - 400: unknown + 400: ErrorResponse /** - * Unauthorized + * Conversation does not exist. */ - 401: unknown + 404: ErrorResponse /** - * Forbidden + * Internal server error. */ - 403: unknown - /** - * App Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + 500: ErrorResponse } -export type CreateChatMessageResponses = { +export type SendChatMessageError = SendChatMessageErrors[keyof SendChatMessageErrors] + +export type SendChatMessageResponses = { /** - * Success + * Successful response. The content type and structure depend on the `response_mode` parameter in the request. + * - If `response_mode` is `blocking`, returns `application/json` with a `ChatCompletionResponse` object. + * - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of `ChunkChatEvent` objects. */ - 200: unknown + 200: ChatCompletionResponse } -export type StopChatMessageData = { +export type SendChatMessageResponse = SendChatMessageResponses[keyof SendChatMessageResponses] + +export type UploadChatFileData = { + /** + * File upload request. Requires multipart/form-data. + */ + body: { + /** + * The file to be uploaded. Supported image types: png, jpg, jpeg, webp, gif. + */ + file: Blob | File + /** + * User identifier, defined by the developer's rules, must be unique within the application. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface. + */ + user: string + } + path?: never + query?: never + url: '/files/upload' +} + +export type UploadChatFileErrors = { + /** + * Bad Request for file operations. Possible error codes: + * - `no_file_uploaded`: A file must be provided. + * - `too_many_files`: Currently only one file is accepted. + * - `unsupported_preview`: The file does not support preview. + * - `unsupported_estimate`: The file does not support estimation. + */ + 400: ErrorResponse + /** + * `file_too_large`: The file is too large. + */ + 413: ErrorResponse + /** + * `unsupported_file_type`: Unsupported extension. (Note: The description for `/files/upload` lists image types, while this generic error mentions document files. This might indicate a context-specific message from the backend). + */ + 415: ErrorResponse + /** + * Internal server error. + */ + 500: ErrorResponse + /** + * Service Unavailable for S3 operations. Possible error codes: + * - `s3_connection_failed`: Unable to connect to S3 service. + * - `s3_permission_denied`: No permission to upload files to S3. + * - `s3_file_too_large`: File exceeds S3 size limit. + */ + 503: ErrorResponse +} + +export type UploadChatFileError = UploadChatFileErrors[keyof UploadChatFileErrors] + +export type UploadChatFileResponses = { + /** + * File uploaded successfully. + */ + 200: FileUploadResponse +} + +export type UploadChatFileResponse = UploadChatFileResponses[keyof UploadChatFileResponses] + +export type PreviewChatFileData = { body?: never path: { /** - * Task ID to stop + * The unique identifier of the file to preview, obtained from the File Upload API response. + */ + file_id: string + } + query?: { + /** + * Whether to force download the file as an attachment. Default is `false` (preview in browser). + */ + as_attachment?: boolean + } + url: '/files/{file_id}/preview' +} + +export type PreviewChatFileErrors = { + /** + * Bad Request. Possible error codes: + * - `invalid_param`: Abnormal parameter input. + */ + 400: ErrorResponse + /** + * Forbidden. Possible error codes: + * - `file_access_denied`: File access denied or file does not belong to current application. + */ + 403: ErrorResponse + /** + * Not Found. Possible error codes: + * - `file_not_found`: File not found or has been deleted. + */ + 404: ErrorResponse + /** + * Internal server error. + */ + 500: ErrorResponse +} + +export type PreviewChatFileError = PreviewChatFileErrors[keyof PreviewChatFileErrors] + +export type PreviewChatFileResponses = { + /** + * File content returned successfully. Headers set based on file type and request parameters. + */ + 200: Blob | File +} + +export type PreviewChatFileResponse = PreviewChatFileResponses[keyof PreviewChatFileResponses] + +export type StopChatMessageGenerationData = { + body: { + /** + * User identifier, must be consistent with the user passed in the send message interface. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface. + */ + user: string + } + path: { + /** + * Task ID, can be obtained from the streaming chunk return of a `/chat-messages` request. */ task_id: string } @@ -654,207 +891,177 @@ export type StopChatMessageData = { url: '/chat-messages/{task_id}/stop' } -export type StopChatMessageErrors = { +export type StopChatMessageGenerationResponses = { /** - * Bad Request + * Operation successful. */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Task Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + 200: { + result?: string + } } -export type StopChatMessageResponses = { - /** - * Success - */ - 200: unknown -} +export type StopChatMessageGenerationResponse = StopChatMessageGenerationResponses[keyof StopChatMessageGenerationResponses] -export type CreateCompletionMessageData = { - body: CompletionMessagePayload - path?: never - query?: never - url: '/completion-messages' -} - -export type CreateCompletionMessageErrors = { - /** - * Bad Request - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * App Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type CreateCompletionMessageResponses = { - /** - * Success - */ - 200: unknown -} - -export type StopCompletionMessageData = { - body?: never +export type PostChatMessageFeedbackData = { + body: MessageFeedbackRequest path: { /** - * Task ID to stop + * Message ID for which feedback is being provided. */ - task_id: string + message_id: string } query?: never - url: '/completion-messages/{task_id}/stop' + url: '/messages/{message_id}/feedbacks' } -export type StopCompletionMessageErrors = { +export type PostChatMessageFeedbackResponses = { /** - * Bad Request + * Operation successful. */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Task Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + 200: { + result?: string + } } -export type StopCompletionMessageResponses = { - /** - * Success - */ - 200: unknown -} +export type PostChatMessageFeedbackResponse = PostChatMessageFeedbackResponses[keyof PostChatMessageFeedbackResponses] -export type GetConversationListData = { +export type GetChatAppFeedbacksData = { body?: never path?: never query?: { /** - * Last conversation ID for pagination + * (optional) Pagination page number. Default: 1 + */ + page?: number + /** + * (optional) Records per page. Default: 20 + */ + limit?: number + } + url: '/app/feedbacks' +} + +export type GetChatAppFeedbacksResponses = { + /** + * A list of application feedbacks. + */ + 200: AppFeedbacksResponse +} + +export type GetChatAppFeedbacksResponse = GetChatAppFeedbacksResponses[keyof GetChatAppFeedbacksResponses] + +export type GetSuggestedQuestionsData = { + body?: never + path: { + /** + * Message ID. + */ + message_id: string + } + query: { + /** + * User identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface. + */ + user: string + } + url: '/messages/{message_id}/suggested' +} + +export type GetSuggestedQuestionsResponses = { + /** + * Successfully retrieved suggested questions. + */ + 200: SuggestedQuestionsResponse +} + +export type GetSuggestedQuestionsResponse = GetSuggestedQuestionsResponses[keyof GetSuggestedQuestionsResponses] + +export type GetConversationHistoryData = { + body?: never + path?: never + query: { + /** + * Conversation ID. + */ + conversation_id: string + /** + * User identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface. + */ + user: string + /** + * The ID of the first chat record on the current page, default is null (for fetching the latest). For subsequent pages, use the ID of the first message from the current list to get older messages. + */ + first_id?: string + /** + * How many chat history messages to return in one request, default is 20. + */ + limit?: number + } + url: '/messages' +} + +export type GetConversationHistoryResponses = { + /** + * Successfully retrieved conversation history. + */ + 200: ConversationHistoryResponse +} + +export type GetConversationHistoryResponse = GetConversationHistoryResponses[keyof GetConversationHistoryResponses] + +export type GetConversationsListData = { + body?: never + path?: never + query: { + /** + * User identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface. + */ + user: string + /** + * (Optional) The ID of the last record on the current page (for pagination). */ last_id?: string /** - * Number of conversations to return (1-100) + * (Optional) How many records to return. Default 20, Min 1, Max 100. */ limit?: number /** - * Filter by pinned status - */ - pinned?: 'true' | 'false' - /** - * Sort order + * Sorting Field. Default: -updated_at. '-' prefix for descending. */ sort_by?: 'created_at' | '-created_at' | 'updated_at' | '-updated_at' } url: '/conversations' } -export type GetConversationListErrors = { +export type GetConversationsListResponses = { /** - * Bad Request + * Successfully retrieved conversations list. */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * App Not Found or Not a Chat App - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + 200: ConversationsListResponse } -export type GetConversationListResponses = { - /** - * Success - */ - 200: unknown -} +export type GetConversationsListResponse = GetConversationsListResponses[keyof GetConversationsListResponses] export type DeleteConversationData = { - body?: never + body: { + /** + * The user identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface. + */ + user: string + } path: { /** - * Conversation UUID + * Conversation ID. */ - c_id: string + conversation_id: string } query?: never - url: '/conversations/{c_id}' -} - -export type DeleteConversationErrors = { - /** - * Bad Request - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Conversation Not Found or Not a Chat App - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + url: '/conversations/{conversation_id}' } export type DeleteConversationResponses = { /** - * Conversation deleted successfully + * Conversation deleted successfully. No Content. */ 204: void } @@ -862,1091 +1069,299 @@ export type DeleteConversationResponses = { export type DeleteConversationResponse = DeleteConversationResponses[keyof DeleteConversationResponses] export type RenameConversationData = { - body?: never + body: ConversationRenameRequest path: { /** - * Conversation UUID + * Conversation ID. */ - c_id: string + conversation_id: string } - query?: { - /** - * New conversation name - */ - name?: string - /** - * Auto-generate conversation name - */ - auto_generate?: boolean - } - url: '/conversations/{c_id}/name' -} - -export type RenameConversationErrors = { - /** - * Bad Request - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Conversation Not Found or Not a Chat App - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + query?: never + url: '/conversations/{conversation_id}/name' } export type RenameConversationResponses = { /** - * Conversation renamed successfully + * Conversation renamed successfully. */ - 200: unknown + 200: ConversationListItem } -export type PinConversationData = { +export type RenameConversationResponse = RenameConversationResponses[keyof RenameConversationResponses] + +export type GetConversationVariablesData = { body?: never path: { /** - * Conversation UUID + * The ID of the conversation to retrieve variables from. */ - c_id: string + conversation_id: string } - query?: never - url: '/conversations/{c_id}/pin' -} - -export type PinConversationErrors = { - /** - * Bad Request - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Conversation Not Found or Not a Chat App - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type PinConversationResponses = { - /** - * Conversation pinned successfully - */ - 200: unknown -} - -export type UnpinConversationData = { - body?: never - path: { + query: { /** - * Conversation UUID + * The user identifier. */ - c_id: string + user: string + /** + * (Optional) The ID of the last record on the current page (for pagination). + */ + last_id?: string + /** + * (Optional) How many records to return. Default 20, Min 1, Max 100. + */ + limit?: number + /** + * (Optional) Filter variables by a specific name. + */ + variable_name?: string } - query?: never - url: '/conversations/{c_id}/unpin' + url: '/conversations/{conversation_id}/variables' } -export type UnpinConversationErrors = { +export type GetConversationVariablesErrors = { /** - * Bad Request + * Conversation not found. Error code: `conversation_not_exists` */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Conversation Not Found or Not a Chat App - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + 404: ErrorResponse } -export type UnpinConversationResponses = { +export type GetConversationVariablesError = GetConversationVariablesErrors[keyof GetConversationVariablesErrors] + +export type GetConversationVariablesResponses = { /** - * Conversation unpinned successfully + * Successfully retrieved conversation variables. */ - 200: unknown + 200: ConversationVariablesResponse } -export type SendEmailCodeLoginData = { - body: EmailCodeLoginSendPayload +export type GetConversationVariablesResponse = GetConversationVariablesResponses[keyof GetConversationVariablesResponses] + +export type AudioToTextData = { + body: AudioToTextRequest path?: never query?: never - url: '/email-code-login' + url: '/audio-to-text' } -export type SendEmailCodeLoginErrors = { +export type AudioToTextResponses = { /** - * Bad request - invalid email format + * Successfully converted audio to text. */ - 400: unknown - /** - * Account not found - */ - 404: unknown + 200: AudioToTextResponse } -export type SendEmailCodeLoginResponses = { - /** - * Email code sent successfully - */ - 200: unknown -} +export type AudioToTextResponse2 = AudioToTextResponses[keyof AudioToTextResponses] -export type VerifyEmailCodeLoginData = { - body: EmailCodeLoginVerifyPayload +export type TextToAudioChatData = { + body: TextToAudioFormRequest path?: never query?: never - url: '/email-code-login/validity' + url: '/text-to-audio' } -export type VerifyEmailCodeLoginErrors = { +export type TextToAudioChatResponses = { /** - * Bad request - invalid code or token + * The generated audio file. */ - 400: unknown - /** - * Invalid token or expired code - */ - 401: unknown - /** - * Account not found - */ - 404: unknown + 200: Blob | File } -export type VerifyEmailCodeLoginResponses = { - /** - * Email code verified and login successful - */ - 200: unknown -} +export type TextToAudioChatResponse = TextToAudioChatResponses[keyof TextToAudioChatResponses] -export type UploadFileData = { +export type GetChatAppInfoData = { body?: never path?: never query?: never - url: '/files/upload' + url: '/info' } -export type UploadFileErrors = { +export type GetChatAppInfoResponses = { /** - * Bad request - invalid file or parameters + * Basic information of the application. */ - 400: unknown - /** - * File too large - */ - 413: unknown - /** - * Unsupported file type - */ - 415: unknown + 200: AppInfoResponse } -export type UploadFileResponses = { - /** - * File uploaded successfully - */ - 201: FileResponse -} +export type GetChatAppInfoResponse = GetChatAppInfoResponses[keyof GetChatAppInfoResponses] -export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses] - -export type SendForgotPasswordEmailData = { - body: ForgotPasswordSendPayload - path?: never - query?: never - url: '/forgot-password' -} - -export type SendForgotPasswordEmailErrors = { - /** - * Bad request - invalid email format - */ - 400: unknown - /** - * Account not found - */ - 404: unknown - /** - * Too many requests - rate limit exceeded - */ - 429: unknown -} - -export type SendForgotPasswordEmailResponses = { - /** - * Password reset email sent successfully - */ - 200: unknown -} - -export type ResetPasswordData = { - body: ForgotPasswordResetPayload - path?: never - query?: never - url: '/forgot-password/resets' -} - -export type ResetPasswordErrors = { - /** - * Bad request - invalid parameters or password mismatch - */ - 400: unknown - /** - * Invalid or expired token - */ - 401: unknown - /** - * Account not found - */ - 404: unknown -} - -export type ResetPasswordResponses = { - /** - * Password reset successfully - */ - 200: unknown -} - -export type CheckForgotPasswordTokenData = { - body: ForgotPasswordCheckPayload - path?: never - query?: never - url: '/forgot-password/validity' -} - -export type CheckForgotPasswordTokenErrors = { - /** - * Bad request - invalid token format - */ - 400: unknown - /** - * Invalid or expired token - */ - 401: unknown -} - -export type CheckForgotPasswordTokenResponses = { - /** - * Token is valid - */ - 200: unknown -} - -export type WebAppLoginData = { - body: LoginPayload - path?: never - query?: never - url: '/login' -} - -export type WebAppLoginErrors = { - /** - * Bad request - invalid email or password format - */ - 400: unknown - /** - * Authentication failed - email or password mismatch - */ - 401: unknown - /** - * Account banned or login disabled - */ - 403: unknown - /** - * Account not found - */ - 404: unknown -} - -export type WebAppLoginResponses = { - /** - * Authentication successful - */ - 200: unknown -} - -export type WebAppLoginStatusData = { - body?: never - path?: never - query?: never - url: '/login/status' -} - -export type WebAppLoginStatusErrors = { - /** - * Login status - */ - 401: unknown -} - -export type WebAppLoginStatusResponses = { - /** - * Login status - */ - 200: unknown -} - -export type WebAppLogoutData = { - body?: never - path?: never - query?: never - url: '/logout' -} - -export type WebAppLogoutResponses = { - /** - * Logout successful - */ - 200: unknown -} - -export type GetMessageListData = { +export type GetChatAppParametersData = { body?: never path?: never query: { /** - * Conversation UUID + * User identifier, defined by the developer's rules, must be unique within the application. */ - conversation_id: string - /** - * First message ID for pagination - */ - first_id?: string - /** - * Number of messages to return (1-100) - */ - limit?: number + user: string } - url: '/messages' + url: '/parameters' } -export type GetMessageListErrors = { +export type GetChatAppParametersResponses = { /** - * Bad Request + * Application parameters information. */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Conversation Not Found or Not a Chat App - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + 200: ChatAppParametersResponse } -export type GetMessageListResponses = { - /** - * Success - */ - 200: unknown -} +export type GetChatAppParametersResponse = GetChatAppParametersResponses[keyof GetChatAppParametersResponses] -export type CreateMessageFeedbackData = { - body?: never - path: { - /** - * Message UUID - */ - message_id: string - } - query?: { - /** - * Feedback rating - */ - rating?: 'like' | 'dislike' - /** - * Feedback content - */ - content?: string - } - url: '/messages/{message_id}/feedbacks' -} - -export type CreateMessageFeedbackErrors = { - /** - * Bad Request - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Message Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type CreateMessageFeedbackResponses = { - /** - * Feedback submitted successfully - */ - 200: unknown -} - -export type GenerateMoreLikeThisData = { - body: MessageMoreLikeThisQuery - path: { - message_id: string - } - query?: never - url: '/messages/{message_id}/more-like-this' -} - -export type GenerateMoreLikeThisErrors = { - /** - * Bad Request - Not a completion app or feature disabled - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Message Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type GenerateMoreLikeThisResponses = { - /** - * Success - */ - 200: unknown -} - -export type GetSuggestedQuestionsData = { - body?: never - path: { - /** - * Message UUID - */ - message_id: string - } - query?: never - url: '/messages/{message_id}/suggested-questions' -} - -export type GetSuggestedQuestionsErrors = { - /** - * Bad Request - Not a chat app or feature disabled - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Message Not Found or Conversation Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type GetSuggestedQuestionsResponses = { - /** - * Success - */ - 200: unknown -} - -export type GetAppMetaData = { +export type GetChatAppMetaData = { body?: never path?: never query?: never url: '/meta' } -export type GetAppMetaErrors = { +export type GetChatAppMetaResponses = { /** - * Bad Request + * Successfully retrieved application meta information. */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * App Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + 200: AppMetaResponse } -export type GetAppMetaResponses = { - /** - * Success - */ - 200: unknown -} +export type GetChatAppMetaResponse = GetChatAppMetaResponses[keyof GetChatAppMetaResponses] -export type GetAppParametersData = { - body?: never - path?: never - query?: never - url: '/parameters' -} - -export type GetAppParametersErrors = { - /** - * Bad Request - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * App Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type GetAppParametersResponses = { - /** - * Success - */ - 200: unknown -} - -export type GetPassportData = { - body?: never - path?: never - query?: never - url: '/passport' -} - -export type GetPassportErrors = { - /** - * Unauthorized - missing app code or invalid authentication - */ - 401: unknown - /** - * Application or user not found - */ - 404: unknown -} - -export type GetPassportResponses = { - /** - * Passport retrieved successfully - */ - 200: unknown -} - -export type UploadRemoteFileData = { - body?: never - path?: never - query?: never - url: '/remote-files/upload' -} - -export type UploadRemoteFileErrors = { - /** - * Bad request - invalid URL or parameters - */ - 400: unknown - /** - * File too large - */ - 413: unknown - /** - * Unsupported file type - */ - 415: unknown - /** - * Failed to fetch remote file - */ - 500: unknown -} - -export type UploadRemoteFileResponses = { - /** - * Remote file uploaded successfully - */ - 201: FileWithSignedUrl -} - -export type UploadRemoteFileResponse = UploadRemoteFileResponses[keyof UploadRemoteFileResponses] - -export type GetRemoteFileInfoData = { - body?: never - path: { - url: string - } - query?: never - url: '/remote-files/{url}' -} - -export type GetRemoteFileInfoErrors = { - /** - * Bad request - invalid URL - */ - 400: unknown - /** - * Remote file not found - */ - 404: unknown - /** - * Failed to fetch remote file - */ - 500: unknown -} - -export type GetRemoteFileInfoResponses = { - /** - * Remote file information retrieved successfully - */ - 200: RemoteFileInfo -} - -export type GetRemoteFileInfoResponse = GetRemoteFileInfoResponses[keyof GetRemoteFileInfoResponses] - -export type GetSavedMessagesData = { - body?: never - path?: never - query?: { - /** - * Last message ID for pagination - */ - last_id?: string - /** - * Number of messages to return (1-100) - */ - limit?: number - } - url: '/saved-messages' -} - -export type GetSavedMessagesErrors = { - /** - * Bad Request - Not a completion app - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * App Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type GetSavedMessagesResponses = { - /** - * Success - */ - 200: unknown -} - -export type SaveMessageData = { - body?: never - path?: never - query: { - /** - * Message UUID to save - */ - message_id: string - } - url: '/saved-messages' -} - -export type SaveMessageErrors = { - /** - * Bad Request - Not a completion app - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Message Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type SaveMessageResponses = { - /** - * Message saved successfully - */ - 200: unknown -} - -export type DeleteSavedMessageData = { - body?: never - path: { - /** - * Message UUID to delete - */ - message_id: string - } - query?: never - url: '/saved-messages/{message_id}' -} - -export type DeleteSavedMessageErrors = { - /** - * Bad Request - Not a completion app - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Message Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type DeleteSavedMessageResponses = { - /** - * Message removed successfully - */ - 204: void -} - -export type DeleteSavedMessageResponse = DeleteSavedMessageResponses[keyof DeleteSavedMessageResponses] - -export type GetAppSiteInfoData = { +export type GetChatWebAppSettingsData = { body?: never path?: never query?: never url: '/site' } -export type GetAppSiteInfoErrors = { +export type GetChatWebAppSettingsResponses = { /** - * Bad Request + * WebApp settings of the application. */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * App Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + 200: WebAppSettingsResponse } -export type GetAppSiteInfoResponses = { - /** - * Success - */ - 200: unknown -} +export type GetChatWebAppSettingsResponse = GetChatWebAppSettingsResponses[keyof GetChatWebAppSettingsResponses] -export type GetSystemFeaturesData = { - body?: never - path?: never - query?: never - url: '/system-features' -} - -export type GetSystemFeaturesErrors = { - /** - * Internal server error - */ - 500: unknown -} - -export type GetSystemFeaturesResponses = { - /** - * System features retrieved successfully - */ - 200: unknown -} - -export type TextToAudioData = { - body: TextToAudioPayload - path?: never - query?: never - url: '/text-to-audio' -} - -export type TextToAudioErrors = { - /** - * Bad Request - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type TextToAudioResponses = { - /** - * Success - */ - 200: unknown -} - -export type GetAppAccessModeData = { +export type GetAnnotationListData = { body?: never path?: never query?: { /** - * Application ID + * Page number. */ - appId?: string + page?: number /** - * Application code + * Number of items returned, default 20, range 1-100. */ - appCode?: string + limit?: number } - url: '/webapp/access-mode' + url: '/apps/annotations' } -export type GetAppAccessModeErrors = { +export type GetAnnotationListResponses = { /** - * Bad Request + * Successfully retrieved annotation list. */ - 400: unknown - /** - * Internal Server Error - */ - 500: unknown + 200: AnnotationListResponse } -export type GetAppAccessModeResponses = { - /** - * Success - */ - 200: unknown -} +export type GetAnnotationListResponse = GetAnnotationListResponses[keyof GetAnnotationListResponses] -export type CheckAppPermissionData = { - body?: never - path?: never - query: { - /** - * Application ID - */ - appId: string - } - url: '/webapp/permission' -} - -export type CheckAppPermissionErrors = { - /** - * Bad Request - */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Internal Server Error - */ - 500: unknown -} - -export type CheckAppPermissionResponses = { - /** - * Success - */ - 200: unknown -} - -export type RunWorkflowData = { - body: WorkflowRunPayload +export type CreateAnnotationData = { + body: CreateAnnotationRequest path?: never query?: never - url: '/workflows/run' + url: '/apps/annotations' } -export type RunWorkflowErrors = { +export type CreateAnnotationResponses = { /** - * Bad Request + * Annotation created successfully. */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * App Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + 200: AnnotationItem } -export type RunWorkflowResponses = { - /** - * Success - */ - 200: unknown -} +export type CreateAnnotationResponse = CreateAnnotationResponses[keyof CreateAnnotationResponses] -export type StopWorkflowTaskData = { +export type DeleteAnnotationData = { body?: never path: { /** - * Task ID to stop + * Annotation ID. */ - task_id: string + annotation_id: string } query?: never - url: '/workflows/tasks/{task_id}/stop' + url: '/apps/annotations/{annotation_id}' } -export type StopWorkflowTaskErrors = { +export type DeleteAnnotationResponses = { /** - * Bad Request + * Annotation deleted successfully. No Content. */ - 400: unknown - /** - * Unauthorized - */ - 401: unknown - /** - * Forbidden - */ - 403: unknown - /** - * Task Not Found - */ - 404: unknown - /** - * Internal Server Error - */ - 500: unknown + 204: void } -export type StopWorkflowTaskResponses = { - /** - * Success - */ - 200: unknown +export type DeleteAnnotationResponse = DeleteAnnotationResponses[keyof DeleteAnnotationResponses] + +export type UpdateAnnotationData = { + body: UpdateAnnotationRequest + path: { + /** + * Annotation ID. + */ + annotation_id: string + } + query?: never + url: '/apps/annotations/{annotation_id}' } + +export type UpdateAnnotationResponses = { + /** + * Annotation updated successfully. + */ + 200: AnnotationItem +} + +export type UpdateAnnotationResponse = UpdateAnnotationResponses[keyof UpdateAnnotationResponses] + +export type InitialAnnotationReplySettingsData = { + body: InitialAnnotationReplySettingsRequest + path: { + /** + * Action, can only be 'enable' or 'disable'. + */ + action: 'enable' | 'disable' + } + query?: never + url: '/apps/annotation-reply/{action}' +} + +export type InitialAnnotationReplySettingsResponses = { + /** + * Annotation reply settings task initiated. + */ + 200: InitialAnnotationReplySettingsResponse +} + +export type InitialAnnotationReplySettingsResponse2 = InitialAnnotationReplySettingsResponses[keyof InitialAnnotationReplySettingsResponses] + +export type GetInitialAnnotationReplySettingsStatusData = { + body?: never + path: { + /** + * Action, must be the same as in the initial settings call ('enable' or 'disable'). + */ + action: 'enable' | 'disable' + /** + * Job ID obtained from the initial settings call. + */ + job_id: string + } + query?: never + url: '/apps/annotation-reply/{action}/status/{job_id}' +} + +export type GetInitialAnnotationReplySettingsStatusResponses = { + /** + * Successfully retrieved task status. + */ + 200: InitialAnnotationReplySettingsStatusResponse +} + +export type GetInitialAnnotationReplySettingsStatusResponse = GetInitialAnnotationReplySettingsStatusResponses[keyof GetInitialAnnotationReplySettingsStatusResponses] diff --git a/web/gen/zod.gen.ts b/web/gen/zod.gen.ts index 43763bffd2..c88c85c305 100644 --- a/web/gen/zod.gen.ts +++ b/web/gen/zod.gen.ts @@ -2,328 +2,774 @@ import { z } from 'zod' -/** - * TextToAudioPayload - */ -export const zTextToAudioPayload = z.object({ - message_id: z.record(z.unknown()).optional(), - voice: z.record(z.unknown()).optional(), - text: z.record(z.unknown()).optional(), - streaming: z.record(z.unknown()).optional(), +export const zInputFileObject = z.intersection(z.union([ + z.object({ + transfer_method: z.enum(['remote_url']).optional(), + url: z.string(), + }), + z.object({ + transfer_method: z.enum(['local_file']).optional(), + upload_file_id: z.string(), + }), +]), z.object({ + type: z.enum(['image']).describe('Supported type: `image`.'), + transfer_method: z.enum(['remote_url', 'local_file']).describe('Transfer method, `remote_url` for image URL / `local_file` for file upload'), + url: z.string().describe('Image URL (when the transfer method is `remote_url`)').optional(), + upload_file_id: z.string().describe('Uploaded file ID, which must be obtained by uploading through the File Upload API in advance (when the transfer method is `local_file`)').optional(), +})) + +export type InputFileObjectZodType = z.infer + +export const zChatRequest = z.object({ + query: z.string().describe('User Input/Question content.'), + inputs: z.record(z.unknown()).describe('Allows the entry of various variable values defined by the App. Contains key/value pairs. Default {}.').optional().default({}), + response_mode: z.enum(['streaming', 'blocking']).describe('Mode of response return. `streaming` (recommended) uses SSE. `blocking` returns after completion (may be interrupted for long processes; not supported in Agent Assistant mode). Cloudflare timeout is 100s.').optional(), + user: z.string().describe('User identifier, unique within the application. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.'), + conversation_id: z.string().describe('Conversation ID to continue a conversation. Pass the previous message\'s conversation_id.').optional(), + files: z.array(zInputFileObject).describe('File list (images) for Vision-capable models.').optional(), + auto_generate_name: z.boolean().describe('Auto-generate conversation title. Default `true`. If `false`, use conversation rename API with `auto_generate: true` for async title generation.').optional().default(true), }) -export type TextToAudioPayloadZodType = z.infer +export type ChatRequestZodType = z.infer /** - * CompletionMessagePayload + * Base schema for Server-Sent Event chunks in streaming mode. */ -export const zCompletionMessagePayload = z.object({ - inputs: z.record(z.unknown()).describe('Input variables for the completion'), - query: z.string().describe('Query text for completion').optional().default(''), - files: z.record(z.unknown()).describe('Files to be processed').optional(), - response_mode: z.record(z.unknown()).describe('Response mode: blocking or streaming').optional(), - retriever_from: z.string().describe('Source of retriever').optional().default('web_app'), +export const zChunkChatEvent = z.object({ + event: z.enum([ + 'message', + 'agent_message', + 'tts_message', + 'tts_message_end', + 'agent_thought', + 'message_file', + 'message_end', + 'message_replace', + 'error', + 'ping', + ]).describe('The type of event.'), +}).describe('Base schema for Server-Sent Event chunks in streaming mode.') + +export type ChunkChatEventZodType = z.infer + +export const zStreamEventBase = z.object({ + task_id: z.string().uuid().describe('Task ID.').optional(), + message_id: z.string().uuid().describe('Unique message ID.').optional(), + conversation_id: z.string().uuid().describe('Conversation ID.').optional(), + created_at: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).describe('Creation timestamp.').optional(), }) -export type CompletionMessagePayloadZodType = z.infer +export type StreamEventBaseZodType = z.infer + +export const zStreamEventChatMessage = zChunkChatEvent.and(zStreamEventBase).and(z.object({ + answer: z.string().describe('LLM returned text chunk.'), + event: z.literal('message'), +})) + +export type StreamEventChatMessageZodType = z.infer + +export const zStreamEventChatAgentMessage = zChunkChatEvent.and(zStreamEventBase).and(z.object({ + answer: z.string().describe('LLM returned text chunk (Agent mode).'), + event: z.literal('agent_message'), +})) + +export type StreamEventChatAgentMessageZodType = z.infer + +export const zStreamEventChatTtsMessage = zChunkChatEvent.and(zStreamEventBase).and(z.object({ + audio: z.string().describe('Base64 encoded audio chunk.'), + event: z.literal('tts_message'), +}).describe('TTS audio stream event (base64 encoded Mp3). Available if auto-play enabled.')) + +export type StreamEventChatTtsMessageZodType = z.infer + +export const zStreamEventChatTtsMessageEnd = zChunkChatEvent.and(zStreamEventBase).and(z.object({ + audio: z.string().describe('Empty string for end event.'), + event: z.literal('tts_message_end'), +}).describe('TTS audio stream end event.')) + +export type StreamEventChatTtsMessageEndZodType = z.infer + +export const zStreamEventChatAgentThought = zChunkChatEvent.and(zStreamEventBase).and(z.object({ + id: z.string().uuid().describe('Agent thought ID.'), + position: z.number().int().describe('Position of this thought in the sequence for the message.'), + thought: z.string().describe('What LLM is thinking.').optional(), + observation: z.string().describe('Response from tool calls.').optional(), + tool: z.string().describe('List of tools called, split by \';\'.').optional(), + tool_input: z.string().describe('Input of tools in JSON format. Example: {"dalle3": {"prompt": "a cute cat"}}.').optional(), + message_files: z.array(z.string().uuid()).describe('File IDs of files related to this thought (e.g., generated by a tool).').optional(), + event: z.literal('agent_thought'), +}).describe('Agent thought, LLM thinking, tool call details (Agent mode).')) + +export type StreamEventChatAgentThoughtZodType = z.infer + +export const zStreamEventChatMessageFile = zChunkChatEvent.and(z.object({ + id: z.string().uuid().describe('File unique ID.'), + type: z.enum(['image']).describe('File type, currently only \'image\'.'), + belongs_to: z.enum(['assistant']).describe('Who this file belongs to, always \'assistant\' here.'), + url: z.string().describe('Remote URL of the file.'), + conversation_id: z.string().uuid().describe('Conversation ID.'), + event: z.literal('message_file'), +}).describe('Message file event, a new file created by a tool.')) + +export type StreamEventChatMessageFileZodType = z.infer + +export const zStreamEventChatMessageReplace = zChunkChatEvent.and(zStreamEventBase).and(z.object({ + answer: z.string().describe('Replacement content.'), + event: z.literal('message_replace'), +}).describe('Message content replacement event (e.g., due to content moderation).')) + +export type StreamEventChatMessageReplaceZodType = z.infer + +export const zStreamEventChatError = zChunkChatEvent.and(zStreamEventBase).and(z.object({ + status: z.number().int().describe('HTTP status code.'), + code: z.string().describe('Error code.'), + message: z.string().describe('Error message.'), + event: z.literal('error'), +}).describe('Error event during streaming.')) + +export type StreamEventChatErrorZodType = z.infer + +export const zStreamEventChatPing = zChunkChatEvent.and(z.object({ + event: z.literal('ping'), +}).describe('Ping event to keep connection alive.')) + +export type StreamEventChatPingZodType = z.infer /** - * ChatMessagePayload + * Model usage information. */ -export const zChatMessagePayload = z.object({ - inputs: z.record(z.unknown()).describe('Input variables for the chat'), - query: z.string().describe('User query/message'), - files: z.record(z.unknown()).describe('Files to be processed').optional(), - response_mode: z.record(z.unknown()).describe('Response mode: blocking or streaming').optional(), - conversation_id: z.record(z.unknown()).describe('Conversation ID').optional(), - parent_message_id: z.record(z.unknown()).describe('Parent message ID').optional(), - retriever_from: z.string().describe('Source of retriever').optional().default('web_app'), +export const zUsage = z.object({ + prompt_tokens: z.number().int().optional(), + prompt_unit_price: z.string().optional(), + prompt_price_unit: z.string().optional(), + prompt_price: z.string().optional(), + completion_tokens: z.number().int().optional(), + completion_unit_price: z.string().optional(), + completion_price_unit: z.string().optional(), + completion_price: z.string().optional(), + total_tokens: z.number().int().optional(), + total_price: z.string().optional(), + currency: z.string().optional(), + latency: z.number().optional(), +}).describe('Model usage information.') + +export type UsageZodType = z.infer + +/** + * Citation and Attribution information for a resource. + */ +export const zRetrieverResource = z.object({ + position: z.number().int().describe('Position of the resource in the list.').optional(), + dataset_id: z.string().uuid().describe('ID of the dataset.').optional(), + dataset_name: z.string().describe('Name of the dataset.').optional(), + document_id: z.string().uuid().describe('ID of the document.').optional(), + document_name: z.string().describe('Name of the document.').optional(), + segment_id: z.string().uuid().describe('ID of the specific segment within the document.').optional(), + score: z.number().describe('Relevance score of the resource.').optional(), + content: z.string().describe('Content snippet from the resource.').optional(), +}).describe('Citation and Attribution information for a resource.') + +export type RetrieverResourceZodType = z.infer + +/** + * Response object for blocking mode chat completion. + */ +export const zChatCompletionResponse = z.object({ + event: z.string().describe('Event type, fixed as `message`.').optional(), + task_id: z.string().uuid().describe('Task ID for request tracking and stop response API.').optional(), + id: z.string().uuid().describe('Unique ID of this response/message event.').optional(), + message_id: z.string().uuid().describe('Unique message ID.').optional(), + conversation_id: z.string().uuid().describe('Conversation ID.').optional(), + mode: z.string().describe('App mode, fixed as `chat`.').optional(), + answer: z.string().describe('Complete response content.').optional(), + metadata: z.object({ + usage: zUsage.optional(), + retriever_resources: z.array(zRetrieverResource).optional(), + }).optional(), + created_at: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).describe('Message creation timestamp (Unix epoch seconds).').optional(), +}).describe('Response object for blocking mode chat completion.') + +export type ChatCompletionResponseZodType = z.infer + +export const zStreamEventChatMessageEnd = zChunkChatEvent.and(zStreamEventBase).and(z.object({ + metadata: z.object({ + usage: zUsage.optional(), + retriever_resources: z.array(zRetrieverResource).optional(), + }), + event: z.literal('message_end'), +}).describe('Message end event, streaming has ended.')) + +export type StreamEventChatMessageEndZodType = z.infer + +export const zFileUploadResponse = z.object({ + id: z.string().uuid().optional(), + name: z.string().optional(), + size: z.number().int().optional(), + extension: z.string().optional(), + mime_type: z.string().optional(), + created_by: z.string().uuid().optional(), + created_at: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).optional(), }) -export type ChatMessagePayloadZodType = z.infer +export type FileUploadResponseZodType = z.infer -/** - * FileResponse - */ -export const zFileResponse = z.object({ - id: z.string(), - name: z.string(), - size: z.number().int(), - extension: z.record(z.unknown()).optional(), - mime_type: z.record(z.unknown()).optional(), - created_by: z.record(z.unknown()).optional(), - created_at: z.record(z.unknown()).optional(), - preview_url: z.record(z.unknown()).optional(), - source_url: z.record(z.unknown()).optional(), - original_url: z.record(z.unknown()).optional(), - user_id: z.record(z.unknown()).optional(), - tenant_id: z.record(z.unknown()).optional(), - conversation_id: z.record(z.unknown()).optional(), - file_key: z.record(z.unknown()).optional(), +export const zMessageFeedbackRequest = z.object({ + rating: z.enum(['like', 'dislike']).nullable().optional(), + user: z.string(), + content: z.string().optional(), }) -export type FileResponseZodType = z.infer +export type MessageFeedbackRequestZodType = z.infer -/** - * ForgotPasswordSendPayload - */ -export const zForgotPasswordSendPayload = z.object({ - email: z.string(), - language: z.record(z.unknown()).optional(), +export const zFeedbackItem = z.object({ + id: z.string().uuid().optional(), + app_id: z.string().uuid().optional(), + conversation_id: z.string().uuid().optional(), + message_id: z.string().uuid().optional(), + rating: z.enum(['like', 'dislike']).nullable().optional(), + content: z.string().optional(), + from_source: z.string().optional(), + from_end_user_id: z.string().uuid().optional(), + from_account_id: z.union([ + z.string().uuid(), + z.null(), + ]).optional(), + created_at: z.string().datetime().optional(), + updated_at: z.string().datetime().optional(), }) -export type ForgotPasswordSendPayloadZodType = z.infer +export type FeedbackItemZodType = z.infer -/** - * ForgotPasswordCheckPayload - */ -export const zForgotPasswordCheckPayload = z.object({ - email: z.string(), - code: z.string(), - token: z.string().min(1), +export const zAppFeedbacksResponse = z.object({ + data: z.array(zFeedbackItem).optional(), }) -export type ForgotPasswordCheckPayloadZodType = z.infer +export type AppFeedbacksResponseZodType = z.infer -/** - * ForgotPasswordResetPayload - */ -export const zForgotPasswordResetPayload = z.object({ - token: z.string().min(1), - new_password: z.string(), - password_confirm: z.string(), +export const zSuggestedQuestionsResponse = z.object({ + result: z.string().optional(), + data: z.array(z.string()).optional(), }) -export type ForgotPasswordResetPayloadZodType = z.infer +export type SuggestedQuestionsResponseZodType = z.infer -/** - * LoginPayload - */ -export const zLoginPayload = z.object({ - email: z.string(), - password: z.string(), +export const zMessageFileItem = z.object({ + id: z.string().uuid().optional(), + type: z.string().describe('File type, e.g., \'image\'.').optional(), + url: z.string().describe('Preview image URL.').optional(), + belongs_to: z.enum(['user', 'assistant']).describe('Who this file belongs to.').optional(), }) -export type LoginPayloadZodType = z.infer +export type MessageFileItemZodType = z.infer -/** - * EmailCodeLoginSendPayload - */ -export const zEmailCodeLoginSendPayload = z.object({ - email: z.string(), - language: z.record(z.unknown()).optional(), +export const zAgentThoughtItem = z.object({ + id: z.string().uuid().describe('Agent thought ID.').optional(), + message_id: z.string().uuid().describe('Unique message ID this thought belongs to.').optional(), + position: z.number().int().describe('Position of this thought.').optional(), + thought: z.string().describe('What LLM is thinking.').optional(), + tool: z.string().describe('Tools called, split by \';\'.').optional(), + tool_input: z.string().describe('Input of tools in JSON format.').optional(), + observation: z.string().describe('Response from tool calls.').optional(), + files: z.array(z.string().uuid()).describe('File IDs related to this thought (from example, Markdown text says \'message_files\').').optional(), + created_at: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).describe('Creation timestamp.').optional(), }) -export type EmailCodeLoginSendPayloadZodType = z.infer +export type AgentThoughtItemZodType = z.infer -/** - * EmailCodeLoginVerifyPayload - */ -export const zEmailCodeLoginVerifyPayload = z.object({ - email: z.string(), - code: z.string(), - token: z.string().min(1), +export const zConversationMessageItem = z.object({ + id: z.string().uuid().optional(), + conversation_id: z.string().uuid().optional(), + inputs: z.record(z.unknown()).optional(), + query: z.string().optional(), + answer: z.string().optional(), + message_files: z.array(zMessageFileItem).optional(), + feedback: z.union([ + z.object({ + rating: z.enum(['like', 'dislike']).optional(), + }), + z.null(), + ]).optional(), + retriever_resources: z.array(zRetrieverResource).optional(), + agent_thoughts: z.array(zAgentThoughtItem).optional(), + created_at: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).optional(), }) -export type EmailCodeLoginVerifyPayloadZodType = z.infer +export type ConversationMessageItemZodType = z.infer -/** - * MessageMoreLikeThisQuery - */ -export const zMessageMoreLikeThisQuery = z.object({ - response_mode: z.enum(['blocking', 'streaming']).describe('Response mode'), +export const zConversationHistoryResponse = z.object({ + limit: z.number().int().optional(), + has_more: z.boolean().optional(), + data: z.array(zConversationMessageItem).optional(), }) -export type MessageMoreLikeThisQueryZodType = z.infer +export type ConversationHistoryResponseZodType = z.infer -/** - * RemoteFileInfo - */ -export const zRemoteFileInfo = z.object({ - file_type: z.string(), - file_length: z.number().int(), +export const zConversationListItem = z.object({ + id: z.string().uuid().optional(), + name: z.string().optional(), + inputs: z.record(z.unknown()).optional(), + status: z.string().optional(), + introduction: z.string().optional(), + created_at: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).optional(), + updated_at: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).optional(), }) -export type RemoteFileInfoZodType = z.infer +export type ConversationListItemZodType = z.infer -/** - * FileWithSignedUrl - */ -export const zFileWithSignedUrl = z.object({ - id: z.string(), - name: z.string(), - size: z.number().int(), - extension: z.record(z.unknown()).optional(), - url: z.record(z.unknown()).optional(), - mime_type: z.record(z.unknown()).optional(), - created_by: z.record(z.unknown()).optional(), - created_at: z.record(z.unknown()).optional(), +export const zConversationsListResponse = z.object({ + limit: z.number().int().optional(), + has_more: z.boolean().optional(), + data: z.array(zConversationListItem).optional(), }) -export type FileWithSignedUrlZodType = z.infer +export type ConversationsListResponseZodType = z.infer -/** - * WorkflowRunPayload - */ -export const zWorkflowRunPayload = z.object({ - inputs: z.record(z.unknown()).describe('Input variables for the workflow'), - files: z.record(z.unknown()).describe('Files to be processed by the workflow').optional(), +export const zConversationRenameRequest = z.object({ + name: z.string().describe('(Optional) The name of the conversation. Omit if auto_generate is true.').optional(), + auto_generate: z.boolean().describe('(Optional) Automatically generate the title. Default false.').optional().default(false), + user: z.string().describe('The user identifier.'), }) -export type WorkflowRunPayloadZodType = z.infer +export type ConversationRenameRequestZodType = z.infer -/** - * AppAccessModeQuery - */ -export const zAppAccessModeQuery = z.object({ - appId: z.record(z.unknown()).describe('Application ID').optional(), - appCode: z.record(z.unknown()).describe('Application code').optional(), +export const zConversationRenameResponse = zConversationListItem + +export type ConversationRenameResponseZodType = z.infer + +export const zConversationVariableItem = z.object({ + id: z.string().uuid().describe('Variable ID.').optional(), + name: z.string().describe('Variable name.').optional(), + value_type: z.string().describe('Variable type (string, number, object, json, etc.).').optional(), + value: z.string().describe('Variable value (can be a JSON string for complex types).').optional(), + description: z.string().describe('Variable description.').optional(), + created_at: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).describe('Creation timestamp.').optional(), + updated_at: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).describe('Last update timestamp.').optional(), }) -export type AppAccessModeQueryZodType = z.infer +export type ConversationVariableItemZodType = z.infer + +export const zConversationVariablesResponse = z.object({ + limit: z.number().int().describe('Number of items per page.').optional(), + has_more: z.boolean().describe('Whether there is a next page.').optional(), + data: z.array(zConversationVariableItem).optional(), +}) + +export type ConversationVariablesResponseZodType = z.infer + +export const zAudioToTextRequest = z.object({ + file: z.string().describe('Audio file. Supported: mp3, mp4, mpeg, mpga, m4a, wav, webm. Limit: 15MB.'), + user: z.string().describe('User identifier.'), +}) + +export type AudioToTextRequestZodType = z.infer + +export const zAudioToTextResponse = z.object({ + text: z.string().describe('Output text from speech recognition.').optional(), +}) + +export type AudioToTextResponseZodType = z.infer /** - * ConversationListQuery + * Requires `user`. Provide either `message_id` or `text`. */ -export const zConversationListQuery = z.object({ - last_id: z.record(z.unknown()).optional(), - limit: z.number().int().gte(1).lte(100).optional(), - pinned: z.record(z.unknown()).optional(), - sort_by: z.enum([ - 'created_at', - '-created_at', - 'updated_at', - '-updated_at', +export const zTextToAudioFormRequest = z.object({ + message_id: z.string().uuid().describe('Message ID (priority if both text and message_id provided).').optional(), + text: z.string().describe('Speech content.').optional(), + user: z.string().describe('User identifier.'), +}).describe('Requires `user`. Provide either `message_id` or `text`.') + +export type TextToAudioFormRequestZodType = z.infer + +export const zAppInfoResponse = z.object({ + name: z.string().optional(), + description: z.string().optional(), + tags: z.array(z.string()).optional(), +}) + +export type AppInfoResponseZodType = z.infer + +export const zTextInputControl = z.object({ + label: z.string(), + variable: z.string(), + required: z.boolean(), + default: z.string().optional(), +}) + +export type TextInputControlZodType = z.infer + +export const zTextInputControlWrapper = z.object({ + 'text-input': zTextInputControl, +}) + +export type TextInputControlWrapperZodType = z.infer + +export const zParagraphControl = z.object({ + label: z.string(), + variable: z.string(), + required: z.boolean(), + default: z.string().optional(), +}) + +export type ParagraphControlZodType = z.infer + +export const zParagraphControlWrapper = z.object({ + paragraph: zParagraphControl, +}) + +export type ParagraphControlWrapperZodType = z.infer + +export const zSelectControl = z.object({ + label: z.string(), + variable: z.string(), + required: z.boolean(), + default: z.string().optional(), + options: z.array(z.string()), +}) + +export type SelectControlZodType = z.infer + +export const zSelectControlWrapper = z.object({ + select: zSelectControl, +}) + +export type SelectControlWrapperZodType = z.infer + +export const zUserInputFormItem = z.union([ + zTextInputControlWrapper, + zParagraphControlWrapper, + zSelectControlWrapper, +]) + +export type UserInputFormItemZodType = z.infer + +export const zChatAppParametersResponse = z.object({ + opening_statement: z.string().optional(), + suggested_questions: z.array(z.string()).optional(), + suggested_questions_after_answer: z.object({ + enabled: z.boolean().optional(), + }).optional(), + speech_to_text: z.object({ + enabled: z.boolean().optional(), + }).optional(), + text_to_speech: z.object({ + enabled: z.boolean().optional(), + voice: z.string().optional(), + language: z.string().optional(), + autoPlay: z.enum(['enabled', 'disabled']).optional(), + }).optional(), + retriever_resource: z.object({ + enabled: z.boolean().optional(), + }).optional(), + annotation_reply: z.object({ + enabled: z.boolean().optional(), + }).optional(), + user_input_form: z.array(zUserInputFormItem).optional(), + file_upload: z.object({ + image: z.object({ + enabled: z.boolean().optional(), + number_limits: z.number().int().optional(), + detail: z.string().optional(), + transfer_methods: z.array(z.enum(['remote_url', 'local_file'])).optional(), + }).optional(), + }).optional(), + system_parameters: z.object({ + file_size_limit: z.number().int().optional(), + image_file_size_limit: z.number().int().optional(), + audio_file_size_limit: z.number().int().optional(), + video_file_size_limit: z.number().int().optional(), + }).optional(), +}) + +export type ChatAppParametersResponseZodType = z.infer + +export const zToolIconDetail = z.object({ + background: z.string().describe('Background color in hex format.').optional(), + content: z.string().describe('Emoji content.').optional(), +}) + +export type ToolIconDetailZodType = z.infer + +export const zAppMetaResponse = z.object({ + tool_icons: z.record(z.union([ + z.string().describe('URL of the icon.'), + zToolIconDetail, + ])).describe('Tool icons. Keys are tool names.').optional(), +}) + +export type AppMetaResponseZodType = z.infer + +export const zWebAppSettingsResponse = z.object({ + title: z.string().optional(), + chat_color_theme: z.string().optional(), + chat_color_theme_inverted: z.boolean().optional(), + icon_type: z.enum(['emoji', 'image']).optional(), + icon: z.string().optional(), + icon_background: z.string().optional(), + icon_url: z.union([ + z.string(), + z.null(), + ]).optional(), + description: z.string().optional(), + copyright: z.string().optional(), + privacy_policy: z.string().optional(), + custom_disclaimer: z.string().optional(), + default_language: z.string().optional(), + show_workflow_steps: z.boolean().optional(), + use_icon_as_answer_icon: z.boolean().optional(), +}) + +export type WebAppSettingsResponseZodType = z.infer + +export const zAnnotationItem = z.object({ + id: z.string().uuid().optional(), + question: z.string().optional(), + answer: z.string().optional(), + hit_count: z.number().int().optional(), + created_at: z.coerce.bigint().min(BigInt('-9223372036854775808'), { message: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { message: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).optional(), +}) + +export type AnnotationItemZodType = z.infer + +export const zAnnotationListResponse = z.object({ + data: z.array(zAnnotationItem).optional(), + has_more: z.boolean().optional(), + limit: z.number().int().optional(), + total: z.number().int().optional(), + page: z.number().int().optional(), +}) + +export type AnnotationListResponseZodType = z.infer + +export const zCreateAnnotationRequest = z.object({ + question: z.string(), + answer: z.string(), +}) + +export type CreateAnnotationRequestZodType = z.infer + +export const zUpdateAnnotationRequest = z.object({ + question: z.string(), + answer: z.string(), +}) + +export type UpdateAnnotationRequestZodType = z.infer + +export const zInitialAnnotationReplySettingsRequest = z.object({ + embedding_provider_name: z.string().describe('Specified embedding model provider name (Optional).').optional(), + embedding_model_name: z.string().describe('Specified embedding model name (Optional).').optional(), + score_threshold: z.number().describe('Similarity threshold for matching annotated replies.'), +}) + +export type InitialAnnotationReplySettingsRequestZodType = z.infer + +export const zInitialAnnotationReplySettingsResponse = z.object({ + job_id: z.string().uuid().optional(), + job_status: z.string().optional(), +}) + +export type InitialAnnotationReplySettingsResponseZodType = z.infer + +export const zInitialAnnotationReplySettingsStatusResponse = z.object({ + job_id: z.string().uuid().optional(), + job_status: z.string().optional(), + error_msg: z.union([ + z.string(), + z.null(), ]).optional(), }) -export type ConversationListQueryZodType = z.infer +export type InitialAnnotationReplySettingsStatusResponseZodType = z.infer -/** - * ConversationRenamePayload - */ -export const zConversationRenamePayload = z.object({ - name: z.record(z.unknown()).optional(), - auto_generate: z.boolean().optional().default(false), +export const zErrorResponse = z.object({ + status: z.number().int().optional(), + code: z.string().optional(), + message: z.string().optional(), }) -export type ConversationRenamePayloadZodType = z.infer +export type ErrorResponseZodType = z.infer -/** - * MessageListQuery - */ -export const zMessageListQuery = z.object({ - conversation_id: z.string().describe('Conversation UUID'), - first_id: z.record(z.unknown()).describe('First message ID for pagination').optional(), - limit: z.number().int().gte(1).lte(100).describe('Number of messages to return (1-100)').optional(), -}) - -export type MessageListQueryZodType = z.infer - -/** - * MessageFeedbackPayload - */ -export const zMessageFeedbackPayload = z.object({ - rating: z.record(z.unknown()).describe('Feedback rating').optional(), - content: z.record(z.unknown()).describe('Feedback content').optional(), -}) - -export type MessageFeedbackPayloadZodType = z.infer - -/** - * RemoteFileUploadPayload - */ -export const zRemoteFileUploadPayload = z.object({ - url: z.string().url().min(1).max(2083).describe('Remote file URL'), -}) - -export type RemoteFileUploadPayloadZodType = z.infer - -/** - * SavedMessageListQuery - */ -export const zSavedMessageListQuery = z.object({ - last_id: z.record(z.unknown()).optional(), - limit: z.number().int().gte(1).lte(100).optional(), -}) - -export type SavedMessageListQueryZodType = z.infer - -/** - * SavedMessageCreatePayload - */ -export const zSavedMessageCreatePayload = z.object({ - message_id: z.string(), -}) - -export type SavedMessageCreatePayloadZodType = z.infer - -export const zAudioToTextData = z.object({ - body: z.never().optional(), +export const zSendChatMessageData = z.object({ + body: zChatRequest, path: z.never().optional(), query: z.never().optional(), }) -export type AudioToTextDataZodType = z.infer +export type SendChatMessageDataZodType = z.infer -export const zCreateChatMessageData = z.object({ - body: zChatMessagePayload, +/** + * Successful response. The content type and structure depend on the `response_mode` parameter in the request. + * - If `response_mode` is `blocking`, returns `application/json` with a `ChatCompletionResponse` object. + * - If `response_mode` is `streaming`, returns `text/event-stream` with a stream of `ChunkChatEvent` objects. + */ +export const zSendChatMessageResponse = zChatCompletionResponse + +export type SendChatMessageResponseZodType = z.infer + +export const zUploadChatFileData = z.object({ + body: z.object({ + file: z.string().describe('The file to be uploaded. Supported image types: png, jpg, jpeg, webp, gif.'), + user: z.string().describe('User identifier, defined by the developer\'s rules, must be unique within the application. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.'), + }).describe('File upload request. Requires multipart/form-data.'), path: z.never().optional(), query: z.never().optional(), }) -export type CreateChatMessageDataZodType = z.infer +export type UploadChatFileDataZodType = z.infer -export const zStopChatMessageData = z.object({ +/** + * File uploaded successfully. + */ +export const zUploadChatFileResponse = zFileUploadResponse + +export type UploadChatFileResponseZodType = z.infer + +export const zPreviewChatFileData = z.object({ body: z.never().optional(), path: z.object({ - task_id: z.string().describe('Task ID to stop'), + file_id: z.string().uuid().describe('The unique identifier of the file to preview, obtained from the File Upload API response.'), + }), + query: z.object({ + as_attachment: z.boolean().describe('Whether to force download the file as an attachment. Default is `false` (preview in browser).').optional().default(false), + }).optional(), +}) + +export type PreviewChatFileDataZodType = z.infer + +/** + * File content returned successfully. Headers set based on file type and request parameters. + */ +export const zPreviewChatFileResponse = z.string().describe('File content returned successfully. Headers set based on file type and request parameters.') + +export type PreviewChatFileResponseZodType = z.infer + +export const zStopChatMessageGenerationData = z.object({ + body: z.object({ + user: z.string().describe('User identifier, must be consistent with the user passed in the send message interface. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.'), + }), + path: z.object({ + task_id: z.string().describe('Task ID, can be obtained from the streaming chunk return of a `/chat-messages` request.'), }), query: z.never().optional(), }) -export type StopChatMessageDataZodType = z.infer +export type StopChatMessageGenerationDataZodType = z.infer -export const zCreateCompletionMessageData = z.object({ - body: zCompletionMessagePayload, - path: z.never().optional(), - query: z.never().optional(), -}) +/** + * Operation successful. + */ +export const zStopChatMessageGenerationResponse = z.object({ + result: z.string().optional(), +}).describe('Operation successful.') -export type CreateCompletionMessageDataZodType = z.infer +export type StopChatMessageGenerationResponseZodType = z.infer -export const zStopCompletionMessageData = z.object({ - body: z.never().optional(), +export const zPostChatMessageFeedbackData = z.object({ + body: zMessageFeedbackRequest, path: z.object({ - task_id: z.string().describe('Task ID to stop'), + message_id: z.string().describe('Message ID for which feedback is being provided.'), }), query: z.never().optional(), }) -export type StopCompletionMessageDataZodType = z.infer +export type PostChatMessageFeedbackDataZodType = z.infer -export const zGetConversationListData = z.object({ +/** + * Operation successful. + */ +export const zPostChatMessageFeedbackResponse = z.object({ + result: z.string().optional(), +}).describe('Operation successful.') + +export type PostChatMessageFeedbackResponseZodType = z.infer + +export const zGetChatAppFeedbacksData = z.object({ body: z.never().optional(), path: z.never().optional(), query: z.object({ - last_id: z.string().describe('Last conversation ID for pagination').optional(), - limit: z.number().int().describe('Number of conversations to return (1-100)').optional().default(20), - pinned: z.enum(['true', 'false']).describe('Filter by pinned status').optional(), + page: z.number().int().describe('(optional) Pagination page number. Default: 1').optional().default(1), + limit: z.number().int().describe('(optional) Records per page. Default: 20').optional().default(20), + }).optional(), +}) + +export type GetChatAppFeedbacksDataZodType = z.infer + +/** + * A list of application feedbacks. + */ +export const zGetChatAppFeedbacksResponse = zAppFeedbacksResponse + +export type GetChatAppFeedbacksResponseZodType = z.infer + +export const zGetSuggestedQuestionsData = z.object({ + body: z.never().optional(), + path: z.object({ + message_id: z.string().describe('Message ID.'), + }), + query: z.object({ + user: z.string().describe('User identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.'), + }), +}) + +export type GetSuggestedQuestionsDataZodType = z.infer + +/** + * Successfully retrieved suggested questions. + */ +export const zGetSuggestedQuestionsResponse = zSuggestedQuestionsResponse + +export type GetSuggestedQuestionsResponseZodType = z.infer + +export const zGetConversationHistoryData = z.object({ + body: z.never().optional(), + path: z.never().optional(), + query: z.object({ + conversation_id: z.string().describe('Conversation ID.'), + user: z.string().describe('User identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.'), + first_id: z.string().describe('The ID of the first chat record on the current page, default is null (for fetching the latest). For subsequent pages, use the ID of the first message from the current list to get older messages.').optional(), + limit: z.number().int().describe('How many chat history messages to return in one request, default is 20.').optional().default(20), + }), +}) + +export type GetConversationHistoryDataZodType = z.infer + +/** + * Successfully retrieved conversation history. + */ +export const zGetConversationHistoryResponse = zConversationHistoryResponse + +export type GetConversationHistoryResponseZodType = z.infer + +export const zGetConversationsListData = z.object({ + body: z.never().optional(), + path: z.never().optional(), + query: z.object({ + user: z.string().describe('User identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.'), + last_id: z.string().describe('(Optional) The ID of the last record on the current page (for pagination).').optional(), + limit: z.number().int().gte(1).lte(100).describe('(Optional) How many records to return. Default 20, Min 1, Max 100.').optional().default(20), sort_by: z.enum([ 'created_at', '-created_at', 'updated_at', '-updated_at', - ]).describe('Sort order').optional(), - }).optional(), + ]).describe('Sorting Field. Default: -updated_at. \'-\' prefix for descending.').optional(), + }), }) -export type GetConversationListDataZodType = z.infer +export type GetConversationsListDataZodType = z.infer + +/** + * Successfully retrieved conversations list. + */ +export const zGetConversationsListResponse = zConversationsListResponse + +export type GetConversationsListResponseZodType = z.infer export const zDeleteConversationData = z.object({ - body: z.never().optional(), + body: z.object({ + user: z.string().describe('The user identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.'), + }), path: z.object({ - c_id: z.string().describe('Conversation UUID'), + conversation_id: z.string().describe('Conversation ID.'), }), query: z.never().optional(), }) @@ -331,322 +777,241 @@ export const zDeleteConversationData = z.object({ export type DeleteConversationDataZodType = z.infer /** - * Conversation deleted successfully + * Conversation deleted successfully. No Content. */ -export const zDeleteConversationResponse = z.void().describe('Conversation deleted successfully') +export const zDeleteConversationResponse = z.void().describe('Conversation deleted successfully. No Content.') export type DeleteConversationResponseZodType = z.infer export const zRenameConversationData = z.object({ - body: z.never().optional(), + body: zConversationRenameRequest, path: z.object({ - c_id: z.string().describe('Conversation UUID'), + conversation_id: z.string().describe('Conversation ID.'), }), - query: z.object({ - name: z.string().describe('New conversation name').optional(), - auto_generate: z.boolean().describe('Auto-generate conversation name').optional().default(false), - }).optional(), + query: z.never().optional(), }) export type RenameConversationDataZodType = z.infer -export const zPinConversationData = z.object({ +/** + * Conversation renamed successfully. + */ +export const zRenameConversationResponse = zConversationListItem + +export type RenameConversationResponseZodType = z.infer + +export const zGetConversationVariablesData = z.object({ body: z.never().optional(), path: z.object({ - c_id: z.string().describe('Conversation UUID'), + conversation_id: z.string().describe('The ID of the conversation to retrieve variables from.'), }), - query: z.never().optional(), -}) - -export type PinConversationDataZodType = z.infer - -export const zUnpinConversationData = z.object({ - body: z.never().optional(), - path: z.object({ - c_id: z.string().describe('Conversation UUID'), + query: z.object({ + user: z.string().describe('The user identifier.'), + last_id: z.string().describe('(Optional) The ID of the last record on the current page (for pagination).').optional(), + limit: z.number().int().gte(1).lte(100).describe('(Optional) How many records to return. Default 20, Min 1, Max 100.').optional().default(20), + variable_name: z.string().describe('(Optional) Filter variables by a specific name.').optional(), }), - query: z.never().optional(), }) -export type UnpinConversationDataZodType = z.infer - -export const zSendEmailCodeLoginData = z.object({ - body: zEmailCodeLoginSendPayload, - path: z.never().optional(), - query: z.never().optional(), -}) - -export type SendEmailCodeLoginDataZodType = z.infer - -export const zVerifyEmailCodeLoginData = z.object({ - body: zEmailCodeLoginVerifyPayload, - path: z.never().optional(), - query: z.never().optional(), -}) - -export type VerifyEmailCodeLoginDataZodType = z.infer - -export const zUploadFileData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.never().optional(), -}) - -export type UploadFileDataZodType = z.infer +export type GetConversationVariablesDataZodType = z.infer /** - * File uploaded successfully + * Successfully retrieved conversation variables. */ -export const zUploadFileResponse = zFileResponse +export const zGetConversationVariablesResponse = zConversationVariablesResponse -export type UploadFileResponseZodType = z.infer +export type GetConversationVariablesResponseZodType = z.infer -export const zSendForgotPasswordEmailData = z.object({ - body: zForgotPasswordSendPayload, +export const zAudioToTextData = z.object({ + body: zAudioToTextRequest, path: z.never().optional(), query: z.never().optional(), }) -export type SendForgotPasswordEmailDataZodType = z.infer +export type AudioToTextDataZodType = z.infer -export const zResetPasswordData = z.object({ - body: zForgotPasswordResetPayload, +/** + * Successfully converted audio to text. + */ +export const zAudioToTextResponse2 = zAudioToTextResponse + +export type AudioToTextResponseZodType2 = z.infer + +export const zTextToAudioChatData = z.object({ + body: zTextToAudioFormRequest, path: z.never().optional(), query: z.never().optional(), }) -export type ResetPasswordDataZodType = z.infer +export type TextToAudioChatDataZodType = z.infer -export const zCheckForgotPasswordTokenData = z.object({ - body: zForgotPasswordCheckPayload, - path: z.never().optional(), - query: z.never().optional(), -}) +/** + * The generated audio file. + */ +export const zTextToAudioChatResponse = z.string().describe('The generated audio file.') -export type CheckForgotPasswordTokenDataZodType = z.infer +export type TextToAudioChatResponseZodType = z.infer -export const zWebAppLoginData = z.object({ - body: zLoginPayload, - path: z.never().optional(), - query: z.never().optional(), -}) - -export type WebAppLoginDataZodType = z.infer - -export const zWebAppLoginStatusData = z.object({ +export const zGetChatAppInfoData = z.object({ body: z.never().optional(), path: z.never().optional(), query: z.never().optional(), }) -export type WebAppLoginStatusDataZodType = z.infer +export type GetChatAppInfoDataZodType = z.infer -export const zWebAppLogoutData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.never().optional(), -}) +/** + * Basic information of the application. + */ +export const zGetChatAppInfoResponse = zAppInfoResponse -export type WebAppLogoutDataZodType = z.infer +export type GetChatAppInfoResponseZodType = z.infer -export const zGetMessageListData = z.object({ +export const zGetChatAppParametersData = z.object({ body: z.never().optional(), path: z.never().optional(), query: z.object({ - conversation_id: z.string().describe('Conversation UUID'), - first_id: z.string().describe('First message ID for pagination').optional(), - limit: z.number().int().describe('Number of messages to return (1-100)').optional().default(20), + user: z.string().describe('User identifier, defined by the developer\'s rules, must be unique within the application.'), }), }) -export type GetMessageListDataZodType = z.infer +export type GetChatAppParametersDataZodType = z.infer -export const zCreateMessageFeedbackData = z.object({ +/** + * Application parameters information. + */ +export const zGetChatAppParametersResponse = zChatAppParametersResponse + +export type GetChatAppParametersResponseZodType = z.infer + +export const zGetChatAppMetaData = z.object({ body: z.never().optional(), - path: z.object({ - message_id: z.string().describe('Message UUID'), - }), + path: z.never().optional(), + query: z.never().optional(), +}) + +export type GetChatAppMetaDataZodType = z.infer + +/** + * Successfully retrieved application meta information. + */ +export const zGetChatAppMetaResponse = zAppMetaResponse + +export type GetChatAppMetaResponseZodType = z.infer + +export const zGetChatWebAppSettingsData = z.object({ + body: z.never().optional(), + path: z.never().optional(), + query: z.never().optional(), +}) + +export type GetChatWebAppSettingsDataZodType = z.infer + +/** + * WebApp settings of the application. + */ +export const zGetChatWebAppSettingsResponse = zWebAppSettingsResponse + +export type GetChatWebAppSettingsResponseZodType = z.infer + +export const zGetAnnotationListData = z.object({ + body: z.never().optional(), + path: z.never().optional(), query: z.object({ - rating: z.enum(['like', 'dislike']).describe('Feedback rating').optional(), - content: z.string().describe('Feedback content').optional(), + page: z.number().int().describe('Page number.').optional().default(1), + limit: z.number().int().gte(1).lte(100).describe('Number of items returned, default 20, range 1-100.').optional().default(20), }).optional(), }) -export type CreateMessageFeedbackDataZodType = z.infer - -export const zGenerateMoreLikeThisData = z.object({ - body: zMessageMoreLikeThisQuery, - path: z.object({ - message_id: z.string(), - }), - query: z.never().optional(), -}) - -export type GenerateMoreLikeThisDataZodType = z.infer - -export const zGetSuggestedQuestionsData = z.object({ - body: z.never().optional(), - path: z.object({ - message_id: z.string().describe('Message UUID'), - }), - query: z.never().optional(), -}) - -export type GetSuggestedQuestionsDataZodType = z.infer - -export const zGetAppMetaData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.never().optional(), -}) - -export type GetAppMetaDataZodType = z.infer - -export const zGetAppParametersData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.never().optional(), -}) - -export type GetAppParametersDataZodType = z.infer - -export const zGetPassportData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.never().optional(), -}) - -export type GetPassportDataZodType = z.infer - -export const zUploadRemoteFileData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.never().optional(), -}) - -export type UploadRemoteFileDataZodType = z.infer +export type GetAnnotationListDataZodType = z.infer /** - * Remote file uploaded successfully + * Successfully retrieved annotation list. */ -export const zUploadRemoteFileResponse = zFileWithSignedUrl +export const zGetAnnotationListResponse = zAnnotationListResponse -export type UploadRemoteFileResponseZodType = z.infer +export type GetAnnotationListResponseZodType = z.infer -export const zGetRemoteFileInfoData = z.object({ - body: z.never().optional(), - path: z.object({ - url: z.string(), - }), +export const zCreateAnnotationData = z.object({ + body: zCreateAnnotationRequest, + path: z.never().optional(), query: z.never().optional(), }) -export type GetRemoteFileInfoDataZodType = z.infer +export type CreateAnnotationDataZodType = z.infer /** - * Remote file information retrieved successfully + * Annotation created successfully. */ -export const zGetRemoteFileInfoResponse = zRemoteFileInfo +export const zCreateAnnotationResponse = zAnnotationItem -export type GetRemoteFileInfoResponseZodType = z.infer +export type CreateAnnotationResponseZodType = z.infer -export const zGetSavedMessagesData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.object({ - last_id: z.string().describe('Last message ID for pagination').optional(), - limit: z.number().int().describe('Number of messages to return (1-100)').optional().default(20), - }).optional(), -}) - -export type GetSavedMessagesDataZodType = z.infer - -export const zSaveMessageData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.object({ - message_id: z.string().describe('Message UUID to save'), - }), -}) - -export type SaveMessageDataZodType = z.infer - -export const zDeleteSavedMessageData = z.object({ +export const zDeleteAnnotationData = z.object({ body: z.never().optional(), path: z.object({ - message_id: z.string().describe('Message UUID to delete'), + annotation_id: z.string().describe('Annotation ID.'), }), query: z.never().optional(), }) -export type DeleteSavedMessageDataZodType = z.infer +export type DeleteAnnotationDataZodType = z.infer /** - * Message removed successfully + * Annotation deleted successfully. No Content. */ -export const zDeleteSavedMessageResponse = z.void().describe('Message removed successfully') +export const zDeleteAnnotationResponse = z.void().describe('Annotation deleted successfully. No Content.') -export type DeleteSavedMessageResponseZodType = z.infer +export type DeleteAnnotationResponseZodType = z.infer -export const zGetAppSiteInfoData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.never().optional(), -}) - -export type GetAppSiteInfoDataZodType = z.infer - -export const zGetSystemFeaturesData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.never().optional(), -}) - -export type GetSystemFeaturesDataZodType = z.infer - -export const zTextToAudioData = z.object({ - body: zTextToAudioPayload, - path: z.never().optional(), - query: z.never().optional(), -}) - -export type TextToAudioDataZodType = z.infer - -export const zGetAppAccessModeData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.object({ - appId: z.string().describe('Application ID').optional(), - appCode: z.string().describe('Application code').optional(), - }).optional(), -}) - -export type GetAppAccessModeDataZodType = z.infer - -export const zCheckAppPermissionData = z.object({ - body: z.never().optional(), - path: z.never().optional(), - query: z.object({ - appId: z.string().describe('Application ID'), +export const zUpdateAnnotationData = z.object({ + body: zUpdateAnnotationRequest, + path: z.object({ + annotation_id: z.string().describe('Annotation ID.'), }), -}) - -export type CheckAppPermissionDataZodType = z.infer - -export const zRunWorkflowData = z.object({ - body: zWorkflowRunPayload, - path: z.never().optional(), query: z.never().optional(), }) -export type RunWorkflowDataZodType = z.infer +export type UpdateAnnotationDataZodType = z.infer -export const zStopWorkflowTaskData = z.object({ +/** + * Annotation updated successfully. + */ +export const zUpdateAnnotationResponse = zAnnotationItem + +export type UpdateAnnotationResponseZodType = z.infer + +export const zInitialAnnotationReplySettingsData = z.object({ + body: zInitialAnnotationReplySettingsRequest, + path: z.object({ + action: z.enum(['enable', 'disable']).describe('Action, can only be \'enable\' or \'disable\'.'), + }), + query: z.never().optional(), +}) + +export type InitialAnnotationReplySettingsDataZodType = z.infer + +/** + * Annotation reply settings task initiated. + */ +export const zInitialAnnotationReplySettingsResponse2 = zInitialAnnotationReplySettingsResponse + +export type InitialAnnotationReplySettingsResponseZodType2 = z.infer + +export const zGetInitialAnnotationReplySettingsStatusData = z.object({ body: z.never().optional(), path: z.object({ - task_id: z.string().describe('Task ID to stop'), + action: z.enum(['enable', 'disable']).describe('Action, must be the same as in the initial settings call (\'enable\' or \'disable\').'), + job_id: z.string().describe('Job ID obtained from the initial settings call.'), }), query: z.never().optional(), }) -export type StopWorkflowTaskDataZodType = z.infer +export type GetInitialAnnotationReplySettingsStatusDataZodType = z.infer + +/** + * Successfully retrieved task status. + */ +export const zGetInitialAnnotationReplySettingsStatusResponse = zInitialAnnotationReplySettingsStatusResponse + +export type GetInitialAnnotationReplySettingsStatusResponseZodType = z.infer diff --git a/web/openapi-ts.config.ts b/web/openapi-ts.config.ts index 6f2177c249..4f3a977b73 100644 --- a/web/openapi-ts.config.ts +++ b/web/openapi-ts.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from '@hey-api/openapi-ts' import { defineConfig as defineOrpcConfig } from './plugins/hey-api-orpc/config' export default defineConfig({ - input: '../open-api/web-api.json', + input: './openapi_chat.json', output: { indexFile: false, path: './gen', diff --git a/web/openapi_chat.json b/web/openapi_chat.json new file mode 100644 index 0000000000..c4f0fe0b5a --- /dev/null +++ b/web/openapi_chat.json @@ -0,0 +1,1935 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Chat App API", + "description": "Chat applications support session persistence, allowing previous chat history to be used as context for responses. This can be applicable for chatbot, customer service AI, etc.", + "version": "1.0.0" + }, + "servers": [ + { + "url": "{api_base_url}", + "description": "The base URL for the Chat App API. Replace {api_base_url} with the actual API base URL provided for your application (e.g., from props.appDetail.api_base_url).", + "variables": { + "api_base_url": { + "default": "https://api.dify.ai/v1", + "description": "Actual base URL of the API" + } + } + } + ], + "security": [ + { + "ApiKeyAuth": [] + } + ], + "paths": { + "/chat-messages": { + "post": { + "summary": "Send Chat Message", + "description": "Send a request to the chat application.", + "operationId": "sendChatMessage", + "tags": ["Chat"], + "requestBody": { + "description": "Request body to send a chat message.", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChatRequest" + }, + "examples": { + "streaming_example": { + "summary": "Streaming mode example with file", + "value": { + "inputs": {}, + "query": "What are the specs of the iPhone 13 Pro Max?", + "response_mode": "streaming", + "conversation_id": "", + "user": "abc-123", + "files": [ + { + "type": "image", + "transfer_method": "remote_url", + "url": "https://cloud.dify.ai/logo/logo-site.png" + } + ] + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Successful response. The content type and structure depend on the `response_mode` parameter in the request.\n- If `response_mode` is `blocking`, returns `application/json` with a `ChatCompletionResponse` object.\n- If `response_mode` is `streaming`, returns `text/event-stream` with a stream of `ChunkChatEvent` objects.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChatCompletionResponse" + }, + "examples": { + "blockingResponse": { + "summary": "Example of a blocking mode response", + "value": { + "event": "message", + "task_id": "c3800678-a077-43df-a102-53f23ed20b88", + "id": "9da23599-e713-473b-982c-4328d4f5c78a", + "message_id": "9da23599-e713-473b-982c-4328d4f5c78a", + "conversation_id": "45701982-8118-4bc5-8e9b-64562b4555f2", + "mode": "chat", + "answer": "iPhone 13 Pro Max specs are listed here:...", + "metadata": { + "usage": { + "prompt_tokens": 1033, + "prompt_unit_price": "0.001", + "prompt_price_unit": "0.001", + "prompt_price": "0.0010330", + "completion_tokens": 128, + "completion_unit_price": "0.002", + "completion_price_unit": "0.001", + "completion_price": "0.0002560", + "total_tokens": 1161, + "total_price": "0.0012890", + "currency": "USD", + "latency": 0.7682376249867957 + }, + "retriever_resources": [ + { + "position": 1, + "dataset_id": "101b4c97-fc2e-463c-90b1-5261a4cdcafb", + "dataset_name": "iPhone", + "document_id": "8dd1ad74-0b5f-4175-b735-7d98bbbb4e00", + "document_name": "iPhone List", + "segment_id": "ed599c7f-2766-4294-9d1d-e5235a61270a", + "score": 0.98457545, + "content": "\"Model\",\"Release Date\",\"Display Size\",\"Resolution\",\"Processor\",\"RAM\",\"Storage\",\"Camera\",\"Battery\",\"Operating System\"\n\"iPhone 13 Pro Max\",\"September 24, 2021\",\"6.7 inch\",\"1284 x 2778\",\"Hexa-core (2x3.23 GHz Avalanche + 4x1.82 GHz Blizzard)\",\"6 GB\",\"128, 256, 512 GB, 1TB\",\"12 MP\",\"4352 mAh\",\"iOS 15\"" + } + ] + }, + "created_at": 1705407629 + } + } + } + }, + "text/event-stream": { + "schema": { + "type": "string", + "description": "A stream of Server-Sent Events. Each event is a JSON object prefixed with 'data: ' and suffixed with '\\n\\n'. See `ChunkChatEvent` for possible event structures." + }, + "examples": { + "streamingResponseBasic": { + "summary": "Example of a streaming mode response (Basic Assistant)", + "value": "data: {\"event\": \"message\", \"task_id\":\"mock_task_id\", \"message_id\": \"5ad4cb98-f0c7-4085-b384-88c403be6290\", \"conversation_id\": \"45701982-8118-4bc5-8e9b-64562b4555f2\", \"answer\": \" I\", \"created_at\": 1679586595}\n\ndata: {\"event\": \"message_end\", \"task_id\":\"mock_task_id\", \"message_id\": \"5ad4cb98-f0c7-4085-b384-88c403be6290\", \"conversation_id\": \"45701982-8118-4bc5-8e9b-64562b4555f2\", \"metadata\": {\"usage\": {\"total_tokens\": 10, \"latency\": 1.0}}}\n\n" + }, + "streamingResponseAgent": { + "summary": "Example of a streaming mode response (Agent Assistant with agent_thought and message_file)", + "value": "data: {\"event\": \"agent_thought\", \"id\": \"agent_thought_id_1\", \"task_id\": \"task123\", \"message_id\": \"msg123\", \"conversation_id\": \"conv123\", \"position\": 1, \"thought\": \"Thinking about calling a tool...\", \"tool\": \"dalle3\", \"tool_input\": \"{\\\"dalle3\\\": {\\\"prompt\\\": \\\"a cute cat\\\"}}\", \"created_at\": 1705395332}\n\ndata: {\"event\": \"message_file\", \"id\": \"file_id_1\", \"type\": \"image\", \"belongs_to\": \"assistant\", \"url\": \"https://example.com/cat.png\", \"conversation_id\": \"conv123\"}\n\ndata: {\"event\": \"agent_message\", \"task_id\": \"task123\", \"message_id\": \"msg123\", \"conversation_id\": \"conv123\", \"answer\": \"Here is the image: \", \"created_at\": 1705395333}\n\ndata: {\"event\": \"message_end\", \"task_id\":\"task123\", \"message_id\": \"msg123\", \"conversation_id\": \"conv123\", \"metadata\": {\"usage\": {\"total_tokens\": 50, \"latency\": 2.5}}}\n\n" + } + } + } + } + }, + "400": { + "description": "Bad Request. Possible error codes:\n- `invalid_param`: Abnormal parameter input.\n- `app_unavailable`: App configuration unavailable.\n- `provider_not_initialize`: No available model credential configuration.\n- `provider_quota_exceeded`: Model invocation quota insufficient.\n- `model_currently_not_support`: Current model unavailable.\n- `completion_request_error`: Text generation failed.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + }, + "404": { + "description": "Conversation does not exist.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + }, + "500": { + "description": "Internal server error.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + } + } + } + }, + "/files/upload": { + "post": { + "summary": "File Upload", + "description": "Upload a file (currently only images are supported) for use when sending messages, enabling multimodal understanding of images and text. Supports png, jpg, jpeg, webp, gif formats. Uploaded files are for use by the current end-user only.", + "operationId": "uploadChatFile", + "tags": ["Files"], + "requestBody": { + "description": "File upload request. Requires multipart/form-data.", + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "required": ["file", "user"], + "properties": { + "file": { + "type": "string", + "format": "binary", + "description": "The file to be uploaded. Supported image types: png, jpg, jpeg, webp, gif." + }, + "user": { + "type": "string", + "description": "User identifier, defined by the developer's rules, must be unique within the application. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface." + } + } + } + } + } + }, + "responses": { + "200": { + "description": "File uploaded successfully.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FileUploadResponse" + } + } + } + }, + "400": { "$ref": "#/components/responses/BadRequestFile" }, + "413": { "$ref": "#/components/responses/FileTooLarge" }, + "415": { "$ref": "#/components/responses/UnsupportedFileTypeFile" }, + "503": { "$ref": "#/components/responses/S3ErrorFile" }, + "500": { "$ref": "#/components/responses/InternalServerError" } + } + } + }, + "/files/{file_id}/preview": { + "get": { + "summary": "File Preview", + "description": "Preview or download uploaded files. This endpoint allows you to access files that have been previously uploaded via the File Upload API. Files can only be accessed if they belong to messages within the requesting application.", + "operationId": "previewChatFile", + "tags": ["Files"], + "parameters": [ + { + "name": "file_id", + "in": "path", + "required": true, + "description": "The unique identifier of the file to preview, obtained from the File Upload API response.", + "schema": { + "type": "string", + "format": "uuid" + } + }, + { + "name": "as_attachment", + "in": "query", + "required": false, + "description": "Whether to force download the file as an attachment. Default is `false` (preview in browser).", + "schema": { + "type": "boolean", + "default": false + } + } + ], + "responses": { + "200": { + "description": "File content returned successfully. Headers set based on file type and request parameters.", + "content": { + "image/png": { + "schema": { + "type": "string", + "format": "binary" + } + }, + "image/jpeg": { + "schema": { + "type": "string", + "format": "binary" + } + }, + "image/webp": { + "schema": { + "type": "string", + "format": "binary" + } + }, + "image/gif": { + "schema": { + "type": "string", + "format": "binary" + } + }, + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + }, + "headers": { + "Content-Type": { + "description": "MIME type of the file", + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "File size in bytes (if available)", + "schema": { + "type": "integer" + } + }, + "Content-Disposition": { + "description": "Set to 'attachment' if as_attachment=true", + "schema": { + "type": "string" + } + }, + "Cache-Control": { + "description": "Caching headers for performance", + "schema": { + "type": "string", + "example": "public, max-age=3600" + } + }, + "Accept-Ranges": { + "description": "Set to 'bytes' for audio/video files", + "schema": { + "type": "string", + "example": "bytes" + } + } + } + }, + "400": { + "description": "Bad Request. Possible error codes:\n- `invalid_param`: Abnormal parameter input.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + }, + "403": { + "description": "Forbidden. Possible error codes:\n- `file_access_denied`: File access denied or file does not belong to current application.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + }, + "404": { + "description": "Not Found. Possible error codes:\n- `file_not_found`: File not found or has been deleted.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + }, + "500": { + "description": "Internal server error.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ErrorResponse" } + } + } + } + } + } + }, + "/chat-messages/{task_id}/stop": { + "post": { + "summary": "Stop Chat Message Generation", + "description": "Stops a chat message generation task. Only supported in streaming mode.", + "operationId": "stopChatMessageGeneration", + "tags": ["Chat"], + "parameters": [ + { + "name": "task_id", + "in": "path", + "required": true, + "description": "Task ID, can be obtained from the streaming chunk return of a `/chat-messages` request.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "string", + "description": "User identifier, must be consistent with the user passed in the send message interface. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface." + } + } + }, + "examples": { + "example": { + "value": { + "user": "abc-123" + } + } + } + } + } + }, + "responses": { + "200": { "$ref": "#/components/responses/SuccessResult" } + } + } + }, + "/messages/{message_id}/feedbacks": { + "post": { + "summary": "Message Feedback", + "description": "End-users can provide feedback messages, facilitating application developers to optimize expected outputs.", + "operationId": "postChatMessageFeedback", + "tags": ["Feedback"], + "parameters": [ + { + "name": "message_id", + "in": "path", + "required": true, + "description": "Message ID for which feedback is being provided.", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MessageFeedbackRequest" + } + } + } + }, + "responses": { + "200": { "$ref": "#/components/responses/SuccessResult" } + } + } + }, + "/app/feedbacks": { + "get": { + "summary": "Get feedbacks of application", + "description": "Get application's feedbacks.", + "operationId": "getChatAppFeedbacks", + "tags": ["Feedback"], + "parameters": [ + { + "name": "page", + "in": "query", + "description": "(optional) Pagination page number. Default: 1", + "required": false, + "schema": { + "type": "integer", + "default": 1 + } + }, + { + "name": "limit", + "in": "query", + "description": "(optional) Records per page. Default: 20", + "required": false, + "schema": { + "type": "integer", + "default": 20 + } + } + ], + "responses": { + "200": { + "description": "A list of application feedbacks.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AppFeedbacksResponse" + } + } + } + } + } + } + }, + "/messages/{message_id}/suggested": { + "get": { + "summary": "Next Suggested Questions", + "description": "Get next questions suggestions for the current message.", + "operationId": "getSuggestedQuestions", + "tags": ["Chat"], + "parameters": [ + { + "name": "message_id", + "in": "path", + "required": true, + "description": "Message ID.", + "schema": { + "type": "string" + } + }, + { + "name": "user", + "in": "query", + "required": true, + "description": "User identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully retrieved suggested questions.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SuggestedQuestionsResponse" + } + } + } + } + } + } + }, + "/messages": { + "get": { + "summary": "Get Conversation History Messages", + "description": "Returns historical chat records in a scrolling load format, with the first page returning the latest `{limit}` messages, i.e., in reverse order.", + "operationId": "getConversationHistory", + "tags": ["Conversations"], + "parameters": [ + { + "name": "conversation_id", + "in": "query", + "required": true, + "description": "Conversation ID.", + "schema": { "type": "string" } + }, + { + "name": "user", + "in": "query", + "required": true, + "description": "User identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.", + "schema": { "type": "string" } + }, + { + "name": "first_id", + "in": "query", + "required": false, + "description": "The ID of the first chat record on the current page, default is null (for fetching the latest). For subsequent pages, use the ID of the first message from the current list to get older messages.", + "schema": { "type": "string" } + }, + { + "name": "limit", + "in": "query", + "required": false, + "description": "How many chat history messages to return in one request, default is 20.", + "schema": { "type": "integer", "default": 20 } + } + ], + "responses": { + "200": { + "description": "Successfully retrieved conversation history.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConversationHistoryResponse" + } + } + } + } + } + } + }, + "/conversations": { + "get": { + "summary": "Get Conversations", + "description": "Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.", + "operationId": "getConversationsList", + "tags": ["Conversations"], + "parameters": [ + { + "name": "user", + "in": "query", + "required": true, + "description": "User identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface.", + "schema": { "type": "string" } + }, + { + "name": "last_id", + "in": "query", + "required": false, + "description": "(Optional) The ID of the last record on the current page (for pagination).", + "schema": { "type": "string" } + }, + { + "name": "limit", + "in": "query", + "required": false, + "description": "(Optional) How many records to return. Default 20, Min 1, Max 100.", + "schema": { "type": "integer", "default": 20, "minimum": 1, "maximum": 100 } + }, + { + "name": "sort_by", + "in": "query", + "required": false, + "description": "Sorting Field. Default: -updated_at. '-' prefix for descending.", + "schema": { + "type": "string", + "enum": ["created_at", "-created_at", "updated_at", "-updated_at"], + "default": "-updated_at" + } + } + ], + "responses": { + "200": { + "description": "Successfully retrieved conversations list.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConversationsListResponse" + } + } + } + } + } + } + }, + "/conversations/{conversation_id}": { + "delete": { + "summary": "Delete Conversation", + "description": "Delete a conversation.", + "operationId": "deleteConversation", + "tags": ["Conversations"], + "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "description": "Conversation ID.", + "schema": { "type": "string" } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": ["user"], + "properties": { + "user": { + "type": "string", + "description": "The user identifier. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface." + } + } + } + } + } + }, + "responses": { + "204": { "description": "Conversation deleted successfully. No Content." } + } + } + }, + "/conversations/{conversation_id}/name": { + "post": { + "summary": "Conversation Rename", + "description": "Rename the session. The session name is used for display on clients that support multiple sessions.", + "operationId": "renameConversation", + "tags": ["Conversations"], + "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "description": "Conversation ID.", + "schema": { "type": "string" } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConversationRenameRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Conversation renamed successfully.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConversationRenameResponse" + } + } + } + } + } + } + }, + "/conversations/{conversation_id}/variables": { + "get": { + "summary": "Get Conversation Variables", + "description": "Retrieve variables from a specific conversation.", + "operationId": "getConversationVariables", + "tags": ["Conversations"], + "parameters": [ + { + "name": "conversation_id", + "in": "path", + "required": true, + "description": "The ID of the conversation to retrieve variables from.", + "schema": { "type": "string" } + }, + { + "name": "user", + "in": "query", + "required": true, + "description": "The user identifier.", + "schema": { "type": "string" } + }, + { + "name": "last_id", + "in": "query", + "required": false, + "description": "(Optional) The ID of the last record on the current page (for pagination).", + "schema": { "type": "string" } + }, + { + "name": "limit", + "in": "query", + "required": false, + "description": "(Optional) How many records to return. Default 20, Min 1, Max 100.", + "schema": { "type": "integer", "default": 20, "minimum": 1, "maximum": 100 } + }, + { + "name": "variable_name", + "in": "query", + "required": false, + "description": "(Optional) Filter variables by a specific name.", + "schema": { "type": "string" } + } + ], + "responses": { + "200": { + "description": "Successfully retrieved conversation variables.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/ConversationVariablesResponse" } + } + } + }, + "404": { "$ref": "#/components/responses/ConversationNotFound" } + } + } + }, + "/audio-to-text": { + "post": { + "summary": "Speech to Text", + "description": "Convert audio file to text. Supported formats: mp3, mp4, mpeg, mpga, m4a, wav, webm. File size limit: 15MB.", + "operationId": "audioToText", + "tags": ["TTS"], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/AudioToTextRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Successfully converted audio to text.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AudioToTextResponse" + } + } + } + } + } + } + }, + "/text-to-audio": { + "post": { + "summary": "Text to Audio", + "description": "Convert text to speech.", + "operationId": "textToAudioChat", + "tags": ["TTS"], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/TextToAudioFormRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Audio file generated successfully.", + "content": { + "audio/wav": { + "schema": { + "type": "string", + "format": "binary", + "description": "The generated audio file." + } + } + }, + "headers": { + "Content-Type": { + "description": "The content type of the response, typically `audio/wav` or `audio/mp3`.", + "schema": { + "type": "string", + "example": "audio/wav" + } + } + } + } + } + } + }, + "/info": { + "get": { + "summary": "Get Application Basic Information", + "description": "Used to get basic information about this application.", + "operationId": "getChatAppInfo", + "tags": ["Application"], + "responses": { + "200": { + "description": "Basic information of the application.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AppInfoResponse" + } + } + } + } + } + } + }, + "/parameters": { + "get": { + "summary": "Get Application Parameters Information", + "description": "Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values.", + "operationId": "getChatAppParameters", + "tags": ["Application"], + "parameters": [ + { + "name": "user", + "in": "query", + "required": true, + "description": "User identifier, defined by the developer's rules, must be unique within the application.", + "schema": { "type": "string" } + } + ], + "responses": { + "200": { + "description": "Application parameters information.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChatAppParametersResponse" + } + } + } + } + } + } + }, + "/meta": { + "get": { + "summary": "Get Application Meta Information", + "description": "Used to get icons of tools in this application.", + "operationId": "getChatAppMeta", + "tags": ["Application"], + "responses": { + "200": { + "description": "Successfully retrieved application meta information.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AppMetaResponse" + } + } + } + } + } + } + }, + "/site": { + "get": { + "summary": "Get Application WebApp Settings", + "description": "Used to get the WebApp settings of the application.", + "operationId": "getChatWebAppSettings", + "tags": ["Application"], + "responses": { + "200": { + "description": "WebApp settings of the application.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WebAppSettingsResponse" + } + } + } + } + } + } + }, + "/apps/annotations": { + "get": { + "summary": "Get Annotation List", + "description": "Retrieves a list of annotations for the application.", + "operationId": "getAnnotationList", + "tags": ["Annotations"], + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Page number.", + "required": false, + "schema": { "type": "integer", "default": 1 } + }, + { + "name": "limit", + "in": "query", + "description": "Number of items returned, default 20, range 1-100.", + "required": false, + "schema": { "type": "integer", "default": 20, "minimum": 1, "maximum": 100 } + } + ], + "responses": { + "200": { + "description": "Successfully retrieved annotation list.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/AnnotationListResponse" } + } + } + } + } + }, + "post": { + "summary": "Create Annotation", + "description": "Creates a new annotation.", + "operationId": "createAnnotation", + "tags": ["Annotations"], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/CreateAnnotationRequest" } + } + } + }, + "responses": { + "200": { + "description": "Annotation created successfully.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/AnnotationItem" } + } + } + } + } + } + }, + "/apps/annotations/{annotation_id}": { + "put": { + "summary": "Update Annotation", + "description": "Updates an existing annotation.", + "operationId": "updateAnnotation", + "tags": ["Annotations"], + "parameters": [ + { + "name": "annotation_id", + "in": "path", + "required": true, + "description": "Annotation ID.", + "schema": { "type": "string" } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UpdateAnnotationRequest" } + } + } + }, + "responses": { + "200": { + "description": "Annotation updated successfully.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/AnnotationItem" } + } + } + } + } + }, + "delete": { + "summary": "Delete Annotation", + "description": "Deletes an annotation.", + "operationId": "deleteAnnotation", + "tags": ["Annotations"], + "parameters": [ + { + "name": "annotation_id", + "in": "path", + "required": true, + "description": "Annotation ID.", + "schema": { "type": "string" } + } + ], + "responses": { + "204": { "description": "Annotation deleted successfully. No Content." } + } + } + }, + "/apps/annotation-reply/{action}": { + "post": { + "summary": "Initial Annotation Reply Settings", + "description": "Enable or disable annotation reply settings and configure embedding models. This interface is executed asynchronously.", + "operationId": "initialAnnotationReplySettings", + "tags": ["Annotations"], + "parameters": [ + { + "name": "action", + "in": "path", + "required": true, + "description": "Action, can only be 'enable' or 'disable'.", + "schema": { "type": "string", "enum": ["enable", "disable"] } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/InitialAnnotationReplySettingsRequest" } + } + } + }, + "responses": { + "200": { + "description": "Annotation reply settings task initiated.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/InitialAnnotationReplySettingsResponse" } + } + } + } + } + } + }, + "/apps/annotation-reply/{action}/status/{job_id}": { + "get": { + "summary": "Query Initial Annotation Reply Settings Task Status", + "description": "Queries the status of an asynchronously executed annotation reply settings task.", + "operationId": "getInitialAnnotationReplySettingsStatus", + "tags": ["Annotations"], + "parameters": [ + { + "name": "action", + "in": "path", + "required": true, + "description": "Action, must be the same as in the initial settings call ('enable' or 'disable').", + "schema": { "type": "string", "enum": ["enable", "disable"] } + }, + { + "name": "job_id", + "in": "path", + "required": true, + "description": "Job ID obtained from the initial settings call.", + "schema": { "type": "string" } + } + ], + "responses": { + "200": { + "description": "Successfully retrieved task status.", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/InitialAnnotationReplySettingsStatusResponse" } + } + } + } + } + } + } + }, + "components": { + "securitySchemes": { + "ApiKeyAuth": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "API_KEY", + "description": "API Key authentication. For all API requests, include your API Key in the `Authorization` HTTP Header, prefixed with 'Bearer '. Example: `Authorization: Bearer {API_KEY}`. **Strongly recommend storing your API Key on the server-side, not shared or stored on the client-side, to avoid possible API-Key leakage that can lead to serious consequences.**" + } + }, + "responses": { + "BadRequestFile": { + "description": "Bad Request for file operations. Possible error codes:\n- `no_file_uploaded`: A file must be provided.\n- `too_many_files`: Currently only one file is accepted.\n- `unsupported_preview`: The file does not support preview.\n- `unsupported_estimate`: The file does not support estimation.", + "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } + }, + "FileTooLarge": { + "description": "`file_too_large`: The file is too large.", + "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } + }, + "UnsupportedFileTypeFile": { + "description": "`unsupported_file_type`: Unsupported extension. (Note: The description for `/files/upload` lists image types, while this generic error mentions document files. This might indicate a context-specific message from the backend).", + "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } + }, + "S3ErrorFile": { + "description": "Service Unavailable for S3 operations. Possible error codes:\n- `s3_connection_failed`: Unable to connect to S3 service.\n- `s3_permission_denied`: No permission to upload files to S3.\n- `s3_file_too_large`: File exceeds S3 size limit.", + "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } + }, + "InternalServerError": { + "description": "Internal server error.", + "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } + }, + "SuccessResult": { + "description": "Operation successful.", + "content": { "application/json": { "schema": { "type": "object", "properties": { "result": { "type": "string", "example": "success" } } } } } + }, + "ConversationNotFound": { + "description": "Conversation not found. Error code: `conversation_not_exists`", + "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } + } + }, + "schemas": { + "ChatRequest": { + "type": "object", + "required": ["query", "user"], + "properties": { + "query": { + "type": "string", + "description": "User Input/Question content." + }, + "inputs": { + "type": "object", + "description": "Allows the entry of various variable values defined by the App. Contains key/value pairs. Default {}.", + "additionalProperties": true, + "default": {} + }, + "response_mode": { + "type": "string", + "enum": ["streaming", "blocking"], + "description": "Mode of response return. `streaming` (recommended) uses SSE. `blocking` returns after completion (may be interrupted for long processes; not supported in Agent Assistant mode). Cloudflare timeout is 100s.", + "default": "streaming" + }, + "user": { + "type": "string", + "description": "User identifier, unique within the application. **Note**: The Service API does not share conversations created by the WebApp. Conversations created through the API are isolated from those created in the WebApp interface." + }, + "conversation_id": { + "type": "string", + "description": "Conversation ID to continue a conversation. Pass the previous message's conversation_id." + }, + "files": { + "type": "array", + "items": { + "$ref": "#/components/schemas/InputFileObject" + }, + "description": "File list (images) for Vision-capable models." + }, + "auto_generate_name": { + "type": "boolean", + "description": "Auto-generate conversation title. Default `true`. If `false`, use conversation rename API with `auto_generate: true` for async title generation.", + "default": true + } + } + }, + "InputFileObject": { + "type": "object", + "required": ["type", "transfer_method"], + "properties": { + "type": { + "type": "string", + "enum": ["image"], + "description": "Supported type: `image`." + }, + "transfer_method": { + "type": "string", + "enum": ["remote_url", "local_file"], + "description": "Transfer method, `remote_url` for image URL / `local_file` for file upload" + }, + "url": { + "type": "string", + "format": "url", + "description": "Image URL (when the transfer method is `remote_url`)" + }, + "upload_file_id": { + "type": "string", + "description": "Uploaded file ID, which must be obtained by uploading through the File Upload API in advance (when the transfer method is `local_file`)" + } + }, + "anyOf": [ + { + "properties": { + "transfer_method": { "enum": ["remote_url"] }, + "url": { "type": "string", "format": "url" } + }, + "required": ["url"], + "not": { "required": ["upload_file_id"] } + }, + { + "properties": { + "transfer_method": { "enum": ["local_file"] }, + "upload_file_id": { "type": "string" } + }, + "required": ["upload_file_id"], + "not": { "required": ["url"] } + } + ] + }, + "ChatCompletionResponse": { + "type": "object", + "description": "Response object for blocking mode chat completion.", + "properties": { + "event": { + "type": "string", + "description": "Event type, fixed as `message`.", + "example": "message" + }, + "task_id": { + "type": "string", + "format": "uuid", + "description": "Task ID for request tracking and stop response API." + }, + "id": { + "type": "string", + "format": "uuid", + "description": "Unique ID of this response/message event." + }, + "message_id": { + "type": "string", + "format": "uuid", + "description": "Unique message ID." + }, + "conversation_id": { + "type": "string", + "format": "uuid", + "description": "Conversation ID." + }, + "mode": { + "type": "string", + "description": "App mode, fixed as `chat`.", + "example": "chat" + }, + "answer": { + "type": "string", + "description": "Complete response content." + }, + "metadata": { + "type": "object", + "properties": { + "usage": { "$ref": "#/components/schemas/Usage" }, + "retriever_resources": { + "type": "array", + "items": { "$ref": "#/components/schemas/RetrieverResource" } + } + } + }, + "created_at": { + "type": "integer", + "format": "int64", + "description": "Message creation timestamp (Unix epoch seconds)." + } + } + }, + "ChunkChatEvent": { + "type": "object", + "description": "Base schema for Server-Sent Event chunks in streaming mode.", + "required": ["event"], + "properties": { + "event": { + "type": "string", + "description": "The type of event.", + "enum": ["message", "agent_message", "tts_message", "tts_message_end", "agent_thought", "message_file", "message_end", "message_replace", "error", "ping"] + } + }, + "discriminator": { + "propertyName": "event", + "mapping": { + "message": "#/components/schemas/StreamEventChatMessage", + "agent_message": "#/components/schemas/StreamEventChatAgentMessage", + "tts_message": "#/components/schemas/StreamEventChatTtsMessage", + "tts_message_end": "#/components/schemas/StreamEventChatTtsMessageEnd", + "agent_thought": "#/components/schemas/StreamEventChatAgentThought", + "message_file": "#/components/schemas/StreamEventChatMessageFile", + "message_end": "#/components/schemas/StreamEventChatMessageEnd", + "message_replace": "#/components/schemas/StreamEventChatMessageReplace", + "error": "#/components/schemas/StreamEventChatError", + "ping": "#/components/schemas/StreamEventChatPing" + } + } + }, + "StreamEventBase": { + "type": "object", + "properties": { + "task_id": { "type": "string", "format": "uuid", "description": "Task ID." }, + "message_id": { "type": "string", "format": "uuid", "description": "Unique message ID." }, + "conversation_id": { "type": "string", "format": "uuid", "description": "Conversation ID." }, + "created_at": { "type": "integer", "format": "int64", "description": "Creation timestamp." } + } + }, + "StreamEventChatMessage": { + "allOf": [ + { "$ref": "#/components/schemas/ChunkChatEvent" }, + { "$ref": "#/components/schemas/StreamEventBase" }, + { + "type": "object", + "required": ["answer"], + "properties": { + "answer": { "type": "string", "description": "LLM returned text chunk." } + } + } + ] + }, + "StreamEventChatAgentMessage": { + "allOf": [ + { "$ref": "#/components/schemas/ChunkChatEvent" }, + { "$ref": "#/components/schemas/StreamEventBase" }, + { + "type": "object", + "required": ["answer"], + "properties": { + "answer": { "type": "string", "description": "LLM returned text chunk (Agent mode)." } + } + } + ] + }, + "StreamEventChatTtsMessage": { + "allOf": [ + { "$ref": "#/components/schemas/ChunkChatEvent" }, + { "$ref": "#/components/schemas/StreamEventBase" }, + { + "type": "object", + "description": "TTS audio stream event (base64 encoded Mp3). Available if auto-play enabled.", + "required": ["audio"], + "properties": { + "audio": { "type": "string", "format": "byte", "description": "Base64 encoded audio chunk." } + } + } + ] + }, + "StreamEventChatTtsMessageEnd": { + "allOf": [ + { "$ref": "#/components/schemas/ChunkChatEvent" }, + { "$ref": "#/components/schemas/StreamEventBase" }, + { + "type": "object", + "description": "TTS audio stream end event.", + "required": ["audio"], + "properties": { + "audio": { "type": "string", "description": "Empty string for end event." } + } + } + ] + }, + "StreamEventChatAgentThought": { + "allOf": [ + { "$ref": "#/components/schemas/ChunkChatEvent" }, + { "$ref": "#/components/schemas/StreamEventBase" }, + { + "type": "object", + "description": "Agent thought, LLM thinking, tool call details (Agent mode).", + "required": ["id", "position"], + "properties": { + "id": { "type": "string", "format": "uuid", "description": "Agent thought ID." }, + "position": { "type": "integer", "description": "Position of this thought in the sequence for the message." }, + "thought": { "type": "string", "description": "What LLM is thinking." }, + "observation": { "type": "string", "description": "Response from tool calls." }, + "tool": { "type": "string", "description": "List of tools called, split by ';'." }, + "tool_input": { "type": "string", "description": "Input of tools in JSON format. Example: {\"dalle3\": {\"prompt\": \"a cute cat\"}}." }, + "message_files": { + "type": "array", + "items": { "type": "string", "format": "uuid" }, + "description": "File IDs of files related to this thought (e.g., generated by a tool)." + } + } + } + ] + }, + "StreamEventChatMessageFile": { + "allOf": [ + { "$ref": "#/components/schemas/ChunkChatEvent" }, + { + "type": "object", + "description": "Message file event, a new file created by a tool.", + "required": ["id", "type", "belongs_to", "url", "conversation_id"], + "properties": { + "id": { "type": "string", "format": "uuid", "description": "File unique ID." }, + "type": { "type": "string", "enum": ["image"], "description": "File type, currently only 'image'." }, + "belongs_to": { "type": "string", "enum": ["assistant"], "description": "Who this file belongs to, always 'assistant' here." }, + "url": { "type": "string", "format": "url", "description": "Remote URL of the file." }, + "conversation_id": { "type": "string", "format": "uuid", "description": "Conversation ID." } + } + } + ] + }, + "StreamEventChatMessageEnd": { + "allOf": [ + { "$ref": "#/components/schemas/ChunkChatEvent" }, + { "$ref": "#/components/schemas/StreamEventBase" }, + { + "type": "object", + "description": "Message end event, streaming has ended.", + "required": ["metadata"], + "properties": { + "metadata": { + "type": "object", + "properties": { + "usage": { "$ref": "#/components/schemas/Usage" }, + "retriever_resources": { + "type": "array", + "items": { "$ref": "#/components/schemas/RetrieverResource" } + } + } + } + } + } + ] + }, + "StreamEventChatMessageReplace": { + "allOf": [ + { "$ref": "#/components/schemas/ChunkChatEvent" }, + { "$ref": "#/components/schemas/StreamEventBase" }, + { + "type": "object", + "description": "Message content replacement event (e.g., due to content moderation).", + "required": ["answer"], + "properties": { + "answer": { "type": "string", "description": "Replacement content." } + } + } + ] + }, + "StreamEventChatError": { + "allOf": [ + { "$ref": "#/components/schemas/ChunkChatEvent" }, + { "$ref": "#/components/schemas/StreamEventBase" }, + { + "type": "object", + "description": "Error event during streaming.", + "required": ["status", "code", "message"], + "properties": { + "status": { "type": "integer", "description": "HTTP status code." }, + "code": { "type": "string", "description": "Error code." }, + "message": { "type": "string", "description": "Error message." } + } + } + ] + }, + "StreamEventChatPing": { + "allOf": [ + { "$ref": "#/components/schemas/ChunkChatEvent" }, + { + "type": "object", + "description": "Ping event to keep connection alive." + } + ] + }, + "Usage": { + "type": "object", + "description": "Model usage information.", + "properties": { + "prompt_tokens": { "type": "integer" }, + "prompt_unit_price": { "type": "string", "format": "decimal" }, + "prompt_price_unit": { "type": "string", "format": "decimal" }, + "prompt_price": { "type": "string", "format": "decimal" }, + "completion_tokens": { "type": "integer" }, + "completion_unit_price": { "type": "string", "format": "decimal" }, + "completion_price_unit": { "type": "string", "format": "decimal" }, + "completion_price": { "type": "string", "format": "decimal" }, + "total_tokens": { "type": "integer" }, + "total_price": { "type": "string", "format": "decimal" }, + "currency": { "type": "string", "example": "USD" }, + "latency": { "type": "number", "format": "double" } + } + }, + "RetrieverResource": { + "type": "object", + "description": "Citation and Attribution information for a resource.", + "properties": { + "position": { "type": "integer", "description": "Position of the resource in the list." }, + "dataset_id": { "type": "string", "format": "uuid", "description": "ID of the dataset." }, + "dataset_name": { "type": "string", "description": "Name of the dataset." }, + "document_id": { "type": "string", "format": "uuid", "description": "ID of the document." }, + "document_name": { "type": "string", "description": "Name of the document." }, + "segment_id": { "type": "string", "format": "uuid", "description": "ID of the specific segment within the document." }, + "score": { "type": "number", "format": "float", "description": "Relevance score of the resource." }, + "content": { "type": "string", "description": "Content snippet from the resource." } + } + }, + "FileUploadResponse": { + "type": "object", + "properties": { + "id": { "type": "string", "format": "uuid" }, + "name": { "type": "string" }, + "size": { "type": "integer" }, + "extension": { "type": "string" }, + "mime_type": { "type": "string" }, + "created_by": { "type": "string", "format": "uuid" }, + "created_at": { "type": "integer", "format": "int64" } + } + }, + "MessageFeedbackRequest": { + "type": "object", + "required": ["user"], + "properties": { + "rating": { + "type": "string", + "enum": ["like", "dislike", null], + "nullable": true + }, + "user": { "type": "string" }, + "content": { "type": "string" } + } + }, + "AppFeedbacksResponse": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { "$ref": "#/components/schemas/FeedbackItem" } + } + } + }, + "FeedbackItem": { + "type": "object", + "properties": { + "id": { "type": "string", "format": "uuid" }, + "app_id": { "type": "string", "format": "uuid" }, + "conversation_id": { "type": "string", "format": "uuid" }, + "message_id": { "type": "string", "format": "uuid" }, + "rating": { "type": "string", "enum": ["like", "dislike", null], "nullable": true }, + "content": { "type": "string" }, + "from_source": { "type": "string" }, + "from_end_user_id": { "type": "string", "format": "uuid" }, + "from_account_id": { "type": "string", "format": "uuid", "nullable": true }, + "created_at": { "type": "string", "format": "date-time" }, + "updated_at": { "type": "string", "format": "date-time" } + } + }, + "SuggestedQuestionsResponse": { + "type": "object", + "properties": { + "result": { "type": "string", "example": "success" }, + "data": { + "type": "array", + "items": { "type": "string" }, + "example": ["a", "b", "c"] + } + } + }, + "ConversationHistoryResponse": { + "type": "object", + "properties": { + "limit": { "type": "integer" }, + "has_more": { "type": "boolean" }, + "data": { + "type": "array", + "items": { "$ref": "#/components/schemas/ConversationMessageItem" } + } + } + }, + "ConversationMessageItem": { + "type": "object", + "properties": { + "id": { "type": "string", "format": "uuid" }, + "conversation_id": { "type": "string", "format": "uuid" }, + "inputs": { "type": "object", "additionalProperties": true }, + "query": { "type": "string" }, + "answer": { "type": "string" }, + "message_files": { + "type": "array", + "items": { "$ref": "#/components/schemas/MessageFileItem" } + }, + "feedback": { + "type": "object", + "nullable": true, + "properties": { + "rating": { "type": "string", "enum": ["like", "dislike"] } + } + }, + "retriever_resources": { + "type": "array", + "items": { "$ref": "#/components/schemas/RetrieverResource" } + }, + "agent_thoughts": { + "type": "array", + "items": { "$ref": "#/components/schemas/AgentThoughtItem" } + }, + "created_at": { "type": "integer", "format": "int64" } + } + }, + "MessageFileItem": { + "type": "object", + "properties": { + "id": { "type": "string", "format": "uuid" }, + "type": { "type": "string", "description": "File type, e.g., 'image'." }, + "url": { "type": "string", "format": "url", "description": "Preview image URL." }, + "belongs_to": { "type": "string", "enum": ["user", "assistant"], "description": "Who this file belongs to." } + } + }, + "AgentThoughtItem": { + "type": "object", + "properties": { + "id": { "type": "string", "format": "uuid", "description": "Agent thought ID." }, + "message_id": { "type": "string", "format": "uuid", "description": "Unique message ID this thought belongs to." }, + "position": { "type": "integer", "description": "Position of this thought." }, + "thought": { "type": "string", "description": "What LLM is thinking." }, + "tool": { "type": "string", "description": "Tools called, split by ';'." }, + "tool_input": { "type": "string", "description": "Input of tools in JSON format." }, + "observation": { "type": "string", "description": "Response from tool calls." }, + "files": { + "type": "array", + "items": { "type": "string", "format": "uuid" }, + "description": "File IDs related to this thought (from example, Markdown text says 'message_files')." + }, + "created_at": { "type": "integer", "format": "int64", "description": "Creation timestamp." } + } + }, + "ConversationsListResponse": { + "type": "object", + "properties": { + "limit": { "type": "integer" }, + "has_more": { "type": "boolean" }, + "data": { + "type": "array", + "items": { "$ref": "#/components/schemas/ConversationListItem" } + } + } + }, + "ConversationListItem": { + "type": "object", + "properties": { + "id": { "type": "string", "format": "uuid" }, + "name": { "type": "string" }, + "inputs": { "type": "object", "additionalProperties": true }, + "status": { "type": "string" }, + "introduction": { "type": "string" }, + "created_at": { "type": "integer", "format": "int64" }, + "updated_at": { "type": "integer", "format": "int64" } + } + }, + "ConversationRenameRequest": { + "type": "object", + "required": ["user"], + "properties": { + "name": { "type": "string", "description": "(Optional) The name of the conversation. Omit if auto_generate is true." }, + "auto_generate": { "type": "boolean", "default": false, "description": "(Optional) Automatically generate the title. Default false." }, + "user": { "type": "string", "description": "The user identifier." } + } + }, + "ConversationRenameResponse": { + "$ref": "#/components/schemas/ConversationListItem" + }, + "ConversationVariablesResponse": { + "type": "object", + "properties": { + "limit": { "type": "integer", "description": "Number of items per page." }, + "has_more": { "type": "boolean", "description": "Whether there is a next page." }, + "data": { + "type": "array", + "items": { "$ref": "#/components/schemas/ConversationVariableItem" } + } + } + }, + "ConversationVariableItem": { + "type": "object", + "properties": { + "id": { "type": "string", "format": "uuid", "description": "Variable ID." }, + "name": { "type": "string", "description": "Variable name." }, + "value_type": { "type": "string", "description": "Variable type (string, number, object, json, etc.)." }, + "value": { "type": "string", "description": "Variable value (can be a JSON string for complex types)." }, + "description": { "type": "string", "description": "Variable description." }, + "created_at": { "type": "integer", "format": "int64", "description": "Creation timestamp." }, + "updated_at": { "type": "integer", "format": "int64", "description": "Last update timestamp." } + } + }, + "AudioToTextRequest": { + "type": "object", + "required": ["file", "user"], + "properties": { + "file": { + "type": "string", + "format": "binary", + "description": "Audio file. Supported: mp3, mp4, mpeg, mpga, m4a, wav, webm. Limit: 15MB." + }, + "user": { + "type": "string", + "description": "User identifier." + } + } + }, + "AudioToTextResponse": { + "type": "object", + "properties": { + "text": { "type": "string", "description": "Output text from speech recognition." } + } + }, + "TextToAudioFormRequest": { + "type": "object", + "required": ["user"], + "properties": { + "message_id": { + "type": "string", + "format": "uuid", + "description": "Message ID (priority if both text and message_id provided)." + }, + "text": { + "type": "string", + "description": "Speech content." + }, + "user": { + "type": "string", + "description": "User identifier." + } + }, + "description": "Requires `user`. Provide either `message_id` or `text`." + }, + "AppInfoResponse": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "description": { "type": "string" }, + "tags": { "type": "array", "items": { "type": "string" } } + } + }, + "ChatAppParametersResponse": { + "type": "object", + "properties": { + "opening_statement": { "type": "string" }, + "suggested_questions": { "type": "array", "items": { "type": "string" } }, + "suggested_questions_after_answer": { + "type": "object", + "properties": { "enabled": { "type": "boolean" } } + }, + "speech_to_text": { + "type": "object", + "properties": { "enabled": { "type": "boolean" } } + }, + "text_to_speech": { + "type": "object", + "properties": { + "enabled": { "type": "boolean" }, + "voice": { "type": "string" }, + "language": { "type": "string" }, + "autoPlay": { "type": "string", "enum": ["enabled", "disabled"] } + } + }, + "retriever_resource": { + "type": "object", + "properties": { "enabled": { "type": "boolean" } } + }, + "annotation_reply": { + "type": "object", + "properties": { "enabled": { "type": "boolean" } } + }, + "user_input_form": { + "type": "array", + "items": { "$ref": "#/components/schemas/UserInputFormItem" } + }, + "file_upload": { + "type": "object", + "properties": { + "image": { + "type": "object", + "properties": { + "enabled": { "type": "boolean" }, + "number_limits": { "type": "integer" }, + "detail": { "type": "string" }, + "transfer_methods": { "type": "array", "items": { "type": "string", "enum": ["remote_url", "local_file"] } } + } + } + } + }, + "system_parameters": { + "type": "object", + "properties": { + "file_size_limit": { "type": "integer" }, + "image_file_size_limit": { "type": "integer" }, + "audio_file_size_limit": { "type": "integer" }, + "video_file_size_limit": { "type": "integer" } + } + } + } + }, + "UserInputFormItem": { + "type": "object", + "oneOf": [ + { "$ref": "#/components/schemas/TextInputControlWrapper" }, + { "$ref": "#/components/schemas/ParagraphControlWrapper" }, + { "$ref": "#/components/schemas/SelectControlWrapper" } + ] + }, + "TextInputControlWrapper": { + "type": "object", + "properties": { "text-input": { "$ref": "#/components/schemas/TextInputControl" } }, + "required": ["text-input"] + }, + "ParagraphControlWrapper": { + "type": "object", + "properties": { "paragraph": { "$ref": "#/components/schemas/ParagraphControl" } }, + "required": ["paragraph"] + }, + "SelectControlWrapper": { + "type": "object", + "properties": { "select": { "$ref": "#/components/schemas/SelectControl" } }, + "required": ["select"] + }, + "TextInputControl": { + "type": "object", + "required": ["label", "variable", "required"], + "properties": { "label": { "type": "string" }, "variable": { "type": "string" }, "required": { "type": "boolean" }, "default": { "type": "string" } } + }, + "ParagraphControl": { + "type": "object", + "required": ["label", "variable", "required"], + "properties": { "label": { "type": "string" }, "variable": { "type": "string" }, "required": { "type": "boolean" }, "default": { "type": "string" } } + }, + "SelectControl": { + "type": "object", + "required": ["label", "variable", "required", "options"], + "properties": { "label": { "type": "string" }, "variable": { "type": "string" }, "required": { "type": "boolean" }, "default": { "type": "string" }, "options": { "type": "array", "items": { "type": "string" } } } + }, + "AppMetaResponse": { + "type": "object", + "properties": { + "tool_icons": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { "type": "string", "format": "url", "description": "URL of the icon." }, + { "$ref": "#/components/schemas/ToolIconDetail" } + ] + }, + "description": "Tool icons. Keys are tool names." + } + } + }, + "ToolIconDetail": { + "type": "object", + "properties": { + "background": { "type": "string", "description": "Background color in hex format." }, + "content": { "type": "string", "description": "Emoji content." } + } + }, + "WebAppSettingsResponse": { + "type": "object", + "properties": { + "title": { "type": "string" }, + "chat_color_theme": { "type": "string" }, + "chat_color_theme_inverted": { "type": "boolean" }, + "icon_type": { "type": "string", "enum": ["emoji", "image"] }, + "icon": { "type": "string" }, + "icon_background": { "type": "string" }, + "icon_url": { "type": "string", "format": "url", "nullable": true }, + "description": { "type": "string" }, + "copyright": { "type": "string" }, + "privacy_policy": { "type": "string" }, + "custom_disclaimer": { "type": "string" }, + "default_language": { "type": "string" }, + "show_workflow_steps": { "type": "boolean" }, + "use_icon_as_answer_icon": { "type": "boolean" } + } + }, + "AnnotationListResponse": { + "type": "object", + "properties": { + "data": { "type": "array", "items": { "$ref": "#/components/schemas/AnnotationItem" } }, + "has_more": { "type": "boolean" }, + "limit": { "type": "integer" }, + "total": { "type": "integer" }, + "page": { "type": "integer" } + } + }, + "AnnotationItem": { + "type": "object", + "properties": { + "id": { "type": "string", "format": "uuid" }, + "question": { "type": "string" }, + "answer": { "type": "string" }, + "hit_count": { "type": "integer" }, + "created_at": { "type": "integer", "format": "int64" } + } + }, + "CreateAnnotationRequest": { + "type": "object", + "required": ["question", "answer"], + "properties": { + "question": { "type": "string" }, + "answer": { "type": "string" } + } + }, + "UpdateAnnotationRequest": { + "type": "object", + "required": ["question", "answer"], + "properties": { + "question": { "type": "string" }, + "answer": { "type": "string" } + } + }, + "InitialAnnotationReplySettingsRequest": { + "type": "object", + "required": ["score_threshold"], + "properties": { + "embedding_provider_name": { "type": "string", "description": "Specified embedding model provider name (Optional)." }, + "embedding_model_name": { "type": "string", "description": "Specified embedding model name (Optional)." }, + "score_threshold": { "type": "number", "format": "float", "description": "Similarity threshold for matching annotated replies." } + } + }, + "InitialAnnotationReplySettingsResponse": { + "type": "object", + "properties": { + "job_id": { "type": "string", "format": "uuid" }, + "job_status": { "type": "string" } + } + }, + "InitialAnnotationReplySettingsStatusResponse": { + "type": "object", + "properties": { + "job_id": { "type": "string", "format": "uuid" }, + "job_status": { "type": "string" }, + "error_msg": { "type": "string", "nullable": true } + } + }, + "ErrorResponse": { + "type": "object", + "properties": { + "status": { "type": "integer" }, + "code": { "type": "string" }, + "message": { "type": "string" } + } + } + } + }, + "tags": [ + { "name": "Chat", "description": "Operations related to chat messages and interactions." }, + { "name": "Files", "description": "File upload and preview operations." }, + { "name": "Feedback", "description": "User feedback operations." }, + { "name": "Conversations", "description": "Operations related to managing conversations." }, + { "name": "TTS", "description": "Text-to-Speech and Speech-to-Text operations." }, + { "name": "Application", "description": "Operations to retrieve application settings and information." }, + { "name": "Annotations", "description": "Operations related to managing annotations for direct replies." } + ] +}