mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 05:56:31 +08:00
outputStructure: 'detailed'
This commit is contained in:
parent
299f8b10c2
commit
54e7386e29
@ -1,54 +1,55 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import { oc } from '@orpc/contract'
|
||||
import { z } from 'zod'
|
||||
import { zAudioToTextData, zAudioToTextResponse, zCreateAnnotationData, zCreateAnnotationResponse, zDeleteAnnotationData, zDeleteConversationData, zGetAnnotationListData, zGetAnnotationListResponse, zGetChatAppFeedbacksData, zGetChatAppFeedbacksResponse, zGetChatAppInfoResponse, zGetChatAppMetaResponse, zGetChatAppParametersData, zGetChatAppParametersResponse, zGetChatWebAppSettingsResponse, zGetConversationHistoryData, zGetConversationHistoryResponse, zGetConversationsListData, zGetConversationsListResponse, zGetConversationVariablesData, zGetConversationVariablesResponse, zGetInitialAnnotationReplySettingsStatusData, zGetInitialAnnotationReplySettingsStatusResponse, zGetSuggestedQuestionsData, zGetSuggestedQuestionsResponse, zInitialAnnotationReplySettingsData, zInitialAnnotationReplySettingsResponse, zPostChatMessageFeedbackData, zPostChatMessageFeedbackResponse, zPreviewChatFileData, zPreviewChatFileResponse, zRenameConversationData, zRenameConversationResponse, zSendChatMessageData, zSendChatMessageResponse, zStopChatMessageGenerationData, zStopChatMessageGenerationResponse, zTextToAudioChatData, zTextToAudioChatResponse, zUpdateAnnotationData, zUpdateAnnotationResponse, zUploadChatFileData, zUploadChatFileResponse } from './zod.gen'
|
||||
|
||||
export const base = oc.$route({ inputStructure: 'detailed' })
|
||||
export const base = oc.$route({ inputStructure: 'detailed', outputStructure: 'detailed' })
|
||||
|
||||
/**
|
||||
* Send a request to the chat application.
|
||||
*/
|
||||
export const sendChatMessageContract = base.route({ path: '/chat-messages', method: 'POST' }).input(zSendChatMessageData).output(zSendChatMessageResponse)
|
||||
export const sendChatMessageContract = base.route({ path: '/chat-messages', method: 'POST' }).input(zSendChatMessageData).output(z.object({ body: zSendChatMessageResponse }))
|
||||
|
||||
/**
|
||||
* 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({ path: '/files/upload', method: 'POST' }).input(zUploadChatFileData).output(zUploadChatFileResponse)
|
||||
export const uploadChatFileContract = base.route({ path: '/files/upload', method: 'POST' }).input(zUploadChatFileData).output(z.object({ body: zUploadChatFileResponse }))
|
||||
|
||||
/**
|
||||
* 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({ path: '/files/{file_id}/preview', method: 'GET' }).input(zPreviewChatFileData).output(zPreviewChatFileResponse)
|
||||
export const previewChatFileContract = base.route({ path: '/files/{file_id}/preview', method: 'GET' }).input(zPreviewChatFileData).output(z.object({ body: zPreviewChatFileResponse }))
|
||||
|
||||
/**
|
||||
* Stops a chat message generation task. Only supported in streaming mode.
|
||||
*/
|
||||
export const stopChatMessageGenerationContract = base.route({ path: '/chat-messages/{task_id}/stop', method: 'POST' }).input(zStopChatMessageGenerationData).output(zStopChatMessageGenerationResponse)
|
||||
export const stopChatMessageGenerationContract = base.route({ path: '/chat-messages/{task_id}/stop', method: 'POST' }).input(zStopChatMessageGenerationData).output(z.object({ body: zStopChatMessageGenerationResponse }))
|
||||
|
||||
/**
|
||||
* End-users can provide feedback messages, facilitating application developers to optimize expected outputs.
|
||||
*/
|
||||
export const postChatMessageFeedbackContract = base.route({ path: '/messages/{message_id}/feedbacks', method: 'POST' }).input(zPostChatMessageFeedbackData).output(zPostChatMessageFeedbackResponse)
|
||||
export const postChatMessageFeedbackContract = base.route({ path: '/messages/{message_id}/feedbacks', method: 'POST' }).input(zPostChatMessageFeedbackData).output(z.object({ body: zPostChatMessageFeedbackResponse }))
|
||||
|
||||
/**
|
||||
* Get application's feedbacks.
|
||||
*/
|
||||
export const getChatAppFeedbacksContract = base.route({ path: '/app/feedbacks', method: 'GET' }).input(zGetChatAppFeedbacksData).output(zGetChatAppFeedbacksResponse)
|
||||
export const getChatAppFeedbacksContract = base.route({ path: '/app/feedbacks', method: 'GET' }).input(zGetChatAppFeedbacksData).output(z.object({ body: zGetChatAppFeedbacksResponse }))
|
||||
|
||||
/**
|
||||
* Get next questions suggestions for the current message.
|
||||
*/
|
||||
export const getSuggestedQuestionsContract = base.route({ path: '/messages/{message_id}/suggested', method: 'GET' }).input(zGetSuggestedQuestionsData).output(zGetSuggestedQuestionsResponse)
|
||||
export const getSuggestedQuestionsContract = base.route({ path: '/messages/{message_id}/suggested', method: 'GET' }).input(zGetSuggestedQuestionsData).output(z.object({ body: zGetSuggestedQuestionsResponse }))
|
||||
|
||||
/**
|
||||
* 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({ path: '/messages', method: 'GET' }).input(zGetConversationHistoryData).output(zGetConversationHistoryResponse)
|
||||
export const getConversationHistoryContract = base.route({ path: '/messages', method: 'GET' }).input(zGetConversationHistoryData).output(z.object({ body: zGetConversationHistoryResponse }))
|
||||
|
||||
/**
|
||||
* Retrieve the conversation list for the current user, defaulting to the most recent 20 entries.
|
||||
*/
|
||||
export const getConversationsListContract = base.route({ path: '/conversations', method: 'GET' }).input(zGetConversationsListData).output(zGetConversationsListResponse)
|
||||
export const getConversationsListContract = base.route({ path: '/conversations', method: 'GET' }).input(zGetConversationsListData).output(z.object({ body: zGetConversationsListResponse }))
|
||||
|
||||
/**
|
||||
* Delete a conversation.
|
||||
@ -58,52 +59,52 @@ export const deleteConversationContract = base.route({ path: '/conversations/{co
|
||||
/**
|
||||
* Rename the session. The session name is used for display on clients that support multiple sessions.
|
||||
*/
|
||||
export const renameConversationContract = base.route({ path: '/conversations/{conversation_id}/name', method: 'POST' }).input(zRenameConversationData).output(zRenameConversationResponse)
|
||||
export const renameConversationContract = base.route({ path: '/conversations/{conversation_id}/name', method: 'POST' }).input(zRenameConversationData).output(z.object({ body: zRenameConversationResponse }))
|
||||
|
||||
/**
|
||||
* Retrieve variables from a specific conversation.
|
||||
*/
|
||||
export const getConversationVariablesContract = base.route({ path: '/conversations/{conversation_id}/variables', method: 'GET' }).input(zGetConversationVariablesData).output(zGetConversationVariablesResponse)
|
||||
export const getConversationVariablesContract = base.route({ path: '/conversations/{conversation_id}/variables', method: 'GET' }).input(zGetConversationVariablesData).output(z.object({ body: zGetConversationVariablesResponse }))
|
||||
|
||||
/**
|
||||
* Convert audio file to text. Supported formats: mp3, mp4, mpeg, mpga, m4a, wav, webm. File size limit: 15MB.
|
||||
*/
|
||||
export const audioToTextContract = base.route({ path: '/audio-to-text', method: 'POST' }).input(zAudioToTextData).output(zAudioToTextResponse)
|
||||
export const audioToTextContract = base.route({ path: '/audio-to-text', method: 'POST' }).input(zAudioToTextData).output(z.object({ body: zAudioToTextResponse }))
|
||||
|
||||
/**
|
||||
* Convert text to speech.
|
||||
*/
|
||||
export const textToAudioChatContract = base.route({ path: '/text-to-audio', method: 'POST' }).input(zTextToAudioChatData).output(zTextToAudioChatResponse)
|
||||
export const textToAudioChatContract = base.route({ path: '/text-to-audio', method: 'POST' }).input(zTextToAudioChatData).output(z.object({ body: zTextToAudioChatResponse }))
|
||||
|
||||
/**
|
||||
* Used to get basic information about this application.
|
||||
*/
|
||||
export const getChatAppInfoContract = base.route({ path: '/info', method: 'GET' }).output(zGetChatAppInfoResponse)
|
||||
export const getChatAppInfoContract = base.route({ path: '/info', method: 'GET' }).output(z.object({ body: zGetChatAppInfoResponse }))
|
||||
|
||||
/**
|
||||
* 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({ path: '/parameters', method: 'GET' }).input(zGetChatAppParametersData).output(zGetChatAppParametersResponse)
|
||||
export const getChatAppParametersContract = base.route({ path: '/parameters', method: 'GET' }).input(zGetChatAppParametersData).output(z.object({ body: zGetChatAppParametersResponse }))
|
||||
|
||||
/**
|
||||
* Used to get icons of tools in this application.
|
||||
*/
|
||||
export const getChatAppMetaContract = base.route({ path: '/meta', method: 'GET' }).output(zGetChatAppMetaResponse)
|
||||
export const getChatAppMetaContract = base.route({ path: '/meta', method: 'GET' }).output(z.object({ body: zGetChatAppMetaResponse }))
|
||||
|
||||
/**
|
||||
* Used to get the WebApp settings of the application.
|
||||
*/
|
||||
export const getChatWebAppSettingsContract = base.route({ path: '/site', method: 'GET' }).output(zGetChatWebAppSettingsResponse)
|
||||
export const getChatWebAppSettingsContract = base.route({ path: '/site', method: 'GET' }).output(z.object({ body: zGetChatWebAppSettingsResponse }))
|
||||
|
||||
/**
|
||||
* Retrieves a list of annotations for the application.
|
||||
*/
|
||||
export const getAnnotationListContract = base.route({ path: '/apps/annotations', method: 'GET' }).input(zGetAnnotationListData).output(zGetAnnotationListResponse)
|
||||
export const getAnnotationListContract = base.route({ path: '/apps/annotations', method: 'GET' }).input(zGetAnnotationListData).output(z.object({ body: zGetAnnotationListResponse }))
|
||||
|
||||
/**
|
||||
* Creates a new annotation.
|
||||
*/
|
||||
export const createAnnotationContract = base.route({ path: '/apps/annotations', method: 'POST' }).input(zCreateAnnotationData).output(zCreateAnnotationResponse)
|
||||
export const createAnnotationContract = base.route({ path: '/apps/annotations', method: 'POST' }).input(zCreateAnnotationData).output(z.object({ body: zCreateAnnotationResponse }))
|
||||
|
||||
/**
|
||||
* Deletes an annotation.
|
||||
@ -113,17 +114,17 @@ export const deleteAnnotationContract = base.route({ path: '/apps/annotations/{a
|
||||
/**
|
||||
* Updates an existing annotation.
|
||||
*/
|
||||
export const updateAnnotationContract = base.route({ path: '/apps/annotations/{annotation_id}', method: 'PUT' }).input(zUpdateAnnotationData).output(zUpdateAnnotationResponse)
|
||||
export const updateAnnotationContract = base.route({ path: '/apps/annotations/{annotation_id}', method: 'PUT' }).input(zUpdateAnnotationData).output(z.object({ body: zUpdateAnnotationResponse }))
|
||||
|
||||
/**
|
||||
* Enable or disable annotation reply settings and configure embedding models. This interface is executed asynchronously.
|
||||
*/
|
||||
export const initialAnnotationReplySettingsContract = base.route({ path: '/apps/annotation-reply/{action}', method: 'POST' }).input(zInitialAnnotationReplySettingsData).output(zInitialAnnotationReplySettingsResponse)
|
||||
export const initialAnnotationReplySettingsContract = base.route({ path: '/apps/annotation-reply/{action}', method: 'POST' }).input(zInitialAnnotationReplySettingsData).output(z.object({ body: zInitialAnnotationReplySettingsResponse }))
|
||||
|
||||
/**
|
||||
* Queries the status of an asynchronously executed annotation reply settings task.
|
||||
*/
|
||||
export const getInitialAnnotationReplySettingsStatusContract = base.route({ path: '/apps/annotation-reply/{action}/status/{job_id}', method: 'GET' }).input(zGetInitialAnnotationReplySettingsStatusData).output(zGetInitialAnnotationReplySettingsStatusResponse)
|
||||
export const getInitialAnnotationReplySettingsStatusContract = base.route({ path: '/apps/annotation-reply/{action}/status/{job_id}', method: 'GET' }).input(zGetInitialAnnotationReplySettingsStatusData).output(z.object({ body: zGetInitialAnnotationReplySettingsStatusResponse }))
|
||||
|
||||
export const contracts = {
|
||||
chat: {
|
||||
|
||||
@ -85,6 +85,7 @@ export const handler: OrpcPlugin['Handler'] = ({ plugin }) => {
|
||||
exported: false,
|
||||
external: '@orpc/contract',
|
||||
})
|
||||
const symbolZ = plugin.external('zod.z')
|
||||
|
||||
// Register zod schema symbols (they come from zod plugin)
|
||||
const zodSchemaSymbols: Record<string, ReturnType<typeof plugin.symbol>> = {}
|
||||
@ -95,7 +96,7 @@ export const handler: OrpcPlugin['Handler'] = ({ plugin }) => {
|
||||
})
|
||||
}
|
||||
|
||||
// Create base contract: export const base = oc.$route({ inputStructure: 'detailed' })
|
||||
// Create base contract: export const base = oc.$route({ inputStructure: 'detailed', outputStructure: 'detailed' })
|
||||
const baseSymbol = plugin.symbol('base', {
|
||||
exported: true,
|
||||
meta: {
|
||||
@ -110,7 +111,8 @@ export const handler: OrpcPlugin['Handler'] = ({ plugin }) => {
|
||||
.attr('$route')
|
||||
.call(
|
||||
$.object()
|
||||
.prop('inputStructure', $.literal('detailed')),
|
||||
.prop('inputStructure', $.literal('detailed'))
|
||||
.prop('outputStructure', $.literal('detailed')),
|
||||
),
|
||||
)
|
||||
plugin.node(baseNode)
|
||||
@ -147,11 +149,18 @@ export const handler: OrpcPlugin['Handler'] = ({ plugin }) => {
|
||||
.call($(zodSchemaSymbols[op.zodDataSchema]))
|
||||
}
|
||||
|
||||
// .output(zodResponseSchema) if has output
|
||||
// .output(z.object({ body: zodResponseSchema })) if has output (detailed outputStructure)
|
||||
if (op.hasOutput) {
|
||||
expression = expression
|
||||
.attr('output')
|
||||
.call($(zodSchemaSymbols[op.zodResponseSchema]))
|
||||
.call(
|
||||
$(symbolZ)
|
||||
.attr('object')
|
||||
.call(
|
||||
$.object()
|
||||
.prop('body', $(zodSchemaSymbols[op.zodResponseSchema])),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
const contractNode = $.const(contractSymbol)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user