From 21a1e4ba82ce133fed62be00c14db48dcaeae0df Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Sun, 25 Jan 2026 20:41:30 +0800 Subject: [PATCH] add simple demo --- web/gen/orpc.ts | 377 +++++++++++ web/gen/types.ts | 1367 ++++++++++++++++++++++++++++++++++++++ web/gen/zod.ts | 1017 ++++++++++++++++++++++++++++ web/openapi-ts.config.ts | 19 +- 4 files changed, 2773 insertions(+), 7 deletions(-) create mode 100644 web/gen/orpc.ts create mode 100644 web/gen/types.ts create mode 100644 web/gen/zod.ts diff --git a/web/gen/orpc.ts b/web/gen/orpc.ts new file mode 100644 index 0000000000..0f480ab045 --- /dev/null +++ b/web/gen/orpc.ts @@ -0,0 +1,377 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { oc } from '@orpc/contract' +import { z } from 'zod' + +import { zAudioToTextData, zAudioToTextResponse2, zCreateAnnotationData, zCreateAnnotationResponse, zDeleteAnnotationData, zDeleteConversationData, zGetAnnotationListData, zGetAnnotationListResponse, zGetChatAppFeedbacksData, zGetChatAppFeedbacksResponse, zGetChatAppInfoResponse, zGetChatAppMetaResponse, zGetChatAppParametersData, zGetChatAppParametersResponse, zGetChatWebAppSettingsResponse, zGetConversationHistoryData, zGetConversationHistoryResponse, zGetConversationsListData, zGetConversationsListResponse, zGetConversationVariablesData, zGetConversationVariablesResponse, zGetInitialAnnotationReplySettingsStatusData, zGetInitialAnnotationReplySettingsStatusResponse, zGetSuggestedQuestionsData, zGetSuggestedQuestionsResponse, zInitialAnnotationReplySettingsData, zInitialAnnotationReplySettingsResponse2, zPostChatMessageFeedbackData, zPostChatMessageFeedbackResponse, zPreviewChatFileData, zPreviewChatFileResponse, zRenameConversationData, zRenameConversationResponse, zSendChatMessageData, zSendChatMessageResponse, zStopChatMessageGenerationData, zStopChatMessageGenerationResponse, zTextToAudioChatData, zTextToAudioChatResponse, zUpdateAnnotationData, zUpdateAnnotationResponse, zUploadChatFileData, zUploadChatFileResponse } from './zod' + +export const base = oc.$route({ inputStructure: 'detailed', outputStructure: 'detailed' }) + +/** + * Send Chat Message + * + * Send a request to the chat application. + */ +export const sendChatMessageContract = base.route({ + method: 'POST', + path: '/chat-messages', + operationId: 'sendChatMessage', + summary: 'Send Chat Message', + description: 'Send a request to the chat application.', + tags: ['Chat'], +}).input(zSendChatMessageData).output(z.object({ body: zSendChatMessageResponse, status: z.literal(200) })) + +/** + * File Upload + * + * 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 uploadChatFileContract = base.route({ + method: 'POST', + path: '/files/upload', + operationId: 'uploadChatFile', + 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.', + tags: ['Files'], +}).input(zUploadChatFileData).output(z.object({ body: zUploadChatFileResponse, status: z.literal(200) })) + +/** + * File Preview + * + * 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 previewChatFileContract = base.route({ + method: 'GET', + path: '/files/{file_id}/preview', + operationId: 'previewChatFile', + 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.', + tags: ['Files'], +}).input(zPreviewChatFileData).output(z.object({ body: zPreviewChatFileResponse, status: z.literal(200) })) + +/** + * Stop Chat Message Generation + * + * Stops a chat message generation task. Only supported in streaming mode. + */ +export const stopChatMessageGenerationContract = base.route({ + method: 'POST', + path: '/chat-messages/{task_id}/stop', + operationId: 'stopChatMessageGeneration', + summary: 'Stop Chat Message Generation', + description: 'Stops a chat message generation task. Only supported in streaming mode.', + tags: ['Chat'], +}).input(zStopChatMessageGenerationData).output(z.object({ body: zStopChatMessageGenerationResponse, status: z.literal(200) })) + +/** + * Message Feedback + * + * End-users can provide feedback messages, facilitating application developers to optimize expected outputs. + */ +export const postChatMessageFeedbackContract = base.route({ + method: 'POST', + path: '/messages/{message_id}/feedbacks', + operationId: 'postChatMessageFeedback', + summary: 'Message Feedback', + description: 'End-users can provide feedback messages, facilitating application developers to optimize expected outputs.', + tags: ['Feedback'], +}).input(zPostChatMessageFeedbackData).output(z.object({ body: zPostChatMessageFeedbackResponse, status: z.literal(200) })) + +/** + * Get feedbacks of application + * + * Get application's feedbacks. + */ +export const getChatAppFeedbacksContract = base.route({ + method: 'GET', + path: '/app/feedbacks', + operationId: 'getChatAppFeedbacks', + summary: 'Get feedbacks of application', + description: 'Get application\'s feedbacks.', + tags: ['Feedback'], +}).input(zGetChatAppFeedbacksData).output(z.object({ body: zGetChatAppFeedbacksResponse, status: z.literal(200) })) + +/** + * Next Suggested Questions + * + * Get next questions suggestions for the current message. + */ +export const getSuggestedQuestionsContract = base.route({ + method: 'GET', + path: '/messages/{message_id}/suggested', + operationId: 'getSuggestedQuestions', + summary: 'Next Suggested Questions', + description: 'Get next questions suggestions for the current message.', + tags: ['Chat'], +}).input(zGetSuggestedQuestionsData).output(z.object({ body: zGetSuggestedQuestionsResponse, status: z.literal(200) })) + +/** + * Get Conversation History Messages + * + * 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 getConversationHistoryContract = base.route({ + method: 'GET', + path: '/messages', + operationId: 'getConversationHistory', + 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.', + tags: ['Conversations'], +}).input(zGetConversationHistoryData).output(z.object({ body: zGetConversationHistoryResponse, status: z.literal(200) })) + +/** + * Get Conversations + * + * Retrieve the conversation list for the current user, defaulting to the most recent 20 entries. + */ +export const getConversationsListContract = base.route({ + method: 'GET', + path: '/conversations', + operationId: 'getConversationsList', + summary: 'Get Conversations', + description: 'Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.', + tags: ['Conversations'], +}).input(zGetConversationsListData).output(z.object({ body: zGetConversationsListResponse, status: z.literal(200) })) + +/** + * Delete Conversation + * + * Delete a conversation. + */ +export const deleteConversationContract = base.route({ + method: 'DELETE', + path: '/conversations/{conversation_id}', + operationId: 'deleteConversation', + summary: 'Delete Conversation', + description: 'Delete a conversation.', + tags: ['Conversations'], +}).input(zDeleteConversationData) + +/** + * Conversation Rename + * + * Rename the session. The session name is used for display on clients that support multiple sessions. + */ +export const renameConversationContract = base.route({ + method: 'POST', + path: '/conversations/{conversation_id}/name', + operationId: 'renameConversation', + summary: 'Conversation Rename', + description: 'Rename the session. The session name is used for display on clients that support multiple sessions.', + tags: ['Conversations'], +}).input(zRenameConversationData).output(z.object({ body: zRenameConversationResponse, status: z.literal(200) })) + +/** + * Get Conversation Variables + * + * Retrieve variables from a specific conversation. + */ +export const getConversationVariablesContract = base.route({ + method: 'GET', + path: '/conversations/{conversation_id}/variables', + operationId: 'getConversationVariables', + summary: 'Get Conversation Variables', + description: 'Retrieve variables from a specific conversation.', + tags: ['Conversations'], +}).input(zGetConversationVariablesData).output(z.object({ body: zGetConversationVariablesResponse, status: z.literal(200) })) + +/** + * Speech to Text + * + * Convert audio file to text. Supported formats: mp3, mp4, mpeg, mpga, m4a, wav, webm. File size limit: 15MB. + */ +export const audioToTextContract = base.route({ + method: 'POST', + path: '/audio-to-text', + operationId: 'audioToText', + summary: 'Speech to Text', + description: 'Convert audio file to text. Supported formats: mp3, mp4, mpeg, mpga, m4a, wav, webm. File size limit: 15MB.', + tags: ['TTS'], +}).input(zAudioToTextData).output(z.object({ body: zAudioToTextResponse2, status: z.literal(200) })) + +/** + * Text to Audio + * + * Convert text to speech. + */ +export const textToAudioChatContract = base.route({ + method: 'POST', + path: '/text-to-audio', + operationId: 'textToAudioChat', + summary: 'Text to Audio', + description: 'Convert text to speech.', + tags: ['TTS'], +}).input(zTextToAudioChatData).output(z.object({ body: zTextToAudioChatResponse, status: z.literal(200) })) + +/** + * Get Application Basic Information + * + * Used to get basic information about this application. + */ +export const getChatAppInfoContract = base.route({ + method: 'GET', + path: '/info', + operationId: 'getChatAppInfo', + summary: 'Get Application Basic Information', + description: 'Used to get basic information about this application.', + tags: ['Application'], +}).output(z.object({ body: zGetChatAppInfoResponse, status: z.literal(200) })) + +/** + * Get Application Parameters Information + * + * Used at the start of entering the page to obtain information such as features, input parameter names, types, and default values. + */ +export const getChatAppParametersContract = base.route({ + method: 'GET', + path: '/parameters', + operationId: 'getChatAppParameters', + 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.', + tags: ['Application'], +}).input(zGetChatAppParametersData).output(z.object({ body: zGetChatAppParametersResponse, status: z.literal(200) })) + +/** + * Get Application Meta Information + * + * Used to get icons of tools in this application. + */ +export const getChatAppMetaContract = base.route({ + method: 'GET', + path: '/meta', + operationId: 'getChatAppMeta', + summary: 'Get Application Meta Information', + description: 'Used to get icons of tools in this application.', + tags: ['Application'], +}).output(z.object({ body: zGetChatAppMetaResponse, status: z.literal(200) })) + +/** + * Get Application WebApp Settings + * + * Used to get the WebApp settings of the application. + */ +export const getChatWebAppSettingsContract = base.route({ + method: 'GET', + path: '/site', + operationId: 'getChatWebAppSettings', + summary: 'Get Application WebApp Settings', + description: 'Used to get the WebApp settings of the application.', + tags: ['Application'], +}).output(z.object({ body: zGetChatWebAppSettingsResponse, status: z.literal(200) })) + +/** + * Get Annotation List + * + * Retrieves a list of annotations for the application. + */ +export const getAnnotationListContract = base.route({ + method: 'GET', + path: '/apps/annotations', + operationId: 'getAnnotationList', + summary: 'Get Annotation List', + description: 'Retrieves a list of annotations for the application.', + tags: ['Annotations'], +}).input(zGetAnnotationListData).output(z.object({ body: zGetAnnotationListResponse, status: z.literal(200) })) + +/** + * Create Annotation + * + * Creates a new annotation. + */ +export const createAnnotationContract = base.route({ + method: 'POST', + path: '/apps/annotations', + operationId: 'createAnnotation', + summary: 'Create Annotation', + description: 'Creates a new annotation.', + tags: ['Annotations'], +}).input(zCreateAnnotationData).output(z.object({ body: zCreateAnnotationResponse, status: z.literal(200) })) + +/** + * Delete Annotation + * + * Deletes an annotation. + */ +export const deleteAnnotationContract = base.route({ + method: 'DELETE', + path: '/apps/annotations/{annotation_id}', + operationId: 'deleteAnnotation', + summary: 'Delete Annotation', + description: 'Deletes an annotation.', + tags: ['Annotations'], +}).input(zDeleteAnnotationData) + +/** + * Update Annotation + * + * Updates an existing annotation. + */ +export const updateAnnotationContract = base.route({ + method: 'PUT', + path: '/apps/annotations/{annotation_id}', + operationId: 'updateAnnotation', + summary: 'Update Annotation', + description: 'Updates an existing annotation.', + tags: ['Annotations'], +}).input(zUpdateAnnotationData).output(z.object({ body: zUpdateAnnotationResponse, status: z.literal(200) })) + +/** + * Initial Annotation Reply Settings + * + * Enable or disable annotation reply settings and configure embedding models. This interface is executed asynchronously. + */ +export const initialAnnotationReplySettingsContract = base.route({ + method: 'POST', + path: '/apps/annotation-reply/{action}', + operationId: 'initialAnnotationReplySettings', + summary: 'Initial Annotation Reply Settings', + description: 'Enable or disable annotation reply settings and configure embedding models. This interface is executed asynchronously.', + tags: ['Annotations'], +}).input(zInitialAnnotationReplySettingsData).output(z.object({ body: zInitialAnnotationReplySettingsResponse2, status: z.literal(200) })) + +/** + * Query Initial Annotation Reply Settings Task Status + * + * Queries the status of an asynchronously executed annotation reply settings task. + */ +export const getInitialAnnotationReplySettingsStatusContract = base.route({ + method: 'GET', + path: '/apps/annotation-reply/{action}/status/{job_id}', + operationId: 'getInitialAnnotationReplySettingsStatus', + summary: 'Query Initial Annotation Reply Settings Task Status', + description: 'Queries the status of an asynchronously executed annotation reply settings task.', + tags: ['Annotations'], +}).input(zGetInitialAnnotationReplySettingsStatusData).output(z.object({ body: zGetInitialAnnotationReplySettingsStatusResponse, status: z.literal(200) })) + +export const router = { + chatMessages: { send: sendChatMessageContract, stopGeneration: stopChatMessageGenerationContract }, + files: { uploadChat: uploadChatFileContract, previewChat: previewChatFileContract }, + messages: { + postChatFeedback: postChatMessageFeedbackContract, + getSuggestedQuestions: getSuggestedQuestionsContract, + getConversationHistory: getConversationHistoryContract, + }, + app: { getChatFeedbacks: getChatAppFeedbacksContract }, + conversations: { + getList: getConversationsListContract, + delete: deleteConversationContract, + rename: renameConversationContract, + getVariables: getConversationVariablesContract, + }, + audioToText: { audioToText: audioToTextContract }, + textToAudio: { textToAudioChat: textToAudioChatContract }, + info: { getChatApp: getChatAppInfoContract }, + parameters: { getChatApp: getChatAppParametersContract }, + meta: { getChatApp: getChatAppMetaContract }, + site: { getChatWebAppSettings: getChatWebAppSettingsContract }, + apps: { + getAnnotationList: getAnnotationListContract, + createAnnotation: createAnnotationContract, + deleteAnnotation: deleteAnnotationContract, + updateAnnotation: updateAnnotationContract, + initialAnnotationReplySettings: initialAnnotationReplySettingsContract, + getInitialAnnotationReplySettingsStatus: getInitialAnnotationReplySettingsStatusContract, + }, +} + +export type Router = typeof router diff --git a/web/gen/types.ts b/web/gen/types.ts new file mode 100644 index 0000000000..bd15f98fab --- /dev/null +++ b/web/gen/types.ts @@ -0,0 +1,1367 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type ClientOptions = { + baseUrl: `${string}://{api_base_url}` | (string & {}) +} + +export type ChatRequest = { + /** + * User Input/Question content. + */ + query: string + /** + * Allows the entry of various variable values defined by the App. Contains key/value pairs. Default {}. + */ + inputs?: { + [key: string]: unknown + } + /** + * 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?: 'streaming' | 'blocking' + /** + * 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. + */ + user: string + /** + * Conversation ID to continue a conversation. Pass the previous message's conversation_id. + */ + conversation_id?: string + /** + * File list (images) for Vision-capable models. + */ + 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 +} + +/** + * Response object for blocking mode chat completion. + */ +export type ChatCompletionResponse = { + /** + * 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 + /** + * Position of this thought in the sequence for the message. + */ + position: number + /** + * What LLM is thinking. + */ + thought?: string + /** + * Response from tool calls. + */ + observation?: string + /** + * List of tools called, split by ';'. + */ + tool?: string + /** + * Input of tools in JSON format. Example: {"dalle3": {"prompt": "a cute cat"}}. + */ + tool_input?: string + /** + * File IDs of files related to this thought (e.g., generated by a tool). + */ + message_files?: Array + event: 'agent_thought' +} + +export type StreamEventChatMessageFile = Omit & { + /** + * File unique ID. + */ + id: string + /** + * File type, currently only 'image'. + */ + type: 'image' + /** + * Who this file belongs to, always 'assistant' here. + */ + belongs_to: 'assistant' + /** + * 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' +} + +/** + * Model usage information. + */ +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 = { + /** + * Position of the resource in the list. + */ + 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 + /** + * 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 +} + +/** + * Requires `user`. Provide either `message_id` or `text`. + */ +export type TextToAudioFormRequest = { + /** + * Message ID (priority if both text and message_id provided). + */ + message_id?: string + /** + * Speech content. + */ + text?: string + /** + * User identifier. + */ + user: string +} + +export type AppInfoResponse = { + name?: string + description?: string + tags?: Array +} + +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 UserInputFormItem = TextInputControlWrapper | ParagraphControlWrapper | SelectControlWrapper + +export type TextInputControlWrapper = { + 'text-input': TextInputControl +} + +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 SendChatMessageErrors = { + /** + * 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: ErrorResponse + /** + * Conversation does not exist. + */ + 404: ErrorResponse + /** + * Internal server error. + */ + 500: ErrorResponse +} + +export type SendChatMessageError = SendChatMessageErrors[keyof SendChatMessageErrors] + +export type SendChatMessageResponses = { + /** + * 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: ChatCompletionResponse +} + +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: { + /** + * 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 + } + query?: never + url: '/chat-messages/{task_id}/stop' +} + +export type StopChatMessageGenerationResponses = { + /** + * Operation successful. + */ + 200: { + result?: string + } +} + +export type StopChatMessageGenerationResponse = StopChatMessageGenerationResponses[keyof StopChatMessageGenerationResponses] + +export type PostChatMessageFeedbackData = { + body: MessageFeedbackRequest + path: { + /** + * Message ID for which feedback is being provided. + */ + message_id: string + } + query?: never + url: '/messages/{message_id}/feedbacks' +} + +export type PostChatMessageFeedbackResponses = { + /** + * Operation successful. + */ + 200: { + result?: string + } +} + +export type PostChatMessageFeedbackResponse = PostChatMessageFeedbackResponses[keyof PostChatMessageFeedbackResponses] + +export type GetChatAppFeedbacksData = { + body?: never + path?: never + query?: { + /** + * (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 + /** + * (Optional) How many records to return. Default 20, Min 1, Max 100. + */ + limit?: number + /** + * Sorting Field. Default: -updated_at. '-' prefix for descending. + */ + sort_by?: 'created_at' | '-created_at' | 'updated_at' | '-updated_at' + } + url: '/conversations' +} + +export type GetConversationsListResponses = { + /** + * Successfully retrieved conversations list. + */ + 200: ConversationsListResponse +} + +export type GetConversationsListResponse = GetConversationsListResponses[keyof GetConversationsListResponses] + +export type DeleteConversationData = { + 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 ID. + */ + conversation_id: string + } + query?: never + url: '/conversations/{conversation_id}' +} + +export type DeleteConversationResponses = { + /** + * Conversation deleted successfully. No Content. + */ + 204: void +} + +export type DeleteConversationResponse = DeleteConversationResponses[keyof DeleteConversationResponses] + +export type RenameConversationData = { + body: ConversationRenameRequest + path: { + /** + * Conversation ID. + */ + conversation_id: string + } + query?: never + url: '/conversations/{conversation_id}/name' +} + +export type RenameConversationResponses = { + /** + * Conversation renamed successfully. + */ + 200: ConversationListItem +} + +export type RenameConversationResponse = RenameConversationResponses[keyof RenameConversationResponses] + +export type GetConversationVariablesData = { + body?: never + path: { + /** + * The ID of the conversation to retrieve variables from. + */ + conversation_id: string + } + query: { + /** + * The user identifier. + */ + 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 + } + url: '/conversations/{conversation_id}/variables' +} + +export type GetConversationVariablesErrors = { + /** + * Conversation not found. Error code: `conversation_not_exists` + */ + 404: ErrorResponse +} + +export type GetConversationVariablesError = GetConversationVariablesErrors[keyof GetConversationVariablesErrors] + +export type GetConversationVariablesResponses = { + /** + * Successfully retrieved conversation variables. + */ + 200: ConversationVariablesResponse +} + +export type GetConversationVariablesResponse = GetConversationVariablesResponses[keyof GetConversationVariablesResponses] + +export type AudioToTextData = { + body: AudioToTextRequest + path?: never + query?: never + url: '/audio-to-text' +} + +export type AudioToTextResponses = { + /** + * Successfully converted audio to text. + */ + 200: AudioToTextResponse +} + +export type AudioToTextResponse2 = AudioToTextResponses[keyof AudioToTextResponses] + +export type TextToAudioChatData = { + body: TextToAudioFormRequest + path?: never + query?: never + url: '/text-to-audio' +} + +export type TextToAudioChatResponses = { + /** + * The generated audio file. + */ + 200: Blob | File +} + +export type TextToAudioChatResponse = TextToAudioChatResponses[keyof TextToAudioChatResponses] + +export type GetChatAppInfoData = { + body?: never + path?: never + query?: never + url: '/info' +} + +export type GetChatAppInfoResponses = { + /** + * Basic information of the application. + */ + 200: AppInfoResponse +} + +export type GetChatAppInfoResponse = GetChatAppInfoResponses[keyof GetChatAppInfoResponses] + +export type GetChatAppParametersData = { + body?: never + path?: never + query: { + /** + * User identifier, defined by the developer's rules, must be unique within the application. + */ + user: string + } + url: '/parameters' +} + +export type GetChatAppParametersResponses = { + /** + * Application parameters information. + */ + 200: ChatAppParametersResponse +} + +export type GetChatAppParametersResponse = GetChatAppParametersResponses[keyof GetChatAppParametersResponses] + +export type GetChatAppMetaData = { + body?: never + path?: never + query?: never + url: '/meta' +} + +export type GetChatAppMetaResponses = { + /** + * Successfully retrieved application meta information. + */ + 200: AppMetaResponse +} + +export type GetChatAppMetaResponse = GetChatAppMetaResponses[keyof GetChatAppMetaResponses] + +export type GetChatWebAppSettingsData = { + body?: never + path?: never + query?: never + url: '/site' +} + +export type GetChatWebAppSettingsResponses = { + /** + * WebApp settings of the application. + */ + 200: WebAppSettingsResponse +} + +export type GetChatWebAppSettingsResponse = GetChatWebAppSettingsResponses[keyof GetChatWebAppSettingsResponses] + +export type GetAnnotationListData = { + body?: never + path?: never + query?: { + /** + * Page number. + */ + page?: number + /** + * Number of items returned, default 20, range 1-100. + */ + limit?: number + } + url: '/apps/annotations' +} + +export type GetAnnotationListResponses = { + /** + * Successfully retrieved annotation list. + */ + 200: AnnotationListResponse +} + +export type GetAnnotationListResponse = GetAnnotationListResponses[keyof GetAnnotationListResponses] + +export type CreateAnnotationData = { + body: CreateAnnotationRequest + path?: never + query?: never + url: '/apps/annotations' +} + +export type CreateAnnotationResponses = { + /** + * Annotation created successfully. + */ + 200: AnnotationItem +} + +export type CreateAnnotationResponse = CreateAnnotationResponses[keyof CreateAnnotationResponses] + +export type DeleteAnnotationData = { + body?: never + path: { + /** + * Annotation ID. + */ + annotation_id: string + } + query?: never + url: '/apps/annotations/{annotation_id}' +} + +export type DeleteAnnotationResponses = { + /** + * Annotation deleted successfully. No Content. + */ + 204: void +} + +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.ts b/web/gen/zod.ts new file mode 100644 index 0000000000..c88c85c305 --- /dev/null +++ b/web/gen/zod.ts @@ -0,0 +1,1017 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod' + +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 ChatRequestZodType = z.infer + +/** + * Base schema for Server-Sent Event chunks in streaming mode. + */ +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 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 + +/** + * Model usage information. + */ +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 FileUploadResponseZodType = z.infer + +export const zMessageFeedbackRequest = z.object({ + rating: z.enum(['like', 'dislike']).nullable().optional(), + user: z.string(), + content: z.string().optional(), +}) + +export type MessageFeedbackRequestZodType = z.infer + +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 FeedbackItemZodType = z.infer + +export const zAppFeedbacksResponse = z.object({ + data: z.array(zFeedbackItem).optional(), +}) + +export type AppFeedbacksResponseZodType = z.infer + +export const zSuggestedQuestionsResponse = z.object({ + result: z.string().optional(), + data: z.array(z.string()).optional(), +}) + +export type SuggestedQuestionsResponseZodType = z.infer + +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 MessageFileItemZodType = z.infer + +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 AgentThoughtItemZodType = z.infer + +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 ConversationMessageItemZodType = z.infer + +export const zConversationHistoryResponse = z.object({ + limit: z.number().int().optional(), + has_more: z.boolean().optional(), + data: z.array(zConversationMessageItem).optional(), +}) + +export type ConversationHistoryResponseZodType = z.infer + +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 ConversationListItemZodType = z.infer + +export const zConversationsListResponse = z.object({ + limit: z.number().int().optional(), + has_more: z.boolean().optional(), + data: z.array(zConversationListItem).optional(), +}) + +export type ConversationsListResponseZodType = z.infer + +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 ConversationRenameRequestZodType = z.infer + +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 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 + +/** + * Requires `user`. Provide either `message_id` or `text`. + */ +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 InitialAnnotationReplySettingsStatusResponseZodType = z.infer + +export const zErrorResponse = z.object({ + status: z.number().int().optional(), + code: z.string().optional(), + message: z.string().optional(), +}) + +export type ErrorResponseZodType = z.infer + +export const zSendChatMessageData = z.object({ + body: zChatRequest, + path: z.never().optional(), + query: z.never().optional(), +}) + +export type SendChatMessageDataZodType = z.infer + +/** + * 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 UploadChatFileDataZodType = z.infer + +/** + * File uploaded successfully. + */ +export const zUploadChatFileResponse = zFileUploadResponse + +export type UploadChatFileResponseZodType = z.infer + +export const zPreviewChatFileData = z.object({ + body: z.never().optional(), + path: z.object({ + 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 StopChatMessageGenerationDataZodType = z.infer + +/** + * Operation successful. + */ +export const zStopChatMessageGenerationResponse = z.object({ + result: z.string().optional(), +}).describe('Operation successful.') + +export type StopChatMessageGenerationResponseZodType = z.infer + +export const zPostChatMessageFeedbackData = z.object({ + body: zMessageFeedbackRequest, + path: z.object({ + message_id: z.string().describe('Message ID for which feedback is being provided.'), + }), + query: z.never().optional(), +}) + +export type PostChatMessageFeedbackDataZodType = z.infer + +/** + * 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({ + 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('Sorting Field. Default: -updated_at. \'-\' prefix for descending.').optional(), + }), +}) + +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.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({ + conversation_id: z.string().describe('Conversation ID.'), + }), + query: z.never().optional(), +}) + +export type DeleteConversationDataZodType = z.infer + +/** + * Conversation deleted successfully. No Content. + */ +export const zDeleteConversationResponse = z.void().describe('Conversation deleted successfully. No Content.') + +export type DeleteConversationResponseZodType = z.infer + +export const zRenameConversationData = z.object({ + body: zConversationRenameRequest, + path: z.object({ + conversation_id: z.string().describe('Conversation ID.'), + }), + query: z.never().optional(), +}) + +export type RenameConversationDataZodType = z.infer + +/** + * Conversation renamed successfully. + */ +export const zRenameConversationResponse = zConversationListItem + +export type RenameConversationResponseZodType = z.infer + +export const zGetConversationVariablesData = z.object({ + body: z.never().optional(), + path: z.object({ + conversation_id: z.string().describe('The ID of the conversation to retrieve variables from.'), + }), + 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(), + }), +}) + +export type GetConversationVariablesDataZodType = z.infer + +/** + * Successfully retrieved conversation variables. + */ +export const zGetConversationVariablesResponse = zConversationVariablesResponse + +export type GetConversationVariablesResponseZodType = z.infer + +export const zAudioToTextData = z.object({ + body: zAudioToTextRequest, + path: z.never().optional(), + query: z.never().optional(), +}) + +export type AudioToTextDataZodType = z.infer + +/** + * 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 TextToAudioChatDataZodType = z.infer + +/** + * The generated audio file. + */ +export const zTextToAudioChatResponse = z.string().describe('The generated audio file.') + +export type TextToAudioChatResponseZodType = z.infer + +export const zGetChatAppInfoData = z.object({ + body: z.never().optional(), + path: z.never().optional(), + query: z.never().optional(), +}) + +export type GetChatAppInfoDataZodType = z.infer + +/** + * Basic information of the application. + */ +export const zGetChatAppInfoResponse = zAppInfoResponse + +export type GetChatAppInfoResponseZodType = z.infer + +export const zGetChatAppParametersData = z.object({ + body: z.never().optional(), + path: z.never().optional(), + query: z.object({ + user: z.string().describe('User identifier, defined by the developer\'s rules, must be unique within the application.'), + }), +}) + +export type GetChatAppParametersDataZodType = z.infer + +/** + * Application parameters information. + */ +export const zGetChatAppParametersResponse = zChatAppParametersResponse + +export type GetChatAppParametersResponseZodType = z.infer + +export const zGetChatAppMetaData = z.object({ + body: z.never().optional(), + 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({ + 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 GetAnnotationListDataZodType = z.infer + +/** + * Successfully retrieved annotation list. + */ +export const zGetAnnotationListResponse = zAnnotationListResponse + +export type GetAnnotationListResponseZodType = z.infer + +export const zCreateAnnotationData = z.object({ + body: zCreateAnnotationRequest, + path: z.never().optional(), + query: z.never().optional(), +}) + +export type CreateAnnotationDataZodType = z.infer + +/** + * Annotation created successfully. + */ +export const zCreateAnnotationResponse = zAnnotationItem + +export type CreateAnnotationResponseZodType = z.infer + +export const zDeleteAnnotationData = z.object({ + body: z.never().optional(), + path: z.object({ + annotation_id: z.string().describe('Annotation ID.'), + }), + query: z.never().optional(), +}) + +export type DeleteAnnotationDataZodType = z.infer + +/** + * Annotation deleted successfully. No Content. + */ +export const zDeleteAnnotationResponse = z.void().describe('Annotation deleted successfully. No Content.') + +export type DeleteAnnotationResponseZodType = z.infer + +export const zUpdateAnnotationData = z.object({ + body: zUpdateAnnotationRequest, + path: z.object({ + annotation_id: z.string().describe('Annotation ID.'), + }), + query: z.never().optional(), +}) + +export type UpdateAnnotationDataZodType = z.infer + +/** + * 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({ + 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 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 60d15a7289..b47c03e509 100644 --- a/web/openapi-ts.config.ts +++ b/web/openapi-ts.config.ts @@ -3,6 +3,8 @@ import { defineConfig } from '@hey-api/openapi-ts' import { defineConfig as defineOrpcConfig } from './plugins/hey-api-orpc/config' +const split = false + // Symbol type for the getFilePath hook (not publicly exported by hey-api) type SymbolMeta = Record & { tags?: readonly string[] @@ -96,6 +98,7 @@ export default defineConfig({ fileName: { suffix: null, }, + clean: false, }, plugins: [ '@hey-api/typescript', @@ -113,11 +116,13 @@ export default defineConfig({ output: 'orpc', }), ], - parser: { - hooks: { - symbols: { - getFilePath, - }, - }, - }, + parser: split + ? { + hooks: { + symbols: { + getFilePath, + }, + }, + } + : undefined, } satisfies UserConfig)