mirror of
https://github.com/langgenius/dify.git
synced 2026-04-20 18:57:19 +08:00
add simple demo
This commit is contained in:
377
web/gen/orpc.ts
Normal file
377
web/gen/orpc.ts
Normal file
@ -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
|
||||
1367
web/gen/types.ts
Normal file
1367
web/gen/types.ts
Normal file
File diff suppressed because it is too large
Load Diff
1017
web/gen/zod.ts
Normal file
1017
web/gen/zod.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -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<string, unknown> & {
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user