@@ -2,6 +2,7 @@ import { Request, Response, NextFunction } from 'express'
2
2
import assistantsService from '../../services/assistants'
3
3
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
4
4
import { StatusCodes } from 'http-status-codes'
5
+ import { AssistantType } from '../../Interface'
5
6
6
7
const createAssistant = async ( req : Request , res : Response , next : NextFunction ) => {
7
8
try {
@@ -35,7 +36,8 @@ const deleteAssistant = async (req: Request, res: Response, next: NextFunction)
35
36
36
37
const getAllAssistants = async ( req : Request , res : Response , next : NextFunction ) => {
37
38
try {
38
- const apiResponse = await assistantsService . getAllAssistants ( )
39
+ const type = req . query . type as AssistantType
40
+ const apiResponse = await assistantsService . getAllAssistants ( type )
39
41
return res . json ( apiResponse )
40
42
} catch ( error ) {
41
43
next ( error )
@@ -78,10 +80,56 @@ const updateAssistant = async (req: Request, res: Response, next: NextFunction)
78
80
}
79
81
}
80
82
83
+ const getChatModels = async ( req : Request , res : Response , next : NextFunction ) => {
84
+ try {
85
+ const apiResponse = await assistantsService . getChatModels ( )
86
+ return res . json ( apiResponse )
87
+ } catch ( error ) {
88
+ next ( error )
89
+ }
90
+ }
91
+
92
+ const getDocumentStores = async ( req : Request , res : Response , next : NextFunction ) => {
93
+ try {
94
+ const apiResponse = await assistantsService . getDocumentStores ( )
95
+ return res . json ( apiResponse )
96
+ } catch ( error ) {
97
+ next ( error )
98
+ }
99
+ }
100
+
101
+ const getTools = async ( req : Request , res : Response , next : NextFunction ) => {
102
+ try {
103
+ const apiResponse = await assistantsService . getTools ( )
104
+ return res . json ( apiResponse )
105
+ } catch ( error ) {
106
+ next ( error )
107
+ }
108
+ }
109
+
110
+ const generateAssistantInstruction = async ( req : Request , res : Response , next : NextFunction ) => {
111
+ try {
112
+ if ( ! req . body ) {
113
+ throw new InternalFlowiseError (
114
+ StatusCodes . PRECONDITION_FAILED ,
115
+ `Error: assistantsController.generateAssistantInstruction - body not provided!`
116
+ )
117
+ }
118
+ const apiResponse = await assistantsService . generateAssistantInstruction ( req . body . task , req . body . selectedChatModel )
119
+ return res . json ( apiResponse )
120
+ } catch ( error ) {
121
+ next ( error )
122
+ }
123
+ }
124
+
81
125
export default {
82
126
createAssistant,
83
127
deleteAssistant,
84
128
getAllAssistants,
85
129
getAssistantById,
86
- updateAssistant
130
+ updateAssistant,
131
+ getChatModels,
132
+ getDocumentStores,
133
+ getTools,
134
+ generateAssistantInstruction
87
135
}
0 commit comments