-
-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add gpt4 turbo to assistant * OpenAI Assistant V2 * update langfuse handler
- Loading branch information
1 parent
4782c0f
commit 7360d1d
Showing
25 changed files
with
21,405 additions
and
15,620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
313 changes: 265 additions & 48 deletions
313
packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
201 changes: 201 additions & 0 deletions
201
packages/server/src/controllers/openai-assistants-vector-store/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
import { Request, Response, NextFunction } from 'express' | ||
import { StatusCodes } from 'http-status-codes' | ||
import { InternalFlowiseError } from '../../errors/internalFlowiseError' | ||
import openAIAssistantVectorStoreService from '../../services/openai-assistants-vector-store' | ||
|
||
const getAssistantVectorStore = async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
if (typeof req.params === 'undefined' || !req.params.id) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.getAssistantVectorStore - id not provided!` | ||
) | ||
} | ||
if (typeof req.query === 'undefined' || !req.query.credential) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.getAssistantVectorStore - credential not provided!` | ||
) | ||
} | ||
const apiResponse = await openAIAssistantVectorStoreService.getAssistantVectorStore(req.query.credential as string, req.params.id) | ||
return res.json(apiResponse) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
const listAssistantVectorStore = async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
if (typeof req.query === 'undefined' || !req.query.credential) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.listAssistantVectorStore - credential not provided!` | ||
) | ||
} | ||
const apiResponse = await openAIAssistantVectorStoreService.listAssistantVectorStore(req.query.credential as string) | ||
return res.json(apiResponse) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
const createAssistantVectorStore = async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
if (!req.body) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.createAssistantVectorStore - body not provided!` | ||
) | ||
} | ||
if (typeof req.query === 'undefined' || !req.query.credential) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.createAssistantVectorStore - credential not provided!` | ||
) | ||
} | ||
const apiResponse = await openAIAssistantVectorStoreService.createAssistantVectorStore(req.query.credential as string, req.body) | ||
return res.json(apiResponse) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
const updateAssistantVectorStore = async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
if (typeof req.params === 'undefined' || !req.params.id) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.updateAssistantVectorStore - id not provided!` | ||
) | ||
} | ||
if (typeof req.query === 'undefined' || !req.query.credential) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.updateAssistantVectorStore - credential not provided!` | ||
) | ||
} | ||
if (!req.body) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.updateAssistantVectorStore - body not provided!` | ||
) | ||
} | ||
const apiResponse = await openAIAssistantVectorStoreService.updateAssistantVectorStore( | ||
req.query.credential as string, | ||
req.params.id, | ||
req.body | ||
) | ||
return res.json(apiResponse) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
const deleteAssistantVectorStore = async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
if (typeof req.params === 'undefined' || !req.params.id) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.deleteAssistantVectorStore - id not provided!` | ||
) | ||
} | ||
if (typeof req.query === 'undefined' || !req.query.credential) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.updateAssistantVectorStore - credential not provided!` | ||
) | ||
} | ||
const apiResponse = await openAIAssistantVectorStoreService.deleteAssistantVectorStore( | ||
req.query.credential as string, | ||
req.params.id as string | ||
) | ||
return res.json(apiResponse) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
const uploadFilesToAssistantVectorStore = async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
if (!req.body) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.uploadFilesToAssistantVectorStore - body not provided!` | ||
) | ||
} | ||
if (typeof req.params === 'undefined' || !req.params.id) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.uploadFilesToAssistantVectorStore - id not provided!` | ||
) | ||
} | ||
if (typeof req.query === 'undefined' || !req.query.credential) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.uploadFilesToAssistantVectorStore - credential not provided!` | ||
) | ||
} | ||
const files = req.files ?? [] | ||
const uploadFiles: { filePath: string; fileName: string }[] = [] | ||
|
||
if (Array.isArray(files)) { | ||
for (const file of files) { | ||
uploadFiles.push({ | ||
filePath: file.path, | ||
fileName: file.originalname | ||
}) | ||
} | ||
} | ||
|
||
const apiResponse = await openAIAssistantVectorStoreService.uploadFilesToAssistantVectorStore( | ||
req.query.credential as string, | ||
req.params.id as string, | ||
uploadFiles | ||
) | ||
return res.json(apiResponse) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
const deleteFilesFromAssistantVectorStore = async (req: Request, res: Response, next: NextFunction) => { | ||
try { | ||
if (!req.body) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.deleteFilesFromAssistantVectorStore - body not provided!` | ||
) | ||
} | ||
if (typeof req.params === 'undefined' || !req.params.id) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.deleteFilesFromAssistantVectorStore - id not provided!` | ||
) | ||
} | ||
if (typeof req.query === 'undefined' || !req.query.credential) { | ||
throw new InternalFlowiseError( | ||
StatusCodes.PRECONDITION_FAILED, | ||
`Error: openaiAssistantsVectorStoreController.deleteFilesFromAssistantVectorStore - credential not provided!` | ||
) | ||
} | ||
|
||
const apiResponse = await openAIAssistantVectorStoreService.deleteFilesFromAssistantVectorStore( | ||
req.query.credential as string, | ||
req.params.id as string, | ||
req.body.file_ids | ||
) | ||
return res.json(apiResponse) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
|
||
export default { | ||
getAssistantVectorStore, | ||
listAssistantVectorStore, | ||
createAssistantVectorStore, | ||
updateAssistantVectorStore, | ||
deleteAssistantVectorStore, | ||
uploadFilesToAssistantVectorStore, | ||
deleteFilesFromAssistantVectorStore | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.