mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
Feature: interactive swagger-ui auto-generated API docs from express (#1812)
* Add interactive swagger-ui auto-generated API docs from express * Update README.md * Update index.ts //@ts-ignore * Fix eslint no-console error * Add swagger paths * Add all end points * Update swagger.yml * update swagger yml file * update swagger config --------- Co-authored-by: Henry <hzj94@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
0f58d31493
commit
e8f5f07735
@@ -48,14 +48,14 @@ const getAllApiKeys = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const getApiKey = async (keyName: string) => {
|
||||
const getApiKey = async (apiKey: string) => {
|
||||
try {
|
||||
if (_apikeysStoredInJson()) {
|
||||
return getApiKey_json(keyName)
|
||||
return getApiKey_json(apiKey)
|
||||
} else if (_apikeysStoredInDb()) {
|
||||
const appServer = getRunningExpressApp()
|
||||
const currentKey = await appServer.AppDataSource.getRepository(ApiKey).findOneBy({
|
||||
keyName: keyName
|
||||
apiKey: apiKey
|
||||
})
|
||||
if (!currentKey) {
|
||||
return undefined
|
||||
|
||||
@@ -7,8 +7,9 @@ import { Credential } from '../../database/entities/Credential'
|
||||
import { decryptCredentialData, getAppVersion } from '../../utils'
|
||||
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
|
||||
import { getErrorMessage } from '../../errors/utils'
|
||||
import { DeleteResult } from 'typeorm'
|
||||
|
||||
const createAssistant = async (requestBody: any): Promise<any> => {
|
||||
const createAssistant = async (requestBody: any): Promise<Assistant> => {
|
||||
try {
|
||||
const appServer = getRunningExpressApp()
|
||||
if (!requestBody.details) {
|
||||
@@ -119,7 +120,7 @@ const createAssistant = async (requestBody: any): Promise<any> => {
|
||||
}
|
||||
}
|
||||
|
||||
const deleteAssistant = async (assistantId: string, isDeleteBoth: any): Promise<any> => {
|
||||
const deleteAssistant = async (assistantId: string, isDeleteBoth: any): Promise<DeleteResult> => {
|
||||
try {
|
||||
const appServer = getRunningExpressApp()
|
||||
const assistant = await appServer.AppDataSource.getRepository(Assistant).findOneBy({
|
||||
@@ -150,11 +151,7 @@ const deleteAssistant = async (assistantId: string, isDeleteBoth: any): Promise<
|
||||
if (isDeleteBoth) await openai.beta.assistants.del(assistantDetails.id)
|
||||
return dbResponse
|
||||
} catch (error: any) {
|
||||
if (error.status === 404 && error.type === 'invalid_request_error') {
|
||||
return 'OK'
|
||||
} else {
|
||||
throw new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, `Error deleting assistant - ${getErrorMessage(error)}`)
|
||||
}
|
||||
throw new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, `Error deleting assistant - ${getErrorMessage(error)}`)
|
||||
}
|
||||
} catch (error) {
|
||||
throw new InternalFlowiseError(
|
||||
@@ -164,7 +161,7 @@ const deleteAssistant = async (assistantId: string, isDeleteBoth: any): Promise<
|
||||
}
|
||||
}
|
||||
|
||||
const getAllAssistants = async (): Promise<any> => {
|
||||
const getAllAssistants = async (): Promise<Assistant[]> => {
|
||||
try {
|
||||
const appServer = getRunningExpressApp()
|
||||
const dbResponse = await appServer.AppDataSource.getRepository(Assistant).find()
|
||||
@@ -177,7 +174,7 @@ const getAllAssistants = async (): Promise<any> => {
|
||||
}
|
||||
}
|
||||
|
||||
const getAssistantById = async (assistantId: string): Promise<any> => {
|
||||
const getAssistantById = async (assistantId: string): Promise<Assistant> => {
|
||||
try {
|
||||
const appServer = getRunningExpressApp()
|
||||
const dbResponse = await appServer.AppDataSource.getRepository(Assistant).findOneBy({
|
||||
@@ -195,7 +192,7 @@ const getAssistantById = async (assistantId: string): Promise<any> => {
|
||||
}
|
||||
}
|
||||
|
||||
const updateAssistant = async (assistantId: string, requestBody: any): Promise<any> => {
|
||||
const updateAssistant = async (assistantId: string, requestBody: any): Promise<Assistant> => {
|
||||
try {
|
||||
const appServer = getRunningExpressApp()
|
||||
const assistant = await appServer.AppDataSource.getRepository(Assistant).findOneBy({
|
||||
|
||||
@@ -580,9 +580,8 @@ const processAndSaveChunks = async (data: IDocumentStoreLoaderForPreview) => {
|
||||
`Error: documentStoreServices.processAndSaveChunks - Document store ${data.storeId} not found`
|
||||
)
|
||||
}
|
||||
|
||||
const newLoaderId = data.id ?? uuidv4()
|
||||
const existingLoaders = JSON.parse(entity.loaders)
|
||||
const newLoaderId = data.id ?? uuidv4()
|
||||
const found = existingLoaders.find((ldr: IDocumentStoreLoader) => ldr.id === newLoaderId)
|
||||
if (found) {
|
||||
// clean up the current status and mark the loader as pending_sync
|
||||
@@ -590,6 +589,15 @@ const processAndSaveChunks = async (data: IDocumentStoreLoaderForPreview) => {
|
||||
found.totalChars = 0
|
||||
found.status = DocumentStoreStatus.SYNCING
|
||||
entity.loaders = JSON.stringify(existingLoaders)
|
||||
data.loaderId = found.loaderId
|
||||
data.loaderName = found.loaderName
|
||||
data.loaderConfig = found.loaderConfig
|
||||
data.splitterId = found.splitterId
|
||||
data.splitterName = found.splitterName
|
||||
data.splitterConfig = found.splitterConfig
|
||||
if (found.credential) {
|
||||
data.credential = found.credential
|
||||
}
|
||||
} else {
|
||||
let loader: IDocumentStoreLoader = {
|
||||
id: newLoaderId,
|
||||
@@ -833,6 +841,9 @@ const saveVectorStoreConfig = async (data: ICommonObject) => {
|
||||
config: data.embeddingConfig,
|
||||
name: data.embeddingName
|
||||
})
|
||||
} else if (entity.embeddingConfig && !data.embeddingName && !data.embeddingConfig) {
|
||||
data.embeddingConfig = JSON.parse(entity.embeddingConfig)?.config
|
||||
data.embeddingName = JSON.parse(entity.embeddingConfig)?.name
|
||||
} else if (!data.embeddingName && !data.embeddingConfig) {
|
||||
entity.embeddingConfig = null
|
||||
}
|
||||
@@ -842,6 +853,9 @@ const saveVectorStoreConfig = async (data: ICommonObject) => {
|
||||
config: data.vectorStoreConfig,
|
||||
name: data.vectorStoreName
|
||||
})
|
||||
} else if (entity.vectorStoreConfig && !data.vectorStoreName && !data.vectorStoreConfig) {
|
||||
data.vectorStoreConfig = JSON.parse(entity.vectorStoreConfig)?.config
|
||||
data.vectorStoreName = JSON.parse(entity.vectorStoreConfig)?.name
|
||||
} else if (!data.vectorStoreName && !data.vectorStoreConfig) {
|
||||
entity.vectorStoreConfig = null
|
||||
}
|
||||
@@ -851,6 +865,9 @@ const saveVectorStoreConfig = async (data: ICommonObject) => {
|
||||
config: data.recordManagerConfig,
|
||||
name: data.recordManagerName
|
||||
})
|
||||
} else if (entity.recordManagerConfig && !data.recordManagerName && !data.recordManagerConfig) {
|
||||
data.recordManagerConfig = JSON.parse(entity.recordManagerConfig)?.config
|
||||
data.recordManagerName = JSON.parse(entity.recordManagerConfig)?.name
|
||||
} else if (!data.recordManagerName && !data.recordManagerConfig) {
|
||||
entity.recordManagerConfig = null
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ const getAllChatMessageFeedback = async (
|
||||
}
|
||||
}
|
||||
|
||||
// Add chatmessage feedback for chatflowid
|
||||
// Add chatmessage feedback
|
||||
const createChatMessageFeedbackForChatflow = async (requestBody: Partial<IChatMessageFeedback>): Promise<any> => {
|
||||
try {
|
||||
const dbResponse = await utilAddChatMessageFeedback(requestBody)
|
||||
@@ -38,10 +38,10 @@ const createChatMessageFeedbackForChatflow = async (requestBody: Partial<IChatMe
|
||||
}
|
||||
}
|
||||
|
||||
// Add chatmessage feedback for chatflowid
|
||||
const updateChatMessageFeedbackForChatflow = async (chatflowId: string, requestBody: Partial<IChatMessageFeedback>): Promise<any> => {
|
||||
// Add chatmessage feedback
|
||||
const updateChatMessageFeedbackForChatflow = async (feedbackId: string, requestBody: Partial<IChatMessageFeedback>): Promise<any> => {
|
||||
try {
|
||||
const dbResponse = await utilUpdateChatMessageFeedback(chatflowId, requestBody)
|
||||
const dbResponse = await utilUpdateChatMessageFeedback(feedbackId, requestBody)
|
||||
return dbResponse
|
||||
} catch (error) {
|
||||
throw new InternalFlowiseError(
|
||||
|
||||
Reference in New Issue
Block a user